| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 52515ae commit d96ad5c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | /*********************************************************************** | |
| 2 | 2 | * | |
| 3 | - * Copyright (C) 2014-2018 wereturtle | ||
| 3 | + * Copyright (C) 2014-2019 wereturtle | ||
| 4 | 4 | * | |
| 5 | 5 | * This program is free software: you can redistribute it and/or modify | |
| 6 | 6 | * it under the terms of the GNU General Public License as published by | |
@@ -88,10 +88,20 @@ ExporterFactory::ExporterFactory() | |||
| 88 | 88 | CommandLineExporter* exporter = NULL; | |
| 89 | 89 | bool pandocIsAvailable = isCommandAvailable("pandoc --version"); | |
| 90 | 90 | bool mmdIsAvailable = isCommandAvailable("multimarkdown --version"); | |
| 91 | - bool discountIsAvailable = isCommandAvailable("markdown -V"); | ||
| 91 | + bool discountIsAvailable = false; | ||
| 92 | 92 | bool cmarkIsAvailable = isCommandAvailable("cmark --version"); | |
| 93 | 93 | bool cmarkGfmIsAvailable = isCommandAvailable("cmark-gfm --version"); | |
| 94 | 94 | ||
| 95 | + // MultiMarkdown installs a "markdown" script to launch the "multimarkdown" | ||
| 96 | + // command. Discount's executable also happens to be named "markdown". | ||
| 97 | + // To avoid confusion, check if MultiMarkdown is actually installed, and | ||
| 98 | + // only if it isn't installed should Discount be checked for availability. | ||
| 99 | + // | ||
| 100 | + if (!mmdIsAvailable) | ||
| 101 | + { | ||
| 102 | + discountIsAvailable = isCommandAvailable("markdown -V"); | ||
| 103 | + } | ||
| 104 | + | ||
| 95 | 105 | SundownExporter* sundownExporter = new SundownExporter(); | |
| 96 | 106 | fileExporters.append(sundownExporter); | |
| 97 | 107 | htmlExporters.append(sundownExporter); | |
@@ -328,13 +338,26 @@ QList<int> ExporterFactory::extractVersionNumber(const QString& command) const | |||
| 328 | 338 | } | |
| 329 | 339 | ||
| 330 | 340 | QString versionStr = QString::fromUtf8(process.readAllStandardOutput().data()); | |
| 331 | - QRegularExpression versionRegex("\\d+(\\.\\d+)*"); | ||
| 341 | + QRegularExpression versionRegex1("v(\\d+(\\.\\d+)*)"); | ||
| 342 | + QRegularExpression versionRegex2("(\\d+(\\.\\d+)*)"); | ||
| 332 | 343 | QRegularExpressionMatch match; | |
| 333 | - int pos = versionStr.indexOf(versionRegex, 0, &match); | ||
| 344 | + | ||
| 345 | + // Prefer searching for "v1.6.3" version format over "1.6.3" format | ||
| 346 | + int pos = versionStr.indexOf(versionRegex1, 0, &match); | ||
| 334 | 347 | ||
| 335 | 348 | if ((pos >= 0) && match.hasMatch()) | |
| 336 | 349 | { | |
| 337 | - versionStr = match.captured(); | ||
| 350 | + versionStr = match.captured(1); | ||
| 351 | + } | ||
| 352 | + // Else try the "1.6.3" format without the "v" in front | ||
| 353 | + else | ||
| 354 | + { | ||
| 355 | + pos = versionStr.indexOf(versionRegex2, 0, &match); | ||
| 356 | + | ||
| 357 | + if ((pos >= 0) && match.hasMatch()) | ||
| 358 | + { | ||
| 359 | + versionStr = match.captured(1); | ||
| 360 | + } | ||
| 338 | 361 | } | |
| 339 | 362 | ||
| 340 | 363 | QStringList numbers = versionStr.split('.', QString::SkipEmptyParts); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments