Merge pull request #43 from progsource/version-1.2.0

Version 1.2.0
This commit is contained in:
Petra Baranski
2023-07-27 19:05:08 +02:00
committed by GitHub
21 changed files with 278 additions and 67 deletions

View File

@@ -0,0 +1,62 @@
name: C++ Bug Report
description: File a bug report regarding C++ problems
title: "[Bug][C++]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: os
attributes:
label: Operating System
description: On which OS are you running maddy?
placeholder: ex. Windows/Linux/OSX
validations:
required: true
- type: input
id: compiler
attributes:
label: Compiler
description: Which compiler do you use?
placeholder: ex. mingw/Visual Studio/clang
validations:
required: true
- type: input
id: compiler_flags
attributes:
label: Compiler flags
description: Which compiler flags do you use?
placeholder: ex. -fno-rtti
validations:
required: true
- type: dropdown
id: maddy_version
attributes:
label: maddy version
description: What version of maddy are you using?
options:
- 1.2.0 (latest)
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
validations:
required: true
- type: textarea
id: example
label: Minimal C++ example
description: To be able to reproduce your issue, please give some example C++ code which creates problems.
validations:
required: true
- type: textarea
id: whats-wrong
attributes:
label: What is not working? What did you try?
description: Also, what did you expect to happen?
validations:
required: true

View File

@@ -0,0 +1,15 @@
name: Feature Request
description: Missing some feature?
labels: ["feature"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to create a feature request!
- type: textarea
id: feature-description
attributes:
label: What are you missing in maddy?
description: If you want some extra Markdown supported, please also write a Markdown example and an expected HTML output.
validations:
required: true

View File

@@ -0,0 +1,62 @@
name: Markdown Bug Report
description: File a bug report regarding Markdown problems
title: "[Bug][Markdown]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: os
attributes:
label: Operating System
description: On which OS are you running maddy?
placeholder: ex. Windows/Linux/OSX
validations:
required: true
- type: input
id: compiler
attributes:
label: Compiler
description: Which compiler do you use?
placeholder: ex. mingw/Visual Studio/clang
validations:
required: true
- type: input
id: compiler_flags
attributes:
label: Compiler flags
description: Which compiler flags do you use?
placeholder: ex. -fno-rtti
validations:
required: true
- type: dropdown
id: maddy_version
attributes:
label: maddy version
description: What version of maddy are you using?
options:
- 1.2.0 (latest)
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
validations:
required: true
- type: textarea
id: example
label: Minimal Mardown example
description: To be able to reproduce your issue, please give some example Markdown which creates problems.
validations:
required: true
- type: textarea
id: whats-wrong
attributes:
label: What is not working? What did you try?
description: Also, what did you expect to happen?
validations:
required: true

View File

@@ -0,0 +1,33 @@
name: release
permissions:
contents: write
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0" # <--= optional, use most recent 3.25.x version
ninjaVersion: "^1.11.1" # <--= optional, use most recent 1.x version
- name: create zip
run: |
mkdir tmp
cd tmp
cmake -DMADDY_CREATE_PACKAGE=ON ..
make maddy_package
- 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)"

View File

@@ -25,6 +25,7 @@ jobs:
- name: run tests
run: |
./build/MaddyTests
test-on-windows:
runs-on: windows-latest
steps:
@@ -42,6 +43,7 @@ jobs:
- name: run tests
run: |
./build/Debug/MaddyTests.exe
test-on-osx:
runs-on: macos-latest
steps:

View File

@@ -14,18 +14,23 @@ maddy uses [semver versioning](https://semver.org/).
## Upcoming
* ?
## version 1.2.0 2023-07-27
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) Added Changelog
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) Added contribution guideline
* ![**CHANGED**](https://img.shields.io/badge/-CHANGED-%23e90) updated cmake minimum required version to 3.25
* ![**CHANGED**](https://img.shields.io/badge/-CHANGED-%23e90) gtest is now loaded via cmake and not a git submodule any longer - updated gtest version to 1.13.0
* ![**CHANGED**](https://img.shields.io/badge/-CHANGED-%23e90) tests are only run if the cmake option `MADDY_BUILD_WITH_TESTS` is on, moved test cmake code to the `tests` subfolder
* ![**REMOVED**](https://img.shields.io/badge/-REMOVED-%23900) travis CI and appveyor
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) GitHub workflow
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) GitHub workflow for tests
* ![**DEPRECATED**](https://img.shields.io/badge/-DEPRECATED-%23666) config flags `isEmphasizedParserEnabled` and `isHTMLWrappedInParagraph`
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) config flag `enabledParsers` to en-/disable each parser separately
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) class attribute to code blocks if there is text after the three backticks like ` ```cpp`
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) optional support for latex blocks - it's off by default
* ?
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) version info to the parser class
* ![**ADDED**](https://img.shields.io/badge/-ADDED-%23099) GitHub workflow for release, so that one can include maddy easier via cmake's `FetchContent`
## version 1.1.2 2020-10-04

View File

@@ -7,49 +7,33 @@ project(maddy)
# ------------------------------------------------------------------------------
set(MADDY_CPP_VERSION 14)
add_definitions(-DCPP_VERSION=${MADDY_CPP_VERSION})
# ------------------------------------------------------------------------------
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# ------------------------------------------------------------------------------
option(MADDY_BUILD_WITH_TESTS "enable building tests" OFF)
option(MADDY_BUILD_WITH_TESTS "enable building tests - does not work with zip download" OFF)
if(${MADDY_BUILD_WITH_TESTS})
enable_testing()
endif()
option(MADDY_CREATE_PACKAGE "create a package for a version release" OFF)
# ------------------------------------------------------------------------------
set(MADDY_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
# ------------------------------------------------------------------------------
if (UNIX)
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -std=c++${MADDY_CPP_VERSION} -Wall -Wpedantic -Wextra -Wno-ignored-qualifiers -fno-rtti -fno-exceptions -fsanitize=address -fno-omit-frame-pointer"
)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ------------------------------------------------------------------------------
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER}
-fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message(STATUS "Found Gold linker, use faster linker")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold ")
endif()
if(${CMAKE_CXX_STANDARD} LESS 14)
message(FATAL_ERROR "maddy requires >=C++14")
endif()
# ------------------------------------------------------------------------------
@@ -64,3 +48,14 @@ target_include_directories(maddy INTERFACE
if(${MADDY_BUILD_WITH_TESTS})
add_subdirectory(tests)
endif()
# ------------------------------------------------------------------------------
if(${MADDY_CREATE_PACKAGE})
set(MADDY_PACKAGE_FILES include/ CMakeLists.txt LICENSE)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${MADDY_PACKAGE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${MADDY_PACKAGE_FILES})
add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip)
endif()

View File

@@ -1,17 +0,0 @@
## Minimal Code Example
```
```
## Conditions
. | .
--------------------- | ------------------
**Operating System:** | ?
**Compiler:** | ?
**Compiler flags:** | ?
**maddy version:** | ?
## Description
What did you try? What is not working?

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.1.2](https://img.shields.io/badge/Version-1.1.2-brightgreen.svg)](https://semver.org/)
[![Version: 1.2.0](https://img.shields.io/badge/Version-1.1.2-brightgreen.svg)](https://semver.org/)
maddy is a C++ Markdown to HTML **header-only** parser library.
@@ -21,13 +21,40 @@ It is tested to work on:
## Why maddy?
When I was needing a Markdown parser in C++ I couldn't find any, that was
When I was looking for a Markdown parser in C++, I couldn't find any, that was
fitting my needs. So I simply wrote my own one.
## Markdown syntax
The supported syntax can be found in the [definitions docs](docs/definitions.md).
## How to add maddy to your cmake project
You can use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)
which was introduced in CMake 3.11.
This way you can add
```cmake
include(FetchContent)
FetchContent_Declare(
maddy
URL https://github.com/progsource/maddy/.../maddy-src.zip
)
FetchContent_MakeAvailable(maddy)
add_executable(my_exe)
target_link_libraries(my_exe PUBLIC maddy)
```
to your CMake file to make it work. Check the
[release](https://github.com/progsource/maddy/releases) for the full
zip-file-url.
The zip only contains a `CMakeLists.txt`, the `include` folder and the `LICENSE`
file.
## How to use
To use maddy in your project, simply add the include path of maddy to yours
@@ -45,14 +72,15 @@ std::stringstream markdownInput("");
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;
config->enabledParsers |= maddy::types::HTML_PARSER;
config->enabledParsers &= ~maddy::types::EMPHASIZED_PARSER; // equivalent to !isEmphasizedParserEnabled
config->enabledParsers |= maddy::types::HTML_PARSER; // equivalent to !isHTMLWrappedInParagraph
std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>(config);
std::string htmlOutput = parser->Parse(markdownInput);
```
You can find all parser flags in [`include/maddy/parserconfig.h`](include/maddy/parserconfig.h).
You can find all parser flags in
[`include/maddy/parserconfig.h`](include/maddy/parserconfig.h).
## How to run the tests
@@ -77,7 +105,6 @@ make test # or run the executable in ../build/MaddyTests
There are different possibilities:
* [Create a GitHub issue](https://github.com/progsource/maddy/issues/new)
* Create a pull request with an own branch (don't forget to put yourself in the
AUTHORS file)
* Create a pull request with an own branch
Please also read [CONTRIBUTING.md](CONTRIBUTING.md).

View File

@@ -54,7 +54,7 @@ public:
static bool
IsStartingLine(const std::string& line)
{
static std::regex re("^- \\[[x| ]\\] .*");
static std::regex re(R"(^- \[[x| ]\] .*)");
return std::regex_match(line, re);
}
@@ -92,11 +92,11 @@ protected:
static std::regex lineRegex("^(- )");
line = std::regex_replace(line, lineRegex, "");
static std::regex emptyBoxRegex("^\\[ \\]");
static std::regex emptyBoxRegex(R"(^\[ \])");
static std::string emptyBoxReplacement = "<input type=\"checkbox\"/>";
line = std::regex_replace(line, emptyBoxRegex, emptyBoxReplacement);
static std::regex boxRegex("^\\[x\\]");
static std::regex boxRegex(R"(^\[x\])");
static std::string boxReplacement = "<input type=\"checkbox\" checked=\"checked\"/>";
line = std::regex_replace(line, boxRegex, boxReplacement);

View File

@@ -41,7 +41,7 @@ public:
void
Parse(std::string& line) override
{
static std::regex re("(?!.*`.*|.*<code>.*)_(?!.*`.*|.*<\\/code>.*)([^_]*)_(?!.*`.*|.*<\\/code>.*)");
static std::regex re(R"((?!.*`.*|.*<code>.*)_(?!.*`.*|.*<\/code>.*)([^_]*)_(?!.*`.*|.*<\/code>.*))");
static std::string replacement = "<em>$1</em>";
line = std::regex_replace(line, re, replacement);

View File

@@ -41,7 +41,7 @@ public:
void
Parse(std::string& line) override
{
static std::regex re("\\!\\[([^\\]]*)\\]\\(([^\\]]*)\\)");
static std::regex re(R"(\!\[([^\]]*)\]\(([^\]]*)\))");
static std::string replacement = "<img src=\"$2\" alt=\"$1\"/>";
line = std::regex_replace(line, re, replacement);

View File

@@ -39,7 +39,7 @@ public:
void
Parse(std::string& line) override
{
static std::regex re("(?!.*`.*|.*<code>.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)");
static std::regex re(R"((?!.*`.*|.*<code>.*)\*(?!.*`.*|.*<\/code>.*)([^\*]*)\*(?!.*`.*|.*<\/code>.*))");
static std::string replacement = "<i>$1</i>";
line = std::regex_replace(line, re, replacement);
}

View File

@@ -78,7 +78,7 @@ public:
static bool
IsStartingLine(const std::string& line)
{
static std::regex re("^(?:\\$){2}(.*)$");
static std::regex re(R"(^(?:\$){2}(.*)$)");
return std::regex_match(line, re);
}

View File

@@ -41,7 +41,7 @@ public:
void
Parse(std::string& line) override
{
static std::regex re("\\[([^\\]]*)\\]\\(([^\\]]*)\\)");
static std::regex re(R"(\[([^\]]*)\]\(([^\]]*)\))");
static std::string replacement = "<a href=\"$2\">$1</a>";
line = std::regex_replace(line, re, replacement);

View File

@@ -89,9 +89,9 @@ protected:
bool isStartOfNewListItem = this->isStartOfNewListItem(line);
uint32_t indentation = getIndentationWidth(line);
static std::regex orderedlineRegex("^[1-9]+[0-9]*\\. ");
static std::regex orderedlineRegex(R"(^[1-9]+[0-9]*\. )");
line = std::regex_replace(line, orderedlineRegex, "");
static std::regex unorderedlineRegex("^\\* ");
static std::regex unorderedlineRegex(R"(^\* )");
line = std::regex_replace(line, unorderedlineRegex, "");
if (!this->isStarted)
@@ -132,7 +132,7 @@ private:
bool
isStartOfNewListItem(const std::string& line) const
{
static std::regex re("^(?:[1-9]+[0-9]*\\. |\\* ).*");
static std::regex re(R"(^(?:[1-9]+[0-9]*\. |\* ).*)");
return std::regex_match(line, re);
}
}; // class OrderedListParser

View File

@@ -51,6 +51,14 @@ namespace maddy {
class Parser
{
public:
/**
* Version info
*
* Check https://github.com/progsource/maddy/blob/master/CHANGELOG.md
* for the changelog.
*/
static const std::string VERSION() { static const std::string v = "1.2.0"; return v; }
/**
* ctor
*

View File

@@ -54,7 +54,7 @@ public:
static bool
IsStartingLine(const std::string& line)
{
static std::regex re("^\\>.*");
static std::regex re(R"(^\>.*)");
return std::regex_match(line, re);
}
@@ -144,9 +144,9 @@ protected:
void
parseBlock(std::string& line) override
{
static std::regex lineRegexWithSpace("^\\> ");
static std::regex lineRegexWithSpace(R"(^\> )");
line = std::regex_replace(line, lineRegexWithSpace, "");
static std::regex lineRegexWithoutSpace("^\\>");
static std::regex lineRegexWithoutSpace(R"(^\>)");
line = std::regex_replace(line, lineRegexWithoutSpace, "");
if (!line.empty())

View File

@@ -39,7 +39,7 @@ public:
void
Parse(std::string& line) override
{
static std::regex re("(?!.*`.*|.*<code>.*)\\~\\~(?!.*`.*|.*<\\/code>.*)([^\\~]*)\\~\\~(?!.*`.*|.*<\\/code>.*)");
static std::regex re(R"((?!.*`.*|.*<code>.*)\~\~(?!.*`.*|.*<\/code>.*)([^\~]*)\~\~(?!.*`.*|.*<\/code>.*))");
static std::string replacement = "<s>$1</s>";
line = std::regex_replace(line, re, replacement);

View File

@@ -43,8 +43,8 @@ public:
{
static std::vector<std::regex> res
{
std::regex{"(?!.*`.*|.*<code>.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"},
std::regex{"(?!.*`.*|.*<code>.*)__(?!.*`.*|.*<\\/code>.*)([^__]*)__(?!.*`.*|.*<\\/code>.*)"}
std::regex{R"((?!.*`.*|.*<code>.*)\*\*(?!.*`.*|.*<\/code>.*)([^\*\*]*)\*\*(?!.*`.*|.*<\/code>.*))"},
std::regex{R"((?!.*`.*|.*<code>.*)__(?!.*`.*|.*<\/code>.*)([^__]*)__(?!.*`.*|.*<\/code>.*))"}
};
static std::string replacement = "<strong>$1</strong>";
for (const auto& re : res)

View File

@@ -1,6 +1,21 @@
# This project is licensed under the MIT license. For more information see the
# LICENSE file.
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER}
-fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message(STATUS "Found Gold linker, use faster linker")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold ")
endif()
endif()
# ------------------------------------------------------------------------------
include(FetchContent)
FetchContent_Declare(
@@ -25,4 +40,8 @@ target_include_directories(MaddyTests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(MaddyTests maddy gmock_main)
set_target_properties(MaddyTests PROPERTIES
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -Wall -Wpedantic -Wextra -Wno-ignored-qualifiers -fno-rtti -fno-exceptions -fsanitize=address -fno-omit-frame-pointer"
)
add_test(NAME MaddyTests COMMAND MaddyTests)