From 02d3ccaf22b7d8e6fa26c93e46840821b0ff2e94 Mon Sep 17 00:00:00 2001 From: Petra Baranski Date: Thu, 27 Jul 2023 18:10:19 +0200 Subject: [PATCH 1/5] docs: update version number --- .github/workflows/run-tests.yml | 2 ++ CHANGELOG.md | 3 ++- README.md | 9 ++++----- include/maddy/parser.h | 8 ++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 43d827d..a95f2e2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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: diff --git a/CHANGELOG.md b/CHANGELOG.md index bde4c15..53c160f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,11 +20,12 @@ maddy uses [semver versioning](https://semver.org/). * ![**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 * ? ## version 1.1.2 2020-10-04 diff --git a/README.md b/README.md index e519324..91adfd5 100644 --- a/README.md +++ b/README.md @@ -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. @@ -45,8 +45,8 @@ std::stringstream markdownInput(""); std::shared_ptr config = std::make_shared(); // 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 parser = std::make_shared(config); std::string htmlOutput = parser->Parse(markdownInput); @@ -77,7 +77,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). diff --git a/include/maddy/parser.h b/include/maddy/parser.h index 1ae8377..e1891bc 100644 --- a/include/maddy/parser.h +++ b/include/maddy/parser.h @@ -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 * From baa5c9ccd048c86273109cb9fc29b651b50fe2d1 Mon Sep 17 00:00:00 2001 From: Petra Baranski Date: Thu, 27 Jul 2023 18:12:13 +0200 Subject: [PATCH 2/5] ci: create release workflow --- .github/workflows/create-release-package.yml | 33 +++++++++++++++ CHANGELOG.md | 1 + CMakeLists.txt | 43 +++++++++----------- README.md | 32 ++++++++++++++- tests/CMakeLists.txt | 19 +++++++++ 5 files changed, 102 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/create-release-package.yml diff --git a/.github/workflows/create-release-package.yml b/.github/workflows/create-release-package.yml new file mode 100644 index 0000000..4120b30 --- /dev/null +++ b/.github/workflows/create-release-package.yml @@ -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)" diff --git a/CHANGELOG.md b/CHANGELOG.md index 53c160f..8334afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ maddy uses [semver versioning](https://semver.org/). * ![**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 diff --git a/CMakeLists.txt b/CMakeLists.txt index af99f39..1481d49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/README.md b/README.md index 91adfd5..d9ff99a 100644 --- a/README.md +++ b/README.md @@ -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 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 @@ -52,7 +79,8 @@ std::shared_ptr parser = std::make_shared(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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d8b9b2f..2fdaea7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) From aecb1b30e6410c8b7fac8c5a5c7ce5ea0fd633c1 Mon Sep 17 00:00:00 2001 From: Petra Baranski Date: Thu, 27 Jul 2023 18:21:34 +0200 Subject: [PATCH 3/5] chore: have prettier issue templates --- .github/ISSUE_TEMPLATE/cpp-bug-report.yml | 62 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 15 +++++ .../ISSUE_TEMPLATE/markdown-bug-report.yml | 62 +++++++++++++++++++ ISSUE_TEMPLATE.md | 17 ----- 4 files changed, 139 insertions(+), 17 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/cpp-bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 .github/ISSUE_TEMPLATE/markdown-bug-report.yml delete mode 100644 ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/cpp-bug-report.yml b/.github/ISSUE_TEMPLATE/cpp-bug-report.yml new file mode 100644 index 0000000..45d9f11 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/cpp-bug-report.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..85ec92c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/markdown-bug-report.yml b/.github/ISSUE_TEMPLATE/markdown-bug-report.yml new file mode 100644 index 0000000..576a167 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/markdown-bug-report.yml @@ -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 diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index 07a1c50..0000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ -## Minimal Code Example - -``` -``` - -## Conditions - -. | . ---------------------- | ------------------ -**Operating System:** | ? -**Compiler:** | ? -**Compiler flags:** | ? -**maddy version:** | ? - -## Description - -What did you try? What is not working? From 123b921f2afef69bda85889ff0cda36d84ff9281 Mon Sep 17 00:00:00 2001 From: Petra Baranski Date: Thu, 27 Jul 2023 18:46:25 +0200 Subject: [PATCH 4/5] style: make regex strings more readable --- include/maddy/checklistparser.h | 6 +++--- include/maddy/emphasizedparser.h | 2 +- include/maddy/imageparser.h | 2 +- include/maddy/italicparser.h | 2 +- include/maddy/latexblockparser.h | 2 +- include/maddy/linkparser.h | 2 +- include/maddy/orderedlistparser.h | 6 +++--- include/maddy/quoteparser.h | 6 +++--- include/maddy/strikethroughparser.h | 2 +- include/maddy/strongparser.h | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/maddy/checklistparser.h b/include/maddy/checklistparser.h index bfc487c..dab5ffc 100644 --- a/include/maddy/checklistparser.h +++ b/include/maddy/checklistparser.h @@ -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 = ""; line = std::regex_replace(line, emptyBoxRegex, emptyBoxReplacement); - static std::regex boxRegex("^\\[x\\]"); + static std::regex boxRegex(R"(^\[x\])"); static std::string boxReplacement = ""; line = std::regex_replace(line, boxRegex, boxReplacement); diff --git a/include/maddy/emphasizedparser.h b/include/maddy/emphasizedparser.h index 6838d83..c1b21ed 100644 --- a/include/maddy/emphasizedparser.h +++ b/include/maddy/emphasizedparser.h @@ -41,7 +41,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!.*`.*|.*.*)_(?!.*`.*|.*<\\/code>.*)([^_]*)_(?!.*`.*|.*<\\/code>.*)"); + static std::regex re(R"((?!.*`.*|.*.*)_(?!.*`.*|.*<\/code>.*)([^_]*)_(?!.*`.*|.*<\/code>.*))"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/imageparser.h b/include/maddy/imageparser.h index 3ac77ae..65bca7c 100644 --- a/include/maddy/imageparser.h +++ b/include/maddy/imageparser.h @@ -41,7 +41,7 @@ public: void Parse(std::string& line) override { - static std::regex re("\\!\\[([^\\]]*)\\]\\(([^\\]]*)\\)"); + static std::regex re(R"(\!\[([^\]]*)\]\(([^\]]*)\))"); static std::string replacement = "\"$1\"/"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/italicparser.h b/include/maddy/italicparser.h index ed59744..ac3df0f 100644 --- a/include/maddy/italicparser.h +++ b/include/maddy/italicparser.h @@ -39,7 +39,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!.*`.*|.*.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)"); + static std::regex re(R"((?!.*`.*|.*.*)\*(?!.*`.*|.*<\/code>.*)([^\*]*)\*(?!.*`.*|.*<\/code>.*))"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); } diff --git a/include/maddy/latexblockparser.h b/include/maddy/latexblockparser.h index 02d66cb..f668523 100644 --- a/include/maddy/latexblockparser.h +++ b/include/maddy/latexblockparser.h @@ -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); } diff --git a/include/maddy/linkparser.h b/include/maddy/linkparser.h index e382f21..e634d43 100644 --- a/include/maddy/linkparser.h +++ b/include/maddy/linkparser.h @@ -41,7 +41,7 @@ public: void Parse(std::string& line) override { - static std::regex re("\\[([^\\]]*)\\]\\(([^\\]]*)\\)"); + static std::regex re(R"(\[([^\]]*)\]\(([^\]]*)\))"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/orderedlistparser.h b/include/maddy/orderedlistparser.h index e41d3b1..27a2aca 100644 --- a/include/maddy/orderedlistparser.h +++ b/include/maddy/orderedlistparser.h @@ -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 diff --git a/include/maddy/quoteparser.h b/include/maddy/quoteparser.h index a3b48d0..c0415dd 100644 --- a/include/maddy/quoteparser.h +++ b/include/maddy/quoteparser.h @@ -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()) diff --git a/include/maddy/strikethroughparser.h b/include/maddy/strikethroughparser.h index 2640459..0c5a8ca 100644 --- a/include/maddy/strikethroughparser.h +++ b/include/maddy/strikethroughparser.h @@ -39,7 +39,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!.*`.*|.*.*)\\~\\~(?!.*`.*|.*<\\/code>.*)([^\\~]*)\\~\\~(?!.*`.*|.*<\\/code>.*)"); + static std::regex re(R"((?!.*`.*|.*.*)\~\~(?!.*`.*|.*<\/code>.*)([^\~]*)\~\~(?!.*`.*|.*<\/code>.*))"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/strongparser.h b/include/maddy/strongparser.h index 589dacc..6e5c41c 100644 --- a/include/maddy/strongparser.h +++ b/include/maddy/strongparser.h @@ -43,8 +43,8 @@ public: { static std::vector res { - std::regex{"(?!.*`.*|.*.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"}, - std::regex{"(?!.*`.*|.*.*)__(?!.*`.*|.*<\\/code>.*)([^__]*)__(?!.*`.*|.*<\\/code>.*)"} + std::regex{R"((?!.*`.*|.*.*)\*\*(?!.*`.*|.*<\/code>.*)([^\*\*]*)\*\*(?!.*`.*|.*<\/code>.*))"}, + std::regex{R"((?!.*`.*|.*.*)__(?!.*`.*|.*<\/code>.*)([^__]*)__(?!.*`.*|.*<\/code>.*))"} }; static std::string replacement = "$1"; for (const auto& re : res) From 155fb2c7e68d37668a2627c52fb80c224f20dbe8 Mon Sep 17 00:00:00 2001 From: Petra Baranski Date: Thu, 27 Jul 2023 18:54:21 +0200 Subject: [PATCH 5/5] docs: update changelog for 1.2.0 --- CHANGELOG.md | 5 ++++- README.md | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8334afa..2834039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ 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 @@ -27,7 +31,6 @@ maddy uses [semver versioning](https://semver.org/). * ![**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 diff --git a/README.md b/README.md index d9ff99a..0533fc8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ It is tested to work on: ## Why maddy? -When I looking for 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