Skip to content

Commit

Permalink
Use included monospace-font for code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Nov 13, 2023
1 parent 93ccd17 commit 2c56551
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions maddy/codeblockparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,24 @@ class CodeBlockParser : public BlockParser
parseBlock(std::string& line) override
{
QString style = QString("\"background: %1; margin-left:12px; color:%2;\"").
arg(Utility::getAppHexColor("lightBackground")).
arg(Utility::getAppHexColor("lightText"));

if (line == "```")
{
if (!this->isStarted)
{
line = "<pre style=" + style.toStdString() + "><code>\n";
arg(Utility::getAppHexColor("lightBackground"), Utility::getAppHexColor("lightText"));

if (line == "```") {
if (!this->isStarted) {
line = "<pre style=" + style.toStdString() +
"><span style=\"font-family:'DejaVu Sans Mono';\"<code>\n";
this->isStarted = true;
this->isFinished = false;
return;
}
else
{
line = "</code></pre>";
} else {
line = "</span></code></pre>";
this->isFinished = true;
this->isStarted = false;
return;
}
}
else if (!this->isStarted && line.substr(0, 3) == "```")
{
line = "<pre style=" + style.toStdString() + " class=\"" + line.substr(3) + "\"><code>\n";
} else if (!this->isStarted && line.substr(0, 3) == "```") {
line = "<pre style=" + style.toStdString() + " class=\"" +
line.substr(3) + "\"><span style=\"font-family:'DejaVu Sans Mono';\"<code>\n";
this->isStarted = true;
this->isFinished = false;
return;
Expand Down

0 comments on commit 2c56551

Please sign in to comment.