mirror of
https://github.com/progsource/maddy.git
synced 2026-03-25 07:50:39 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fe37d5a1f | ||
|
|
6e01add19a | ||
|
|
65730beffa | ||
|
|
4722932068 | ||
|
|
c4ca557e43 | ||
|
|
650ea2bc82 | ||
|
|
ce81283b26 | ||
|
|
211b627a75 |
4
.github/ISSUE_TEMPLATE/cpp-bug-report.yml
vendored
4
.github/ISSUE_TEMPLATE/cpp-bug-report.yml
vendored
@@ -37,7 +37,9 @@ body:
|
|||||||
label: maddy version
|
label: maddy version
|
||||||
description: What version of maddy are you using?
|
description: What version of maddy are you using?
|
||||||
options:
|
options:
|
||||||
- 1.2.0 (latest)
|
- 1.3.0 (latest)
|
||||||
|
- 1.2.1
|
||||||
|
- 1.2.0
|
||||||
- 1.1.2
|
- 1.1.2
|
||||||
- 1.1.1
|
- 1.1.1
|
||||||
- 1.1.0
|
- 1.1.0
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ body:
|
|||||||
label: maddy version
|
label: maddy version
|
||||||
description: What version of maddy are you using?
|
description: What version of maddy are you using?
|
||||||
options:
|
options:
|
||||||
- 1.2.0 (latest)
|
- 1.3.0 (latest)
|
||||||
|
- 1.2.1
|
||||||
|
- 1.2.0
|
||||||
- 1.1.2
|
- 1.1.2
|
||||||
- 1.1.1
|
- 1.1.1
|
||||||
- 1.1.0
|
- 1.1.0
|
||||||
@@ -51,7 +53,7 @@ body:
|
|||||||
id: example
|
id: example
|
||||||
attributes:
|
attributes:
|
||||||
label: Minimal Mardown example
|
label: Minimal Mardown example
|
||||||
description: To be able to reproduce your issue, please give some example Markdown which creates problems.
|
description: To be able to reproduce your issue, please give some example Markdown which creates problems. Please indent the Markdown by 4 spaces.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
10
.github/ISSUE_TEMPLATE/other.yml
vendored
Normal file
10
.github/ISSUE_TEMPLATE/other.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
name: Other
|
||||||
|
description: Anything that doesn't fit into one of the other issue categories
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: whats-up
|
||||||
|
attributes:
|
||||||
|
label: What is the issue?
|
||||||
|
description: Is some tooling not working? Performance issues? ...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
2
.github/workflows/run-tests.yml
vendored
2
.github/workflows/run-tests.yml
vendored
@@ -4,9 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- dev
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- dev
|
||||||
jobs:
|
jobs:
|
||||||
test-on-ubuntu:
|
test-on-ubuntu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ maddy uses [semver versioning](https://semver.org/).
|
|||||||
|
|
||||||
* ?
|
* ?
|
||||||
|
|
||||||
|
## version 1.3.0 2023-08-26
|
||||||
|
|
||||||
|
*  Headlines can have inline parsing now. It is on by default, but can be disabled by config.
|
||||||
|
|
||||||
## version 1.2.1 2023-08-06
|
## version 1.2.1 2023-08-06
|
||||||
|
|
||||||
*  Parser.h version() method clashing with VERSION defines at global scope
|
*  Parser.h version() method clashing with VERSION defines at global scope
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# maddy
|
# maddy
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://semver.org/)
|
[](https://semver.org/)
|
||||||
|
|
||||||
maddy is a C++ Markdown to HTML **header-only** parser library.
|
maddy is a C++ Markdown to HTML **header-only** parser library.
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
HeadlineParser(
|
HeadlineParser(
|
||||||
std::function<void(std::string&)> parseLineCallback,
|
std::function<void(std::string&)> parseLineCallback,
|
||||||
std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback
|
std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback,
|
||||||
|
bool isInlineParserAllowed = true
|
||||||
)
|
)
|
||||||
: BlockParser(parseLineCallback, getBlockParserForLineCallback)
|
: BlockParser(parseLineCallback, getBlockParserForLineCallback)
|
||||||
|
, isInlineParserAllowed(isInlineParserAllowed)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +105,7 @@ protected:
|
|||||||
bool
|
bool
|
||||||
isLineParserAllowed() const override
|
isLineParserAllowed() const override
|
||||||
{
|
{
|
||||||
return false;
|
return this->isInlineParserAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -131,6 +133,9 @@ protected:
|
|||||||
line = std::regex_replace(line, hlRegex[i], hlReplacement[i]);
|
line = std::regex_replace(line, hlRegex[i], hlReplacement[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isInlineParserAllowed;
|
||||||
}; // class HeadlineParser
|
}; // class HeadlineParser
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
* Check https://github.com/progsource/maddy/blob/master/CHANGELOG.md
|
* Check https://github.com/progsource/maddy/blob/master/CHANGELOG.md
|
||||||
* for the changelog.
|
* for the changelog.
|
||||||
*/
|
*/
|
||||||
static const std::string& version() { static const std::string v = "1.2.1"; return v; }
|
static const std::string& version() { static const std::string v = "1.3.0"; return v; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ctor
|
* ctor
|
||||||
@@ -287,10 +287,22 @@ private:
|
|||||||
maddy::HeadlineParser::IsStartingLine(line)
|
maddy::HeadlineParser::IsStartingLine(line)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
parser = std::make_shared<maddy::HeadlineParser>(
|
if (!this->config || this->config->isHeadlineInlineParsingEnabled)
|
||||||
nullptr,
|
{
|
||||||
nullptr
|
parser = std::make_shared<maddy::HeadlineParser>(
|
||||||
);
|
[this](std::string& line){ this->runLineParser(line); },
|
||||||
|
nullptr,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parser = std::make_shared<maddy::HeadlineParser>(
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -70,11 +70,22 @@ struct ParserConfig
|
|||||||
*/
|
*/
|
||||||
bool isHTMLWrappedInParagraph;
|
bool isHTMLWrappedInParagraph;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* en-/disable headline inline-parsing
|
||||||
|
*
|
||||||
|
* default: enabled
|
||||||
|
*/
|
||||||
|
bool isHeadlineInlineParsingEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enabled parsers bitfield
|
||||||
|
*/
|
||||||
uint32_t enabledParsers;
|
uint32_t enabledParsers;
|
||||||
|
|
||||||
ParserConfig()
|
ParserConfig()
|
||||||
: isEmphasizedParserEnabled(true)
|
: isEmphasizedParserEnabled(true)
|
||||||
, isHTMLWrappedInParagraph(true)
|
, isHTMLWrappedInParagraph(true)
|
||||||
|
, isHeadlineInlineParsingEnabled(true)
|
||||||
, enabledParsers(maddy::types::DEFAULT)
|
, enabledParsers(maddy::types::DEFAULT)
|
||||||
{}
|
{}
|
||||||
}; // class ParserConfig
|
}; // class ParserConfig
|
||||||
|
|||||||
@@ -64,3 +64,34 @@ TEST(MADDY_PARSER, ItShouldParseWithSmallConfig)
|
|||||||
|
|
||||||
ASSERT_EQ(testHtml3, output);
|
ASSERT_EQ(testHtml3, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(MADDY_PARSER, ItShouldParseInlineCodeInHeadlines)
|
||||||
|
{
|
||||||
|
const std::string headlineTest = R"(
|
||||||
|
# Some **test** markdown
|
||||||
|
)";
|
||||||
|
const std::string expectedHTML = "<h1>Some <strong>test</strong> markdown</h1>";
|
||||||
|
std::stringstream markdown(headlineTest);
|
||||||
|
|
||||||
|
auto parser = std::make_shared<maddy::Parser>();
|
||||||
|
|
||||||
|
const std::string output = parser->Parse(markdown);
|
||||||
|
|
||||||
|
ASSERT_EQ(expectedHTML, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MADDY_PARSER, ItShouldNotParseInlineCodeInHeadlineIfDisabled)
|
||||||
|
{
|
||||||
|
const std::string headlineTest = R"(
|
||||||
|
# Some **test** markdown
|
||||||
|
)";
|
||||||
|
const std::string expectedHTML = "<h1>Some **test** markdown</h1>";
|
||||||
|
std::stringstream markdown(headlineTest);
|
||||||
|
auto config = std::make_shared<maddy::ParserConfig>();
|
||||||
|
config->isHeadlineInlineParsingEnabled = false;
|
||||||
|
auto parser = std::make_shared<maddy::Parser>(config);
|
||||||
|
|
||||||
|
const std::string output = parser->Parse(markdown);
|
||||||
|
|
||||||
|
ASSERT_EQ(expectedHTML, output);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user