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

Subheader without a newline is not detected #391

Open
fenuks opened this issue Jan 27, 2024 · 2 comments
Open

Subheader without a newline is not detected #391

fenuks opened this issue Jan 27, 2024 · 2 comments

Comments

@fenuks
Copy link

fenuks commented Jan 27, 2024

Hello, for file

# Bug report
## Description

Description header is not detected.

# Workaround

## Description
Add an empty line before the header.

vim-pandoc-syntax conceals it to
conceal.

This problem was introduced in 634d830. That change fixes incorrect detection of headers in the middle of paragraphs, but is a bit too strict.

@fenuks
Copy link
Author

fenuks commented Mar 2, 2024

This patch seems to fix the issue without adverse effects:

diff --git i/syntax/pandoc.vim w/syntax/pandoc.vim
index 38df7f1..9cdd83f 100644
--- i/syntax/pandoc.vim
+++ w/syntax/pandoc.vim
@@ -400,7 +400,7 @@ call s:WithConceal('strikeout', 'syn match pandocStrikeoutMark /\~\~/ contained
 " }}}2
 
 " Headers: {{{2
-syn match pandocAtxHeader /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,@Spell,pandocAmpersandEscape,pandocReferenceLabel,pandocReferenceURL display
+syn match pandocAtxHeader /\(\%^\|<.\+>.*\n\|^\s*\n\|^#\{1,6}.*\n\)\@<=#\{1,6}.*\n/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,@Spell,pandocAmpersandEscape,pandocReferenceLabel,pandocReferenceURL display
 syn match pandocAtxHeaderMark /\(^#\{1,6}\|\\\@<!#\+\(\s*.*$\)\@=\)/ contained containedin=pandocAtxHeader
 call s:WithConceal('atx', 'syn match pandocAtxStart /#/ contained containedin=pandocAtxHeaderMark', 'conceal cchar='.s:cchars['atx'])
 syn match pandocSetexHeader /^.\+\n[=]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,@Spell,pandocAmpersandEscape

@heyrict
Copy link

heyrict commented Jun 2, 2024

Here is a cleaner workaround before this patch can be merged to the upstream. Add these to vimrc:

augroup consecutive_heading
    au!
    au filetype pandoc syn clear pandocAtxHeader
    au filetype pandoc syn match pandocAtxHeader /\(\%^\|<.\+>.*\|^\s*\)\@<=#\{1,6}.*\n/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,@Spell,pandocAmpersandEscape,pandocReferenceLabel,pandocReferenceURL display
augroup END

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

2 participants