3 Commits

Author SHA1 Message Date
Petra Baranski
731827264e Fix workflow indentation 2025-03-28 05:17:38 +01:00
Petra Baranski
100eb59bc8 Release 1.4.0
* up version to 1.4.0
* Remove deprecated code
* change release message
2025-03-28 05:04:55 +01:00
Petra Baranski
4518e402c7 Fix linkparser line handling with multiple parenthesis 2025-03-28 03:37:04 +01:00
15 changed files with 62 additions and 73 deletions

View File

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

View File

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

View File

@@ -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 for-each-ref refs/tags/$TAG_NAME --format='%(contents)')
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)

View File

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

View File

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

View File

@@ -14,9 +14,13 @@ maddy uses [semver versioning](https://semver.org/).
## Upcoming
## version 1.4.0 2025-03-28
* ![**CHANGED**](https://img.shields.io/badge/-CHANGED-%23e90) Updated google test to v1.16.0.
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) clang-format
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) automatic update dependencies ci
* ![**FIXED**](https://img.shields.io/badge/-FIXED-%23090) `(This is a [link](/ABC/some file) (the URL will include this).)` should not put the later parenthesis into the link url.
* ![**REMOVED**](https://img.shields.io/badge/-REMOVED-%23900) 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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