From f1dc484fa7146b847ba5ef200f072cc576a8753b Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 4 Apr 2021 23:26:31 +0200 Subject: MarkdownRenderer: move resetting format to a separate function --- src/renderers/markdownrenderer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/renderers/markdownrenderer.cpp') 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 ¤t_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: -- cgit v1.2.3