mirror of
https://github.com/progsource/maddy.git
synced 2026-03-25 16:00:39 +01:00
feat: enable optional inline parsing in headlines
This commit is contained in:
@@ -57,9 +57,11 @@ public:
|
||||
*/
|
||||
HeadlineParser(
|
||||
std::function<void(std::string&)> parseLineCallback,
|
||||
std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback
|
||||
std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback,
|
||||
bool isInlineParserAllowed = true
|
||||
)
|
||||
: BlockParser(parseLineCallback, getBlockParserForLineCallback)
|
||||
, isInlineParserAllowed(isInlineParserAllowed)
|
||||
{}
|
||||
|
||||
/**
|
||||
@@ -103,7 +105,7 @@ protected:
|
||||
bool
|
||||
isLineParserAllowed() const override
|
||||
{
|
||||
return false;
|
||||
return this->isInlineParserAllowed;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -131,6 +133,9 @@ protected:
|
||||
line = std::regex_replace(line, hlRegex[i], hlReplacement[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool isInlineParserAllowed;
|
||||
}; // class HeadlineParser
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -287,10 +287,22 @@ private:
|
||||
maddy::HeadlineParser::IsStartingLine(line)
|
||||
)
|
||||
{
|
||||
parser = std::make_shared<maddy::HeadlineParser>(
|
||||
nullptr,
|
||||
nullptr
|
||||
);
|
||||
if (!this->config || this->config->isHeadlineInlineParsingEnabled)
|
||||
{
|
||||
parser = std::make_shared<maddy::HeadlineParser>(
|
||||
[this](std::string& line){ this->runLineParser(line); },
|
||||
nullptr,
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
parser = std::make_shared<maddy::HeadlineParser>(
|
||||
nullptr,
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(
|
||||
|
||||
@@ -70,11 +70,22 @@ struct ParserConfig
|
||||
*/
|
||||
bool isHTMLWrappedInParagraph;
|
||||
|
||||
/**
|
||||
* en-/disable headline inline-parsing
|
||||
*
|
||||
* default: enabled
|
||||
*/
|
||||
bool isHeadlineInlineParsingEnabled;
|
||||
|
||||
/**
|
||||
* enabled parsers bitfield
|
||||
*/
|
||||
uint32_t enabledParsers;
|
||||
|
||||
ParserConfig()
|
||||
: isEmphasizedParserEnabled(true)
|
||||
, isHTMLWrappedInParagraph(true)
|
||||
, isHeadlineInlineParsingEnabled(true)
|
||||
, enabledParsers(maddy::types::DEFAULT)
|
||||
{}
|
||||
}; // class ParserConfig
|
||||
|
||||
Reference in New Issue
Block a user