From efe6a9a14f91e48e3b5f5c36fbd833bfbf90677c Mon Sep 17 00:00:00 2001 From: rwxrob Date: Mon, 27 Jan 2020 09:30:43 -0500 Subject: [PATCH 1/2] Fix smart quotes and apostrophe --- doc/pandoc-syntax.txt | 2 ++ syntax/pandoc.vim | 26 +++++++++++++----- tests/smart.pdc | 63 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 tests/smart.pdc diff --git a/doc/pandoc-syntax.txt b/doc/pandoc-syntax.txt index 325b483..7a6069b 100644 --- a/doc/pandoc-syntax.txt +++ b/doc/pandoc-syntax.txt @@ -37,6 +37,8 @@ CONFIGURATION *vim-pandoc-syntax-configuration* - dashes - ellipses - quotes + - squotes + - apostrophe - inlinecode To review what are the rules for, look for the call to |s:WithConceal| in diff --git a/syntax/pandoc.vim b/syntax/pandoc.vim index 0e09029..b46f3cd 100644 --- a/syntax/pandoc.vim +++ b/syntax/pandoc.vim @@ -8,6 +8,7 @@ scriptencoding utf-8 " Maintainer: Caleb Maclennan " Contributor: David Sanson " Contributor: Jorge Israel Peña +" Contributor: Rob Muhlestein (twitch.tv/rwxrob) " OriginalAuthor: Jeremy Schultz " Version: 5.0 @@ -264,7 +265,7 @@ syn match pandocTitleBlockTitle /\%^%.*\n/ contained containedin=pandocTitleBloc " }}}2 " Blockquotes: {{{2 -syn match pandocBlockQuote /^\s\{,3}>.*\n\(.*\n\@1.*\n\(.*\n\@1/ contained containedin=pandocEmphasis,pandocStrong,pandocPCite,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocUListItem,pandocNoFormatted " }}}2 @@ -368,11 +369,11 @@ 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/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,pandocBeginQuote,pandocEndQuote,pandocBeginSQuote,pandocEndSQuote,pandocApostrophe,pandocEllipses,@Spell,pandocAmpersandEscape,pandocReferenceLabel,pandocReferenceURL display syn match pandocAtxHeaderMark /\(^#\{1,6}\|\\\@[[:punct:]]*\)\@<=''[[:blank:][:punct:]\n]\@=/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=’') +endif +" }}}3 + " Hrule: {{{3 syn match pandocHRule /^\s*\([*\-_]\)\s*\%(\1\s*\)\{2,}$/ display " }}}3 diff --git a/tests/smart.pdc b/tests/smart.pdc new file mode 100644 index 0000000..3c04dc8 --- /dev/null +++ b/tests/smart.pdc @@ -0,0 +1,63 @@ +# smart punctuation + +# Ellipses ... + +Ellipses ... +---------- + +Ellipses ... +========== + +And then there was ... + +Blah ... blah. + +... and yet. +...and yet. + +# "Foo" is a thing + +A "Foo" is a thing +------------------ + +A "Foo" is a thing +================== + +Just some "foo" here. +Are you a "foo"? + +"Foo" +*"Foo"* +**"Foo"** +_"Foo"_ +__"Foo"__ +~~"Foo"~~ + +# 'Bar' + +'Bar' +----- + +'Bar' +===== + +Just some 'bar' here. +Are you a 'bar'? + +'Bar' +*'Bar'* +**'Bar'** +_'Bar'_ +__'Bar'__ +~~'Bar'~~ + +# I'd Really Like to Know + +I'd Really Like to Know +----------------------- + +I'd Really Like to Know +======================= + +I'd +'cuz From ee59c576a2278122a2e6a8bd147a44db7ece5981 Mon Sep 17 00:00:00 2001 From: rwxrob Date: Thu, 13 Feb 2020 16:50:06 -0500 Subject: [PATCH 2/2] Fix ellipsis, start fix for en and em-dash --- syntax/pandoc.vim | 6 +++--- tests/smart.pdc | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/syntax/pandoc.vim b/syntax/pandoc.vim index b46f3cd..292a0c0 100644 --- a/syntax/pandoc.vim +++ b/syntax/pandoc.vim @@ -501,19 +501,19 @@ endif " Emdashes: {{{3 if &encoding ==# 'utf-8' - call s:WithConceal('emdashes', 'syn match pandocEllipses /\([^-]\)\@<=---\([^-]\)\@=/ display', 'conceal cchar=—') + call s:WithConceal('emdashes', 'syn match pandocEmdashes /---/ containedin=pandocSetexHeader,pandocEmphasis,pandocStrong,pandocListItem,pandocListItemContinuation,pandocUListItem display', 'conceal cchar=—') endif " }}}3 " Endashes: {{{3 if &encoding ==# 'utf-8' - call s:WithConceal('endashes', 'syn match pandocEllipses /\([^-]\)\@<=--\([^-]\)\@=/ display', 'conceal cchar=–') + call s:WithConceal('endashes', 'syn match pandocEndashes /\([^-]\)\@<=--\([^-]\)\@=/ display', 'conceal cchar=–') endif " }}}3 " Ellipses: {{{3 if &encoding ==# 'utf-8' - call s:WithConceal('ellipses', 'syn match pandocEllipses /\.\.\./ display', 'conceal cchar=…') + call s:WithConceal('ellipses', 'syn match pandocEllipses /\.\.\./ containedin=pandocEmphasis,pandocStrong,pandocListItem,pandocListItemContinuation,pandocUListItem display', 'conceal cchar=…') endif " }}}3 diff --git a/tests/smart.pdc b/tests/smart.pdc index 3c04dc8..71a43d3 100644 --- a/tests/smart.pdc +++ b/tests/smart.pdc @@ -1,4 +1,4 @@ -# smart punctuation +# Smart Punctuation # Ellipses ... @@ -15,6 +15,38 @@ Blah ... blah. ... and yet. ...and yet. +* I'm in a bullet... + +Endash -- +---------- + +Endash -- +========== + +And then there was -- + +Blah--blah. +Blah -- blah. + +-- and yet. +--and yet. + +* I'm in a bullet... + +Emdash --- +--------- + +Emdash --- +========== + +And then there was --- + +Blah---blah. +Blah --- blah. + +--- and yet. +---and yet. + # "Foo" is a thing A "Foo" is a thing