mirror of
https://github.com/quitesimpleorg/qsmaddy.git
synced 2025-07-01 15:13:49 +02:00
Compare commits
14 Commits
1.1.1
...
fix/add_st
Author | SHA1 | Date | |
---|---|---|---|
a28769be2b | |||
adb1a910d4 | |||
f38b3cf4fa | |||
6b632abd44 | |||
38f802de09 | |||
348aa81607 | |||
ba5cb5d6c5 | |||
fd698d1f5f | |||
5b2f20041c | |||
cde0137e90 | |||
71ee49d1ea | |||
19338d2b56 | |||
cb75226b4a | |||
51d61b68fe |
@ -28,5 +28,5 @@ script:
|
|||||||
- mkdir tmp
|
- mkdir tmp
|
||||||
- cd tmp
|
- cd tmp
|
||||||
- cmake ..
|
- cmake ..
|
||||||
- make
|
- make -j4
|
||||||
- ../build/MaddyTests
|
- ../build/MaddyTests
|
||||||
|
4
AUTHORS
4
AUTHORS
@ -6,3 +6,7 @@ a license to everyone to use it as detailed in LICENSE.)
|
|||||||
|
|
||||||
M. Petra Baranski (info@progsource.de)
|
M. Petra Baranski (info@progsource.de)
|
||||||
Patrick José Pereira (patrickelectric@gmail.com)
|
Patrick José Pereira (patrickelectric@gmail.com)
|
||||||
|
Martin Kopecky (martin.kopecky357@gmail.com)
|
||||||
|
Andrew Mettlach (dmmettlach@gmail.com)
|
||||||
|
Evan Klitzke (evan@eklitzke.org)
|
||||||
|
Albert Schwarzkopf (dev-maddy@quitesimple.org)
|
||||||
|
67
CHANGELOG.md
Normal file
67
CHANGELOG.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
This file tries to follow roughly [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
maddy uses [semver versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## Badges
|
||||||
|
|
||||||
|
*  for any bug fixes.
|
||||||
|
*  in case of vulnerabilities.
|
||||||
|
*  for new features.
|
||||||
|
*  for changes in existing functionality.
|
||||||
|
*  for soon-to-be removed features.
|
||||||
|
*  for now removed features.
|
||||||
|
|
||||||
|
## Upcoming
|
||||||
|
|
||||||
|
*  Added Changelog
|
||||||
|
*  Added contribution guideline
|
||||||
|
* ?
|
||||||
|
|
||||||
|
## version 1.1.2 2020-10-04
|
||||||
|
|
||||||
|
*  `*`, `+` and `-` are equivalent for making unordered bullet list
|
||||||
|
*  Parsing support for fully numeric ordered lists
|
||||||
|
*  make `Parser::Parse` accept istreams instead of stringstream
|
||||||
|
*  CMake is creating an interface library which you can include in your own `target_link_libraries` and the global include path is untouched from maddy.
|
||||||
|
|
||||||
|
## version 1.1.1 2019-12-27
|
||||||
|
|
||||||
|
*  BreakLineParser
|
||||||
|
*  HTMLParser
|
||||||
|
*  Added optional config with the following options:
|
||||||
|
* en-/disable the emphasized parser
|
||||||
|
* wrap/not wrap HTML in markdown within a paragraph in output
|
||||||
|
*  Updated gtest to release-1.10.0 to fix build issues
|
||||||
|
|
||||||
|
|
||||||
|
## version 1.1.0 2019-02-19
|
||||||
|
|
||||||
|
*  Added missing includes to BlockParser
|
||||||
|
*  Added missing dtor to BlockParser and LineParser
|
||||||
|
*  `__test__` can also be used to get `<strong>text</strong>`
|
||||||
|
*  Added AppVeyor CI
|
||||||
|
*  Added clang for CI
|
||||||
|
*  Single underscore `_` results in emphasized tag `<em>`, single `*` in italic tag `<i>`
|
||||||
|
|
||||||
|
## version 1.0.3 2018-01-18
|
||||||
|
|
||||||
|
*  Make sure that all parsers are finished
|
||||||
|
*  ol documentation
|
||||||
|
*  Added Travic-CI with gcc
|
||||||
|
*  Added Howto for running the tests on the README
|
||||||
|
|
||||||
|
## version 1.0.2 2017-12-26
|
||||||
|
|
||||||
|
*  Fixed inline code for directly following letters (bold, emphasized and strikethrough)
|
||||||
|
|
||||||
|
## version 1.0.1 2017-12-25
|
||||||
|
|
||||||
|
*  Fixed inline code for bold, emphasized and strikethrough
|
||||||
|
*  Fixed spelling in README
|
||||||
|
*  Use Gold Linker on Unix if available for faster compile time
|
||||||
|
*  Added Github ISSUE_TEMPLATE
|
||||||
|
|
||||||
|
## version 1.0.0 2017-12-25
|
||||||
|
|
||||||
|
initial release
|
@ -60,10 +60,9 @@ add_subdirectory(libs)
|
|||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
include_directories(
|
add_library(maddy INTERFACE)
|
||||||
${LIBS_INCLUDE_DIRS}
|
target_include_directories(maddy INTERFACE
|
||||||
${MADDY_INCLUDE_DIR}
|
${MADDY_INCLUDE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tests
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -73,5 +72,9 @@ add_executable(
|
|||||||
${MADDY_TESTS_FILES}
|
${MADDY_TESTS_FILES}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(MaddyTests gmock_main)
|
target_include_directories(MaddyTests PUBLIC
|
||||||
|
${LIBS_INCLUDE_DIRS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/tests
|
||||||
|
)
|
||||||
|
target_link_libraries(MaddyTests maddy gmock_main)
|
||||||
add_test(MaddyTests ${CMAKE_CURRENT_SOURCE_DIR}/build/MaddyTests)
|
add_test(MaddyTests ${CMAKE_CURRENT_SOURCE_DIR}/build/MaddyTests)
|
||||||
|
26
CONTRIBUTING.md
Normal file
26
CONTRIBUTING.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Contribution Guideline
|
||||||
|
|
||||||
|
First of all: I am thankful for any contribution this project gets.
|
||||||
|
|
||||||
|
## Creating Issues
|
||||||
|
|
||||||
|
You found a bug, you miss some feature in the project or have an idea how to
|
||||||
|
improve the code? Then [create a GitHub issue](https://github.com/progsource/maddy/issues/new).
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
* 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.
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright 2017, 2018, 2019 M. Petra Baranski
|
Copyright 2017, 2018, 2019, 2020 M. Petra Baranski
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# maddy
|
# maddy
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://semver.org/)
|
[](https://semver.org/)
|
||||||
[](https://travis-ci.org/progsource/maddy)
|
[](https://travis-ci.org/progsource/maddy)
|
||||||
[](https://ci.appveyor.com/project/progsource/maddy/branch/master)
|
[](https://ci.appveyor.com/project/progsource/maddy/branch/master)
|
||||||
|
|
||||||
@ -78,3 +78,5 @@ There are different possibilities:
|
|||||||
* [Create a GitHub issue](https://github.com/progsource/maddy/issues/new)
|
* [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
|
* Create a pull request with an own branch (don't forget to put yourself in the
|
||||||
AUTHORS file)
|
AUTHORS file)
|
||||||
|
|
||||||
|
Please also read [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||||
|
@ -44,11 +44,13 @@ results in
|
|||||||
## Lists
|
## Lists
|
||||||
|
|
||||||
### unordered
|
### unordered
|
||||||
|
Characters "*", "+" or "-" to make an unordered "bullet" list are equivalent.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* unordered
|
- unordered
|
||||||
* list
|
* list
|
||||||
* items
|
+ items
|
||||||
|
|
||||||
```
|
```
|
||||||
results in
|
results in
|
||||||
@ -66,8 +68,8 @@ results in
|
|||||||
* list
|
* list
|
||||||
* items
|
* items
|
||||||
* in
|
* in
|
||||||
* an
|
+ an
|
||||||
* hierarchy
|
- hierarchy
|
||||||
|
|
||||||
```
|
```
|
||||||
results in
|
results in
|
||||||
@ -92,6 +94,26 @@ results in
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. ordered
|
||||||
|
2. list
|
||||||
|
3. items
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
results in
|
||||||
|
|
||||||
|
```html
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li>ordered</li>
|
||||||
|
<li>list</li>
|
||||||
|
<li>items</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
1. ordered
|
1. ordered
|
||||||
* list
|
* list
|
||||||
* items
|
* items
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void
|
void
|
||||||
Parse(std::string& line) override
|
Parse(std::string& line) override
|
||||||
{
|
{
|
||||||
std::regex re("(?!.*`.*|.*<code>.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)");
|
static std::regex re("(?!.*`.*|.*<code>.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)");
|
||||||
static std::string replacement = "<i>$1</i>";
|
static std::string replacement = "<i>$1</i>";
|
||||||
line = std::regex_replace(line, re, replacement);
|
line = std::regex_replace(line, re, replacement);
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ protected:
|
|||||||
bool isStartOfNewListItem = this->isStartOfNewListItem(line);
|
bool isStartOfNewListItem = this->isStartOfNewListItem(line);
|
||||||
uint32_t indentation = getIndentationWidth(line);
|
uint32_t indentation = getIndentationWidth(line);
|
||||||
|
|
||||||
static std::regex orderedlineRegex("^1\\. ");
|
static std::regex orderedlineRegex("^[1-9]+[0-9]*\\. ");
|
||||||
line = std::regex_replace(line, orderedlineRegex, "");
|
line = std::regex_replace(line, orderedlineRegex, "");
|
||||||
static std::regex unorderedlineRegex("^(\\* )");
|
static std::regex unorderedlineRegex("^\\* ");
|
||||||
line = std::regex_replace(line, unorderedlineRegex, "");
|
line = std::regex_replace(line, unorderedlineRegex, "");
|
||||||
|
|
||||||
if (!this->isStarted)
|
if (!this->isStarted)
|
||||||
@ -132,7 +132,7 @@ private:
|
|||||||
bool
|
bool
|
||||||
isStartOfNewListItem(const std::string& line) const
|
isStartOfNewListItem(const std::string& line) const
|
||||||
{
|
{
|
||||||
static std::regex re("^(?:1\\. |\\* ).*");
|
static std::regex re("^(?:[1-9]+[0-9]*\\. |\\* ).*");
|
||||||
return std::regex_match(line, re);
|
return std::regex_match(line, re);
|
||||||
}
|
}
|
||||||
}; // class OrderedListParser
|
}; // class OrderedListParser
|
||||||
|
@ -73,11 +73,11 @@ public:
|
|||||||
* Parse
|
* Parse
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {const std::stringstream&} markdown
|
* @param {const std::istream&} markdown
|
||||||
* @return {std::string} HTML
|
* @return {std::string} HTML
|
||||||
*/
|
*/
|
||||||
std::string
|
std::string
|
||||||
Parse(std::stringstream& markdown) const
|
Parse(std::istream& markdown) const
|
||||||
{
|
{
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
std::shared_ptr<BlockParser> currentBlockParser = nullptr;
|
std::shared_ptr<BlockParser> currentBlockParser = nullptr;
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
static bool
|
static bool
|
||||||
IsStartingLine(const std::string& line)
|
IsStartingLine(const std::string& line)
|
||||||
{
|
{
|
||||||
static std::regex re("^\\* .*");
|
static std::regex re("^[+*-] .*");
|
||||||
return std::regex_match(line, re);
|
return std::regex_match(line, re);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ protected:
|
|||||||
bool isStartOfNewListItem = IsStartingLine(line);
|
bool isStartOfNewListItem = IsStartingLine(line);
|
||||||
uint32_t indentation = getIndentationWidth(line);
|
uint32_t indentation = getIndentationWidth(line);
|
||||||
|
|
||||||
static std::regex lineRegex("^(\\* )");
|
static std::regex lineRegex("^([+*-] )");
|
||||||
line = std::regex_replace(line, lineRegex, "");
|
line = std::regex_replace(line, lineRegex, "");
|
||||||
|
|
||||||
if (!this->isStarted)
|
if (!this->isStarted)
|
||||||
|
@ -96,3 +96,26 @@ TEST_F(MADDY_ORDEREDLISTPARSER, ItReplacesMarkdownWithAnHierachicalHtmlList)
|
|||||||
|
|
||||||
ASSERT_EQ(expected, outputString);
|
ASSERT_EQ(expected, outputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MADDY_ORDEREDLISTPARSER, ItReplacesNumberedMarkdownListWithAnHtmlOrderedList)
|
||||||
|
{
|
||||||
|
std::vector<std::string> markdown = {
|
||||||
|
"1. a"
|
||||||
|
, "94. b"
|
||||||
|
, "103. c"
|
||||||
|
, ""
|
||||||
|
};
|
||||||
|
std::string expected = "<ol><li>a</li><li>b</li><li>c</li></ol>";
|
||||||
|
|
||||||
|
for (std::string md : markdown)
|
||||||
|
{
|
||||||
|
olParser->AddLine(md);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_TRUE(olParser->IsFinished());
|
||||||
|
|
||||||
|
std::stringstream& output(olParser->GetResult());
|
||||||
|
const std::string& outputString = output.str();
|
||||||
|
|
||||||
|
ASSERT_EQ(expected, outputString);
|
||||||
|
}
|
||||||
|
@ -55,9 +55,14 @@ TEST_F(MADDY_UNORDEREDLISTPARSER, ItReplacesMarkdownWithAnHtmlUnorderedList)
|
|||||||
std::vector<std::string> markdown = {
|
std::vector<std::string> markdown = {
|
||||||
"* a"
|
"* a"
|
||||||
, "* b"
|
, "* b"
|
||||||
|
, "- c"
|
||||||
|
, "- d"
|
||||||
|
, "+ e"
|
||||||
|
, "+ f"
|
||||||
|
, "* g"
|
||||||
, ""
|
, ""
|
||||||
};
|
};
|
||||||
std::string expected = "<ul><li>a</li><li>b</li></ul>";
|
std::string expected = "<ul><li>a</li><li>b</li><li>c</li><li>d</li><li>e</li><li>f</li><li>g</li></ul>";
|
||||||
|
|
||||||
for (std::string md : markdown)
|
for (std::string md : markdown)
|
||||||
{
|
{
|
||||||
@ -80,9 +85,12 @@ TEST_F(MADDY_UNORDEREDLISTPARSER, ItReplacesMarkdownWithAnHierachicalHtmlList)
|
|||||||
, " * e"
|
, " * e"
|
||||||
, "* b"
|
, "* b"
|
||||||
, " * c"
|
, " * c"
|
||||||
|
, " + x"
|
||||||
|
, " + y"
|
||||||
|
, " - z"
|
||||||
, ""
|
, ""
|
||||||
};
|
};
|
||||||
std::string expected = "<ul><li>a<ul><li>d</li><li>e</li></ul></li><li>b<ul><li>c</li></ul></li></ul>";
|
std::string expected = "<ul><li>a<ul><li>d</li><li>e</li></ul></li><li>b<ul><li>c</li><li>x</li><li>y</li><li>z</li></ul></li></ul>";
|
||||||
|
|
||||||
for (std::string md : markdown)
|
for (std::string md : markdown)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user