8 Commits
1.2.1 ... 1.3.0

Author SHA1 Message Date
Petra Baranski
1fe37d5a1f chore: fix other.yml 2023-08-26 13:34:41 +02:00
Petra Baranski
6e01add19a Merge pull request #49 from progsource/rc-1.3.0
Release 1.3.0
2023-08-26 13:33:19 +02:00
Petra Baranski
65730beffa chore: update version to 1.3.0 2023-08-26 13:28:28 +02:00
Petra Baranski
4722932068 docs: updated changelog 2023-08-26 13:25:11 +02:00
Petra Baranski
c4ca557e43 Merge pull request #48 from progsource/headline-inline-parsing
Headline inline parsing
2023-08-26 13:11:04 +02:00
Petra Baranski
650ea2bc82 ci: enable test runners for dev branch 2023-08-26 13:08:06 +02:00
Petra Baranski
ce81283b26 feat: enable optional inline parsing in headlines 2023-08-26 13:03:35 +02:00
Petra Baranski
211b627a75 chore: added 'other' issue template 2023-08-26 13:01:27 +02:00
10 changed files with 90 additions and 11 deletions

View File

@@ -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

View File

@@ -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
View 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

View File

@@ -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

View File

@@ -16,6 +16,10 @@ maddy uses [semver versioning](https://semver.org/).
* ? * ?
## version 1.3.0 2023-08-26
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) 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
* ![**FIXED**](https://img.shields.io/badge/-FIXED-%23090) Parser.h version() method clashing with VERSION defines at global scope * ![**FIXED**](https://img.shields.io/badge/-FIXED-%23090) Parser.h version() method clashing with VERSION defines at global scope

View File

@@ -1,7 +1,7 @@
# maddy # maddy
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Version: 1.2.1](https://img.shields.io/badge/Version-1.2.1-brightgreen.svg)](https://semver.org/) [![Version: 1.3.0](https://img.shields.io/badge/Version-1.3.0-brightgreen.svg)](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.

View File

@@ -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
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -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
@@ -286,12 +286,24 @@ private:
) && ) &&
maddy::HeadlineParser::IsStartingLine(line) maddy::HeadlineParser::IsStartingLine(line)
) )
{
if (!this->config || this->config->isHeadlineInlineParsingEnabled)
{
parser = std::make_shared<maddy::HeadlineParser>(
[this](std::string& line){ this->runLineParser(line); },
nullptr,
true
);
}
else
{ {
parser = std::make_shared<maddy::HeadlineParser>( parser = std::make_shared<maddy::HeadlineParser>(
nullptr, nullptr,
nullptr nullptr,
false
); );
} }
}
else if ( else if (
( (
!this->config || !this->config ||

View File

@@ -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

View File

@@ -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);
}