Some markdown processing.
This commit is contained in:
parent
31b479e9f6
commit
ec11529b9a
23 changed files with 677 additions and 135 deletions
|
@ -1,29 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "HtmlDocument.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class MarkdownDocument;
|
||||
class MarkdownParagraph;
|
||||
|
||||
class MarkdownParser
|
||||
{
|
||||
enum class DocumentState
|
||||
{
|
||||
None
|
||||
NONE,
|
||||
IN_MULTILINEQUOTE
|
||||
};
|
||||
|
||||
enum class LineState
|
||||
{
|
||||
None
|
||||
NONE,
|
||||
IN_HEADING,
|
||||
IN_INLINEQUOTE,
|
||||
IN_MULTILINE_TAG
|
||||
};
|
||||
|
||||
public:
|
||||
MarkdownParser();
|
||||
|
||||
HtmlDocumentPtr getHtml();
|
||||
~MarkdownParser();
|
||||
|
||||
void processLine(const std::string& line);
|
||||
|
||||
void run(const std::string& content);
|
||||
std::unique_ptr<MarkdownDocument> run(const std::string& content);
|
||||
|
||||
private:
|
||||
DocumentState mDocumentState {DocumentState::None};
|
||||
HtmlDocumentPtr mHtmlDocument;
|
||||
void processLine();
|
||||
|
||||
void onMultilineQuote();
|
||||
void onInlineQuote();
|
||||
void onHeading(unsigned level);
|
||||
|
||||
void onEmptyLine();
|
||||
void onNewParagraph();
|
||||
|
||||
void onTextSpan();
|
||||
|
||||
std::pair<unsigned, bool> onTick(unsigned tickCount);
|
||||
|
||||
std::string mWorkingLine;
|
||||
std::string mLineContent;
|
||||
std::string mDocumentContent;
|
||||
std::string mMultilineTag;
|
||||
|
||||
LineState mLineState {LineState::NONE};
|
||||
DocumentState mDocumentState {DocumentState::NONE};
|
||||
|
||||
std::unique_ptr<MarkdownParagraph> mWorkingParagraph{nullptr};
|
||||
std::unique_ptr<MarkdownDocument> mMarkdownDocument;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue