Some markdown processing.

This commit is contained in:
James Grogan 2022-12-01 17:13:54 +00:00
parent 31b479e9f6
commit ec11529b9a
23 changed files with 677 additions and 135 deletions

View file

@ -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;
};