From f3baca79549205c19cde6712a93982f971b58da5 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 18 Oct 2020 16:28:43 +0200 Subject: When we have some simple markdown files like with extra spaces (after `\aa2`, `\bb2` and `\ccs2` to give in markdown a newline): ``` First test: 2 extra spaces after first line with error no extra empty lines \aa2 \aa3 ``` and ``` First test: 2 extra spaces after first line with error one extra empty line \bb2 \bb4 ``` and ``` First test: 2 extra spaces after first line with error two extra empty lines \cc2 \cc5 ``` we get warnings like: ``` .../aa.md:2: warning: Found unknown command '\aa2' .../aa.md:4: warning: Found unknown command '\aa3' .../bb.md:2: warning: Found unknown command '\bb2' .../bb.md:5: warning: Found unknown command '\bb4' .../cc.md:2: warning: Found unknown command '\cc2' .../cc.md:6: warning: Found unknown command '\cc5' ``` whilst this should be: ``` .../aa.md:2: warning: Found unknown command '\aa2' .../aa.md:3: warning: Found unknown command '\aa3' .../bb.md:2: warning: Found unknown command '\bb2' .../bb.md:4: warning: Found unknown command '\bb4' .../cc.md:2: warning: Found unknown command '\cc2' .../cc.md:5: warning: Found unknown command '\cc5' ``` This has been corrected by placing the `
` straight after the extra spaces and by not adding an extra newline. --- src/markdown.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/markdown.cpp b/src/markdown.cpp index 930efd6..8da908c 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -2070,11 +2070,15 @@ void Markdown::writeOneLineHeaderOrRuler(const char *data,int size) } else // nothing interesting -> just output the line { - m_out.addStr(data,size); + int tmpSize = size; + if (data[size-1] == '\n') tmpSize--; + m_out.addStr(data,tmpSize); + if (hasLineBreak(data,size)) { - m_out.addStr("
\n"); + m_out.addStr("
"); } + if (tmpSize != size) m_out.addChar('\n'); } } -- cgit v0.12