Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line-headings fails for code beginning lines #635

Open
KSR-Yasuda opened this issue Jul 12, 2023 · 4 comments
Open

Line-headings fails for code beginning lines #635

KSR-Yasuda opened this issue Jul 12, 2023 · 4 comments

Comments

@KSR-Yasuda
Copy link
Contributor

Line-headings (==== or ---- line following heading text)
does not work for the lines that begin with `code`.

hogefuga (OK)
====

hogefuga (OK)
----

`hoge` fuga (NG)
====

`hoge` fuga (NG)
----

markdown

@lggruspe
Copy link
Contributor

This is also the case with strikethrough text.

Stuff like :Toc and :HeaderDecrease work just fine, but the syntax highlighting is broken.

@alerque
Copy link
Member

alerque commented Sep 20, 2023

@lggruspe Curious why you didn't include code markup in #641 ... is there an issue with ATX vs. SetExt headers here or some other holdup? Would extending the list of contains fix this?

@lggruspe
Copy link
Contributor

There's an issue with code span highlighting. The syntax file currently only looks for closing delimiters with 3+ backticks at the start of a line, so code spans like the following don't get closed.

# ```code```

This paragraph gets highlighted as code.

@KSR-Yasuda
Copy link
Contributor Author

Perhaps just moving htmlH[12] rules for "Line following heading case\n====" after mkdCode rule
works fine as "# preceding heading case"?

--- a/syntax/markdown.vim
+++ b/syntax/markdown.vim
@@ -85,16 +85,6 @@ syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+     end=+"+  contained
 syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+     end=+'+  contained
 syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+     end=+)+  contained
 
-"HTML headings
-syn region htmlH1       matchgroup=mkdHeading     start="^\s*#"                   end="$" contains=@mkdHeadingContent,@Spell
-syn region htmlH2       matchgroup=mkdHeading     start="^\s*##"                  end="$" contains=@mkdHeadingContent,@Spell
-syn region htmlH3       matchgroup=mkdHeading     start="^\s*###"                 end="$" contains=@mkdHeadingContent,@Spell
-syn region htmlH4       matchgroup=mkdHeading     start="^\s*####"                end="$" contains=@mkdHeadingContent,@Spell
-syn region htmlH5       matchgroup=mkdHeading     start="^\s*#####"               end="$" contains=@mkdHeadingContent,@Spell
-syn region htmlH6       matchgroup=mkdHeading     start="^\s*######"              end="$" contains=@mkdHeadingContent,@Spell
-syn match  htmlH1       /^.\+\n=\+$/ contains=@mkdHeadingContent,@Spell
-syn match  htmlH2       /^.\+\n-\+$/ contains=@mkdHeadingContent,@Spell
-
 "define Markdown groups
 syn match  mkdLineBreak    /  \+$/
 syn region mkdBlockquote   start=/^\s*>/                   end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell
@@ -117,6 +107,16 @@ syn match  mkdRule         /^\s*\*\s\{0,1}\*\s\{0,1}\*\(\*\|\s\)*$/
 syn match  mkdRule         /^\s*-\s\{0,1}-\s\{0,1}-\(-\|\s\)*$/
 syn match  mkdRule         /^\s*_\s\{0,1}_\s\{0,1}_\(_\|\s\)*$/
 
+"HTML headings
+syn region htmlH1       matchgroup=mkdHeading     start="^\s*#"                   end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH2       matchgroup=mkdHeading     start="^\s*##"                  end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH3       matchgroup=mkdHeading     start="^\s*###"                 end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH4       matchgroup=mkdHeading     start="^\s*####"                end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH5       matchgroup=mkdHeading     start="^\s*#####"               end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH6       matchgroup=mkdHeading     start="^\s*######"              end="$" contains=@mkdHeadingContent,@Spell
+syn match  htmlH1       /^.\+\n=\+$/ contains=@mkdHeadingContent,@Spell
+syn match  htmlH2       /^.\+\n-\+$/ contains=@mkdHeadingContent,@Spell
+
 " YAML frontmatter
 if get(g:, 'vim_markdown_frontmatter', 0)
   syn include @yamlTop syntax/yaml.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants