Skip to content

Commit

Permalink
Markdown: handle XML/HTML comments
Browse files Browse the repository at this point in the history
  • Loading branch information
techee committed Jan 1, 2022
1 parent b1bd013 commit 69be461
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Units/parser-markdown.r/xml-comment.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
1 change: 1 addition & 0 deletions Units/parser-markdown.r/xml-comment.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXTRACT ME 1 input.md /^# EXTRACT ME 1$/;" c
7 changes: 7 additions & 0 deletions Units/parser-markdown.r/xml-comment.d/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
# SKIP ME 1
-->

<!-- # SKIP ME 2 -->

# EXTRACT ME 1
20 changes: 18 additions & 2 deletions parsers/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static void findMarkdownTags (void)
long startSourceLineNumber = 0;
long startLineNumber = 0;
bool inPreambule = false;
bool inComment = false;

nestingLevels = nestingLevelsNewFull (0, fillEndField);

Expand Down Expand Up @@ -246,9 +247,24 @@ static void findMarkdownTags (void)
lineProcessed = true;
}
}
/* XML comment start */
else if (lineLen >= pos + 4 && line[pos] == '<' && line[pos + 1] == '!' &&
line[pos + 2] == '-' && line[pos + 3] == '-')
{
if (strstr ((const char *)(line + pos + 4), "-->") == NULL)
inComment = true;
lineProcessed = true;
}
/* XML comment end */
else if (lineLen >= pos + 3 && line[pos] == '-' && line[pos + 1] == '-' &&
line[pos + 2] == '>')
{
inComment = false;
lineProcessed = true;
}

/* code block */
if (inCodeChar)
/* code block or comment */
if (inCodeChar || inComment)
lineProcessed = true;

/* code block using indent */
Expand Down

0 comments on commit 69be461

Please sign in to comment.