Skip to content

Commit 78320f2

Browse files
committed
Markdown: handle XML/HTML comments
1 parent b1bd013 commit 78320f2

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXTRACT ME 1 input.md /^# EXTRACT ME 1$/;" c
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
# SKIP ME 1
3+
-->
4+
5+
<!-- # SKIP ME 2 -->
6+
7+
# EXTRACT ME 1

parsers/markdown.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static void findMarkdownTags (void)
193193
long startSourceLineNumber = 0;
194194
long startLineNumber = 0;
195195
bool inPreambule = false;
196+
bool inComment = false;
196197

197198
nestingLevels = nestingLevelsNewFull (0, fillEndField);
198199

@@ -246,9 +247,23 @@ static void findMarkdownTags (void)
246247
lineProcessed = true;
247248
}
248249
}
250+
/* XML comment start */
251+
else if (lineLen >= pos + 4 && line[pos] == '<' && line[pos + 1] == '!' &&
252+
line[pos + 2] == '-' && line[pos + 3] == '-')
253+
{
254+
if (strstr ((const char *)(line + pos + 4), "-->") == NULL)
255+
inComment = true;
256+
lineProcessed = true;
257+
}
258+
/* XML comment end */
259+
else if (inComment && strstr ((const char *)(line + pos), "-->"))
260+
{
261+
inComment = false;
262+
lineProcessed = true;
263+
}
249264

250-
/* code block */
251-
if (inCodeChar)
265+
/* code block or comment */
266+
if (inCodeChar || inComment)
252267
lineProcessed = true;
253268

254269
/* code block using indent */

0 commit comments

Comments
 (0)