Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrettyMarkdown

使用 C++17 std::variant<> 和拓展的聚合类实现的 Markdown 序列化工具,只包含一个头文件。

基本概念:

  • EmptyLine 空行
  • Title<L> L 级标题
  • Reference<L> L 级引用
  • BulletItem<L> L 级无序列表项
  • OrderedItem<L> L 级有序列表项
  • CodeBlock 代码块
  • HorizontalRule 水平分割线
  • Link 链接,可以放在段(Paragraph)中,也可以直接放在 Markdown 文档中
  • Image 图片,可以放在段(Paragraph)中,也可以直接放在 Markdown 文档中
  • Table 表格
  • Paragraph
    • Plain 纯文本
    • Break 换行
    • Bold 加粗
    • Italic 斜体
    • Code 代码

序列化概念:

  • Validator 检验器,判断 Markdown 成员是否有效
  • Serializer<V> 序列化器

Markdown 文档:

  • Markdown 文档

使用示例

#include "PrettyMarkdown.h"

Paragraph paragraph;
paragraph << Plain{ "Hello" }
          << Break{}
          << Plain{ "World" };

Markdown doc;
doc << Title<1>{ "Hello World" }
    << Paragraph{ "This is a paragraph." }
    << paragraph
    << BulletItem<1>{ "Item 1" }
    << BulletItem<1>{ "Item 2" }
    << OrderedItem<1>{ "First" }
    << OrderedItem<1>{ "Second" }
    << CodeBlock{ "int main() { return 0; }", "cpp" }
    << HorizontalRule{}
    << Link{ "https://example.com", "Example" }
    << Image{ "https://example.com/image.png", "Example Image" };

About

PrettyMarkdown 是一个仅头文件的 C++ Markdown 写出库,使用了 C++17 标准和 std::variant 异质多态特性。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages