镜像自地址
https://github.com/quitesimpleorg/qsmaddy.git
已同步 2025-07-01 15:13:49 +02:00
比较提交
22 次代码提交
作者 | SHA1 | 提交日期 | |
---|---|---|---|
04342d813c | |||
cbd8731795 | |||
e20ac6c514 | |||
9a9774f904 | |||
ba9077a9fa | |||
b467e556e3 | |||
7963d90603 | |||
663acbb0ea | |||
d300d3a92a | |||
fa3fdcb87b | |||
e8f9551b66 | |||
18fdc4c78b | |||
5618c3ff23 | |||
eb1aafc35f | |||
91e62beaec | |||
0f7f7c1b9d | |||
2ee6840008 | |||
6619f03879 | |||
7d43a6c593 | |||
91b687d5e7 | |||
82b320d967 | |||
4ef069b356 |
18
.travis.yml
普通文件
18
.travis.yml
普通文件
@ -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
|
@ -1,4 +1,4 @@
|
||||
# This project is licensed under the MITlicense. For more information see the
|
||||
# This project is licensed under the MIT license. For more information see the
|
||||
# LICENSE file.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
@ -27,11 +27,26 @@ file(GLOB_RECURSE MADDY_TESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/maddy/*.cp
|
||||
|
||||
set(
|
||||
CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -g -std=c++${MADDY_CPP_VERSION} -Wall -Wpedantic -Wextra -Wno-ignored-qualifiers -fno-rtti -fno-exceptions" # -O2
|
||||
"${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 (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()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/gtest/googlemock)
|
||||
add_subdirectory(libs)
|
||||
|
17
ISSUE_TEMPLATE.md
普通文件
17
ISSUE_TEMPLATE.md
普通文件
@ -0,0 +1,17 @@
|
||||
## Minimal Code Example
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
## Conditions
|
||||
|
||||
. | .
|
||||
--------------------- | ------------------
|
||||
**Operating System:** | ?
|
||||
**Compiler:** | ?
|
||||
**Compiler flags:** | ?
|
||||
**maddy version:** | ?
|
||||
|
||||
## Description
|
||||
|
||||
What did you try? What is not working?
|
26
README.md
26
README.md
@ -1,11 +1,12 @@
|
||||
# maddy
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://semver.org/)
|
||||
[](https://semver.org/)
|
||||
[](https://travis-ci.org/progsource/maddy)
|
||||
|
||||
maddy is a C++ Markdown to HTML **header-only** parser library.
|
||||
|
||||
## Supportes OS
|
||||
## Supported OS
|
||||
|
||||
It actually should work on any OS, that supports the C++14 standard 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).
|
||||
|
||||
## HowTo use
|
||||
## How to use
|
||||
|
||||
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:
|
||||
@ -42,6 +43,25 @@ std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>();
|
||||
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
|
||||
|
||||
There are different possibilities:
|
||||
|
@ -58,7 +58,7 @@ results in
|
||||
|
||||
```
|
||||
|
||||
* unorederd
|
||||
* unordered
|
||||
* list
|
||||
* items
|
||||
* in
|
||||
@ -69,14 +69,18 @@ results in
|
||||
results in
|
||||
```html
|
||||
<ul>
|
||||
<li>list</li>
|
||||
<li>items
|
||||
<li>unordered
|
||||
<ul>
|
||||
<li>in</li>
|
||||
<li>an</li>
|
||||
<li>list</li>
|
||||
<li>items
|
||||
<ul>
|
||||
<li>in</li>
|
||||
<li>an</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>hierarchy</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>hierarchy</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
@ -89,13 +93,17 @@ results in
|
||||
* items
|
||||
|
||||
```
|
||||
|
||||
results in
|
||||
|
||||
```html
|
||||
|
||||
<ol>
|
||||
<li>ordered</li>
|
||||
<li>list</li>
|
||||
<li>items</li>
|
||||
</ol>
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
@ -108,7 +116,9 @@ results in
|
||||
* hierarchy
|
||||
|
||||
```
|
||||
|
||||
results in
|
||||
|
||||
```html
|
||||
<ol>
|
||||
<li>ordered</li>
|
||||
@ -116,7 +126,9 @@ results in
|
||||
<ol>
|
||||
<li>items</li>
|
||||
<li>in
|
||||
<ol>an</ol>
|
||||
<ol>
|
||||
<li>an</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>hierarchy</li>
|
||||
</ol>
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
void
|
||||
Parse(std::string& line) override
|
||||
{
|
||||
static std::regex re("\\*([^\\*]*)\\*");
|
||||
static std::regex re("(?!.*`.*|.*<code>.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)");
|
||||
static std::string replacement = "<em>$1</em>";
|
||||
|
||||
line = std::regex_replace(line, re, replacement);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
void
|
||||
Parse(std::string& line) override
|
||||
{
|
||||
static std::regex re("\\~\\~([^\\~]*)\\~\\~");
|
||||
static std::regex re("(?!.*`.*|.*<code>.*)\\~\\~(?!.*`.*|.*<\\/code>.*)([^\\~]*)\\~\\~(?!.*`.*|.*<\\/code>.*)");
|
||||
static std::string replacement = "<s>$1</s>";
|
||||
|
||||
line = std::regex_replace(line, re, replacement);
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
void
|
||||
Parse(std::string& line) override
|
||||
{
|
||||
static std::regex re("\\*\\*([^\\*\\*]*)\\*\\*");
|
||||
static std::regex re("(?!.*`.*|.*<code>.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)");
|
||||
static std::string replacement = "<strong>$1</strong>";
|
||||
|
||||
line = std::regex_replace(line, re, replacement);
|
||||
|
@ -20,3 +20,14 @@ TEST(MADDY_EMPHASIZEDPARSER, ItReplacesMarkdownWithEmphasizedHTML)
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode)
|
||||
{
|
||||
std::string text = "some text `*bla*` `/**text*/` testing *it* out";
|
||||
std::string expected = "some text `*bla*` `/**text*/` testing <em>it</em> out";
|
||||
auto emphasizedParser = std::make_shared<maddy::EmphasizedParser>();
|
||||
|
||||
emphasizedParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
@ -20,3 +20,14 @@ TEST(MADDY_STRIKETHROUGHPARSER, ItReplacesMarkdownWithStrikeThroughHTML)
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode)
|
||||
{
|
||||
std::string text = "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>();
|
||||
|
||||
strikeThroughParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
@ -31,3 +31,14 @@ TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML)
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode)
|
||||
{
|
||||
std::string text = "some text **bla** `/**text**/` testing `**it**` out";
|
||||
std::string expected = "some text **bla** `/**text**/` testing `**it**` out";
|
||||
auto strongParser = std::make_shared<maddy::StrongParser>();
|
||||
|
||||
strongParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
::testing::GTEST_FLAG(throw_on_failure) = false;
|
||||
::testing::GTEST_FLAG(throw_on_failure) = true;
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
在新工单中引用
屏蔽一个用户