aboutsummaryrefslogtreecommitdiff
path: root/src/renderers/markdownrenderer.cpp
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-04-04 23:26:31 +0200
committerFelix Queißner <felix@ib-queissner.de>2021-04-05 17:13:58 +0200
commitf1dc484fa7146b847ba5ef200f072cc576a8753b (patch)
treed349da6fccb7a6dcef96d0cb5edd50e9b0786567 /src/renderers/markdownrenderer.cpp
parent0e6bed958e9c179e9a6fddde13b9a9f883abe861 (diff)
downloadkristall-f1dc484fa7146b847ba5ef200f072cc576a8753b.tar.gz
MarkdownRenderer: move resetting format to a separate function
Diffstat (limited to 'src/renderers/markdownrenderer.cpp')
-rw-r--r--src/renderers/markdownrenderer.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/renderers/markdownrenderer.cpp b/src/renderers/markdownrenderer.cpp
index 9e9e953..f001d45 100644
--- a/src/renderers/markdownrenderer.cpp
+++ b/src/renderers/markdownrenderer.cpp
@@ -106,6 +106,13 @@ static QString extractNodeText(cmark_node &node)
return QString::fromUtf8(data, strlen(data));
}
+static void resetFormatting(RenderState &state)
+{
+ state.emitNewBlock();
+ state.suppress_next_block = true;
+ state.cursor.setBlockFormat(state.text_style.standard_format);
+}
+
static void renderNode(RenderState &state, cmark_node & node, const QTextCharFormat &current_format, int listIndent)
{
auto & cursor = state.cursor;
@@ -126,10 +133,7 @@ static void renderNode(RenderState &state, cmark_node & node, const QTextCharFor
cursor.setBlockFormat(state.text_style.blockquote_format);
renderChildren(state, node, current_format);
- state.emitNewBlock();
- state.suppress_next_block = true;
- cursor.setBlockFormat(state.text_style.standard_format);
-
+ resetFormatting(state);
break;
}
case CMARK_NODE_LIST:
@@ -166,10 +170,7 @@ static void renderNode(RenderState &state, cmark_node & node, const QTextCharFor
QString code = extractNodeText(node);
cursor.insertText(code, state.text_style.preformatted);
- state.emitNewBlock();
- state.suppress_next_block = true;
- cursor.setBlockFormat(state.text_style.standard_format);
-
+ resetFormatting(state);
break;
}
case CMARK_NODE_HTML_BLOCK: