mirror of
https://github.com/progsource/maddy.git
synced 2026-03-24 23:40:39 +01:00
No paragraphs for html (#27)
* htmlparser added
* Added ParserConfig
* added option to disable the emphasized parser
* added option to not wrap HTML in markdown within a paragraph in output
* Updated docs
* Version update 1.1.1
This commit is contained in:
@@ -10,11 +10,14 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "maddy/parserconfig.h"
|
||||
|
||||
// BlockParser
|
||||
#include "maddy/checklistparser.h"
|
||||
#include "maddy/codeblockparser.h"
|
||||
#include "maddy/headlineparser.h"
|
||||
#include "maddy/horizontallineparser.h"
|
||||
#include "maddy/htmlparser.h"
|
||||
#include "maddy/orderedlistparser.h"
|
||||
#include "maddy/paragraphparser.h"
|
||||
#include "maddy/quoteparser.h"
|
||||
@@ -54,8 +57,9 @@ public:
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
Parser()
|
||||
: breakLineParser(std::make_shared<BreakLineParser>())
|
||||
Parser(std::shared_ptr<ParserConfig> config = nullptr)
|
||||
: config(config)
|
||||
, breakLineParser(std::make_shared<BreakLineParser>())
|
||||
, emphasizedParser(std::make_shared<EmphasizedParser>())
|
||||
, imageParser(std::make_shared<ImageParser>())
|
||||
, inlineCodeParser(std::make_shared<InlineCodeParser>())
|
||||
@@ -113,6 +117,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ParserConfig> config;
|
||||
std::shared_ptr<BreakLineParser> breakLineParser;
|
||||
std::shared_ptr<EmphasizedParser> emphasizedParser;
|
||||
std::shared_ptr<ImageParser> imageParser;
|
||||
@@ -132,7 +137,11 @@ private:
|
||||
|
||||
// Attention! StrongParser has to be before EmphasizedParser
|
||||
this->strongParser->Parse(line);
|
||||
this->emphasizedParser->Parse(line);
|
||||
|
||||
if (!this->config || this->config->isEmphasizedParserEnabled)
|
||||
{
|
||||
this->emphasizedParser->Parse(line);
|
||||
}
|
||||
|
||||
this->strikeThroughParser->Parse(line);
|
||||
|
||||
@@ -195,6 +204,14 @@ private:
|
||||
{
|
||||
parser = this->createUnorderedListParser();
|
||||
}
|
||||
else if (
|
||||
this->config &&
|
||||
!this->config->isHTMLWrappedInParagraph &&
|
||||
maddy::HtmlParser::IsStartingLine(line)
|
||||
)
|
||||
{
|
||||
parser = std::make_shared<maddy::HtmlParser>(nullptr, nullptr);
|
||||
}
|
||||
else if (maddy::ParagraphParser::IsStartingLine(line))
|
||||
{
|
||||
parser = std::make_shared<maddy::ParagraphParser>(
|
||||
|
||||
Reference in New Issue
Block a user