1
0
espelhamento de https://github.com/quitesimpleorg/qsmaddy.git sincronizado 2025-07-02 23:53:49 +02:00

18 Commits
1.0.1 ... 1.0.3

Autor SHA1 Mensagem Data
04342d813c Merge pull request #6 from progsource/make-sure-that-all-block-parsers-are-finished
Make sure that all block parsers are finished
2018-01-18 19:23:29 +01:00
cbd8731795 Merge branch 'master' into make-sure-that-all-block-parsers-are-finished 2018-01-18 19:16:37 +01:00
e20ac6c514 update version 2018-01-18 19:09:39 +01:00
9a9774f904 make sure that all parsers are finished 2018-01-18 19:09:10 +01:00
ba9077a9fa Merge pull request #5 from progsource/fix-docs-definitions
fix ol docs
2018-01-07 06:33:56 +01:00
b467e556e3 fix ol docs 2018-01-07 06:28:20 +01:00
7963d90603 Merge pull request #4 from progsource/fix-howto-run-tests
fixed howto run tests
2017-12-30 14:16:28 +01:00
663acbb0ea fixed howto run tests
has to be called before
2017-12-30 14:09:42 +01:00
d300d3a92a Merge pull request #3 from progsource/add-run-test-help
added howto for running the tests
2017-12-30 03:42:03 +01:00
fa3fdcb87b added howto for running the tests 2017-12-30 03:37:18 +01:00
e8f9551b66 Merge pull request #2 from progsource/travis-badge
added travis badge
2017-12-26 15:14:09 +01:00
18fdc4c78b added travis badge 2017-12-26 15:09:37 +01:00
5618c3ff23 Merge pull request #1 from progsource/travis-integration
Travis integration
2017-12-26 11:57:19 +01:00
eb1aafc35f travis: added export CXX 2017-12-26 11:47:32 +01:00
91e62beaec added travis.yml 2017-12-26 11:42:57 +01:00
0f7f7c1b9d updated version 2017-12-26 05:25:02 +01:00
2ee6840008 fixed the inline code now also for not directly following letters
* em
* s
* strong

updated regex
2017-12-26 05:24:01 +01:00
6619f03879 updated version also in image in readme 2017-12-25 21:28:06 +01:00
12 arquivos alterados com 83 adições e 21 exclusões

18
.travis.yml Arquivo normal
Ver arquivo

@ -0,0 +1,18 @@
dist: trusty
sudo: false
language: cpp
compiler: g++
install: export CXX="g++-6"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
script:
- mkdir tmp
- cd tmp
- cmake ..
- make
- ../build/MaddyTests

Ver arquivo

@ -27,7 +27,7 @@ file(GLOB_RECURSE MADDY_TESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/maddy/*.cp
set( set(
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -std=c++${MADDY_CPP_VERSION} -Wall -Wpedantic -Wextra -Wno-ignored-qualifiers -fno-rtti -fno-exceptions" "${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"
) )
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

Ver arquivo

@ -1,7 +1,8 @@
# maddy # maddy
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Version: 1.0.1](https://img.shields.io/badge/Version-1.0.0-brightgreen.svg)](https://semver.org/) [![Version: 1.0.3](https://img.shields.io/badge/Version-1.0.3-brightgreen.svg)](https://semver.org/)
[![Build Status](https://travis-ci.org/progsource/maddy.svg?branch=master)](https://travis-ci.org/progsource/maddy)
maddy is a C++ Markdown to HTML **header-only** parser library. maddy is a C++ Markdown to HTML **header-only** parser library.
@ -26,7 +27,7 @@ fitting my needs. So I simply wrote my own one.
The supported syntax can be found in the [definitions docs](docs/definitions.md). The supported syntax can be found in the [definitions docs](docs/definitions.md).
## HowTo use ## How to use
To use maddy in your project, simply add the include path of maddy to yours To use maddy in your project, simply add the include path of maddy to yours
and in the code, you can then do the following: and in the code, you can then do the following:
@ -42,6 +43,25 @@ std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>();
std::string htmlOutput = parser->Parse(markdownInput); std::string htmlOutput = parser->Parse(markdownInput);
``` ```
## How to run the tests
*(tested on Linux with
[git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and
[cmake](https://cmake.org/install/) installed)*
Open your preferred terminal and type:
```shell
git clone https://github.com/progsource/maddy.git
cd maddy
git submodule update --init --recursive
mkdir tmp
cd tmp
cmake ..
make
make test # or run the executable in ../build/MaddyTests
```
## How to contribute ## How to contribute
There are different possibilities: There are different possibilities:

Ver arquivo

@ -58,7 +58,7 @@ results in
``` ```
* unorederd * unordered
* list * list
* items * items
* in * in
@ -68,6 +68,8 @@ results in
``` ```
results in results in
```html ```html
<ul>
<li>unordered
<ul> <ul>
<li>list</li> <li>list</li>
<li>items <li>items
@ -78,6 +80,8 @@ results in
</li> </li>
<li>hierarchy</li> <li>hierarchy</li>
</ul> </ul>
</li>
</ul>
``` ```
### ordered ### ordered
@ -89,13 +93,17 @@ results in
* items * items
``` ```
results in results in
```html ```html
<ol> <ol>
<li>ordered</li> <li>ordered</li>
<li>list</li> <li>list</li>
<li>items</li> <li>items</li>
</ol> </ol>
``` ```
``` ```
@ -108,7 +116,9 @@ results in
* hierarchy * hierarchy
``` ```
results in results in
```html ```html
<ol> <ol>
<li>ordered</li> <li>ordered</li>
@ -116,7 +126,9 @@ results in
<ol> <ol>
<li>items</li> <li>items</li>
<li>in <li>in
<ol>an</ol> <ol>
<li>an</li>
</ol>
</li> </li>
<li>hierarchy</li> <li>hierarchy</li>
</ol> </ol>

Ver arquivo

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

Ver arquivo

@ -93,6 +93,18 @@ public:
} }
} }
// make sure, that all parsers are finished
if (currentBlockParser)
{
std::string emptyLine = "";
currentBlockParser->AddLine(emptyLine);
if (currentBlockParser->IsFinished())
{
result += currentBlockParser->GetResult().str();
currentBlockParser = nullptr;
}
}
return result; return result;
} }

Ver arquivo

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

Ver arquivo

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

Ver arquivo

@ -23,8 +23,8 @@ TEST(MADDY_EMPHASIZEDPARSER, ItReplacesMarkdownWithEmphasizedHTML)
TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode) TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode)
{ {
std::string text = "some text `*bla*` text testing *it* out"; std::string text = "some text `*bla*` `/**text*/` testing *it* out";
std::string expected = "some text `*bla*` text testing <em>it</em> out"; std::string expected = "some text `*bla*` `/**text*/` testing <em>it</em> out";
auto emphasizedParser = std::make_shared<maddy::EmphasizedParser>(); auto emphasizedParser = std::make_shared<maddy::EmphasizedParser>();
emphasizedParser->Parse(text); emphasizedParser->Parse(text);

Ver arquivo

@ -23,8 +23,8 @@ TEST(MADDY_STRIKETHROUGHPARSER, ItReplacesMarkdownWithStrikeThroughHTML)
TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode) TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode)
{ {
std::string text = "some text `~~bla~~` text testing <code>~~it~~</code> out"; std::string text = "some text `~~bla~~` ` ~~text~~ ` testing <code>~~it~~</code> out";
std::string expected = "some text `~~bla~~` text testing <code>~~it~~</code> out"; std::string expected = "some text `~~bla~~` ` ~~text~~ ` testing <code>~~it~~</code> out";
auto strikeThroughParser = std::make_shared<maddy::StrikeThroughParser>(); auto strikeThroughParser = std::make_shared<maddy::StrikeThroughParser>();
strikeThroughParser->Parse(text); strikeThroughParser->Parse(text);

Ver arquivo

@ -34,8 +34,8 @@ TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML)
TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode) TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode)
{ {
std::string text = "some text *bla* text testing `**it**` out"; std::string text = "some text **bla** `/**text**/` testing `**it**` out";
std::string expected = "some text *bla* text testing `**it**` out"; std::string expected = "some text **bla** `/**text**/` testing `**it**` out";
auto strongParser = std::make_shared<maddy::StrongParser>(); auto strongParser = std::make_shared<maddy::StrongParser>();
strongParser->Parse(text); strongParser->Parse(text);

Ver arquivo

@ -8,7 +8,7 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int main (int argc, char** argv) { int main (int argc, char** argv) {
::testing::GTEST_FLAG(throw_on_failure) = false; ::testing::GTEST_FLAG(throw_on_failure) = true;
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }