mirror of
https://github.com/progsource/maddy.git
synced 2026-03-25 16:00:39 +01:00
Compare commits
4 Commits
a5b18310a8
...
261e75f22f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
261e75f22f | ||
|
|
731827264e | ||
|
|
100eb59bc8 | ||
|
|
4518e402c7 |
3
.github/ISSUE_TEMPLATE/cpp-bug-report.yml
vendored
3
.github/ISSUE_TEMPLATE/cpp-bug-report.yml
vendored
@@ -37,7 +37,8 @@ body:
|
||||
label: maddy version
|
||||
description: What version of maddy are you using?
|
||||
options:
|
||||
- 1.3.0 (latest)
|
||||
- 1.4.0 (latest)
|
||||
- 1.3.0
|
||||
- 1.2.1
|
||||
- 1.2.0
|
||||
- 1.1.2
|
||||
|
||||
@@ -37,7 +37,8 @@ body:
|
||||
label: maddy version
|
||||
description: What version of maddy are you using?
|
||||
options:
|
||||
- 1.3.0 (latest)
|
||||
- 1.4.0 (latest)
|
||||
- 1.3.0
|
||||
- 1.2.1
|
||||
- 1.2.0
|
||||
- 1.1.2
|
||||
|
||||
16
.github/workflows/create-release-package.yml
vendored
16
.github/workflows/create-release-package.yml
vendored
@@ -25,10 +25,24 @@ jobs:
|
||||
cmake -DMADDY_CREATE_PACKAGE=ON ..
|
||||
make maddy_package
|
||||
|
||||
- name: Get current tag message
|
||||
id: tag-message
|
||||
run: |
|
||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||
TAG_MESSAGE=$(git tag -l --format='%(contents)' $TAG_NAME)
|
||||
echo "message<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: create release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/maddy-src.zip
|
||||
tag: ${{ github.ref }}
|
||||
body: "You can find all changes of this release in the [changelog](https://github.com/progsource/maddy/blob/master/CHANGELOG.md)"
|
||||
body: |
|
||||
${{ steps.tag-message.outputs.message }}
|
||||
|
||||
---
|
||||
|
||||
You can find all changes of this release in the [changelog](https://github.com/progsource/maddy/blob/master/CHANGELOG.md)
|
||||
|
||||
6
.github/workflows/run-checks.yml
vendored
6
.github/workflows/run-checks.yml
vendored
@@ -1,11 +1,13 @@
|
||||
name: run-checks
|
||||
|
||||
run-name: run-checks ${{ github.ref }}
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
pull_request_target:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
run-clang-format:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
6
.github/workflows/run-tests.yml
vendored
6
.github/workflows/run-tests.yml
vendored
@@ -1,11 +1,13 @@
|
||||
name: run-tests
|
||||
run-name: test ${{ github.ref }}
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
test-on-ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -14,9 +14,13 @@ maddy uses [semver versioning](https://semver.org/).
|
||||
|
||||
## Upcoming
|
||||
|
||||
## version 1.4.0 2025-03-28
|
||||
|
||||
*  Updated google test to v1.16.0.
|
||||
*  clang-format
|
||||
*  automatic update dependencies ci
|
||||
*  `(This is a [link](/ABC/some file) (the URL will include this).)` should not put the later parenthesis into the link url.
|
||||
*  config flags `isEmphasizedParserEnabled` and `isHTMLWrappedInParagraph`. Use `config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER;` and `config->enabledParsers |= maddy::types::HTML_PARSER;` to gain the same behavior as if the previous config flags were set to `false`.
|
||||
|
||||
## version 1.3.0 2023-08-26
|
||||
|
||||
|
||||
@@ -10,17 +10,10 @@ improve the code? Then [create a GitHub issue](https://github.com/progsource/mad
|
||||
## Creating Pull-Requests
|
||||
|
||||
* Use a branch other than master.
|
||||
* Add yourself to the `AUTHORS` file.
|
||||
* Try to stick with the code style the files are having right now.
|
||||
* Write in your commit messages what/why you did something. Often times a one-liner might be enough, but if you want to write more, make an empty line in between like:
|
||||
```
|
||||
Short description
|
||||
|
||||
More and longer text for the commit message with some more information.
|
||||
That can go over multiple lines.
|
||||
```
|
||||
Do not include Github issue ticket numbers inside commit messages.
|
||||
* Feel free to add yourself to the `AUTHORS` file. (optional)
|
||||
* Use clang-format to format the code.
|
||||
* Write in your commit messages what/why you did something. Often times a one-liner might be enough.
|
||||
* Explain for what your PR is for - like providing a use-case or something similar.
|
||||
* Update documentation of the Markdown syntax if anything changed there. (`docs/definitions.md`)
|
||||
* Add a changelog entry at "Upcoming" inside of `CHANGELOG.md`
|
||||
* Make sure, that the tests are successful.
|
||||
* Make sure, that the tests are successful and if you wrote a bugfix, to have a test, that highlights the issue.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# maddy
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://semver.org/)
|
||||
[](https://semver.org/)
|
||||
|
||||
maddy is a C++ Markdown to HTML **header-only** parser library.
|
||||
|
||||
@@ -70,10 +70,8 @@ std::stringstream markdownInput("");
|
||||
|
||||
// config is optional
|
||||
std::shared_ptr<maddy::ParserConfig> config = std::make_shared<maddy::ParserConfig>();
|
||||
// config->isEmphasizedParserEnabled = false; // default true - this flag is deprecated
|
||||
// config->isHTMLWrappedInParagraph = false; // default true - this flag is deprecated
|
||||
config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER; // equivalent to !isEmphasizedParserEnabled
|
||||
config->enabledParsers |= maddy::types::HTML_PARSER; // equivalent to !isHTMLWrappedInParagraph
|
||||
config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER; // disable emphasized parser
|
||||
config->enabledParsers |= maddy::types::HTML_PARSER; // do not wrap HTML in paragraph
|
||||
|
||||
std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>(config);
|
||||
std::string htmlOutput = parser->Parse(markdownInput);
|
||||
|
||||
@@ -7,9 +7,9 @@ destroy the output, if there was HTML in your markdown.
|
||||
The Parser expects you to use spaces and not tabs for indentation in the
|
||||
markdown.
|
||||
|
||||
If a line starts with `<` and `config->isHTMLWrappedInParagraph` is false, it
|
||||
expects that the upcoming line is HTML and therefor will not be surrounded by a
|
||||
paragraph.
|
||||
If a line starts with `<` and `config->enabledParsers |= maddy::types::HTML_PARSER;`
|
||||
is set, it expects that the upcoming line is HTML and therefor will not be
|
||||
surrounded by a paragraph.
|
||||
|
||||
## Headlines
|
||||
|
||||
@@ -279,7 +279,7 @@ results in
|
||||
|
||||
## emphasized
|
||||
|
||||
This can be disabled by setting `config->isEmphasizedParserEnabled = false`.
|
||||
This can be disabled by setting `config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER;`.
|
||||
|
||||
```
|
||||
_emphasized text_
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
*/
|
||||
void Parse(std::string& line) override
|
||||
{
|
||||
static std::regex re(R"(\[([^\]]*)\]\(([^\]]*)\))");
|
||||
static std::regex re(R"(\[([^\]]*)\]\(([^)]*)\))");
|
||||
static std::string replacement = "<a href=\"$2\">$1</a>";
|
||||
|
||||
line = std::regex_replace(line, re, replacement);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
*/
|
||||
static const std::string& version()
|
||||
{
|
||||
static const std::string v = "1.3.0";
|
||||
static const std::string v = "1.4.0";
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -72,17 +72,6 @@ public:
|
||||
*/
|
||||
Parser(std::shared_ptr<ParserConfig> config = nullptr) : config(config)
|
||||
{
|
||||
// deprecated backward compatibility
|
||||
// will be removed in 1.4.0 latest including the booleans
|
||||
if (this->config && !this->config->isEmphasizedParserEnabled)
|
||||
{
|
||||
this->config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER;
|
||||
}
|
||||
if (this->config && !this->config->isHTMLWrappedInParagraph)
|
||||
{
|
||||
this->config->enabledParsers |= maddy::types::HTML_PARSER;
|
||||
}
|
||||
|
||||
if (!this->config ||
|
||||
(this->config->enabledParsers & maddy::types::BREAKLINE_PARSER) != 0)
|
||||
{
|
||||
|
||||
@@ -58,20 +58,6 @@ enum PARSER_TYPE : uint32_t
|
||||
*/
|
||||
struct ParserConfig
|
||||
{
|
||||
/**
|
||||
* @deprecated will be removed in 1.4.0 latest
|
||||
*
|
||||
* this flag = false == `enabledParsers &= ~maddy::types::EMPHASIZED_PARSER`
|
||||
*/
|
||||
bool isEmphasizedParserEnabled;
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in 1.4.0 latest
|
||||
*
|
||||
* this flag = false == `enabledParsers |= maddy::types::HTML_PARSER`
|
||||
*/
|
||||
bool isHTMLWrappedInParagraph;
|
||||
|
||||
/**
|
||||
* en-/disable headline inline-parsing
|
||||
*
|
||||
@@ -85,9 +71,7 @@ struct ParserConfig
|
||||
uint32_t enabledParsers;
|
||||
|
||||
ParserConfig()
|
||||
: isEmphasizedParserEnabled(true)
|
||||
, isHTMLWrappedInParagraph(true)
|
||||
, isHeadlineInlineParsingEnabled(true)
|
||||
: isHeadlineInlineParsingEnabled(true)
|
||||
, enabledParsers(maddy::types::DEFAULT)
|
||||
{}
|
||||
}; // class ParserConfig
|
||||
|
||||
@@ -37,6 +37,22 @@ TEST(MADDY_LINKPARSER, ItReplacesMarkdownWithLinks)
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(
|
||||
MADDY_LINKPARSER, ItReplacesMarkdownProperlyEvenWithMultipleParenthesisInLine
|
||||
)
|
||||
{
|
||||
std::string text =
|
||||
"(This is a [link](/ABC/some file) (the URL will include this).)";
|
||||
std::string expected =
|
||||
"(This is a <a href=\"/ABC/some file\">link</a> (the URL will include "
|
||||
"this).)";
|
||||
auto linkParser = std::make_shared<maddy::LinkParser>();
|
||||
|
||||
linkParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class DISABLED_MADDY_LINKPARSER : public ::testing::Test
|
||||
|
||||
@@ -21,21 +21,6 @@ TEST(MADDY_PARSER, ItShouldParse)
|
||||
ASSERT_EQ(testHtml, output);
|
||||
}
|
||||
|
||||
TEST(MADDY_PARSER, ItShouldParseWithConfig)
|
||||
{
|
||||
auto config = std::make_shared<maddy::ParserConfig>();
|
||||
config->isEmphasizedParserEnabled = false;
|
||||
config->isHTMLWrappedInParagraph = false;
|
||||
|
||||
auto parser = std::make_shared<maddy::Parser>(config);
|
||||
|
||||
std::stringstream markdown(testMarkdown);
|
||||
|
||||
const std::string output = parser->Parse(markdown);
|
||||
|
||||
ASSERT_EQ(testHtml2, output);
|
||||
}
|
||||
|
||||
TEST(MADDY_PARSER, ItShouldParseWithBitwiseConfig)
|
||||
{
|
||||
auto config = std::make_shared<maddy::ParserConfig>();
|
||||
|
||||
@@ -123,7 +123,7 @@ def main():
|
||||
"""
|
||||
if len(sys.argv) != 2:
|
||||
print(
|
||||
"Usage: python check_clang_format.py <dry_run|format>"
|
||||
"Usage: python format.py <dry_run|format>"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user