Skip to content

multiple smart punctuation fixes #312

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
Standalone pandoc syntax module, to be used alongside
[vim-pandoc](http://github.com/vim-pandoc/vim-pandoc).

Forked from the version provided by `fmoralesc/vim-pantondoc`, in turn taken
from `vim-pandoc/vim-pandoc`.
Forked from the version provided by `fmoralesc/vim-pantondoc`, in turn taken from `vim-pandoc/vim-pandoc`.

## Requirements

Expand All @@ -16,44 +15,52 @@ from `vim-pandoc/vim-pandoc`.

## Installation

The repository follows the usual bundle structure, so it's easy to install it
using [pathogen](https://github.com/tpope/vim-pathogen),
[Vundle](https://github.com/gmarik/vundle) or NeoBundle.
The repository follows the usual bundle structure, so it's easy to install it using [Plug](https://github.com/junegunn/vim-plug), [pathogen](https://github.com/tpope/vim-pathogen), [Vundle](https://github.com/gmarik/vundle) or NeoBundle.

For Vundle users, it should be enough to add
**Plug** adds something like the following lines to `.vimrc`:

Plugin 'vim-pandoc/vim-pandoc-syntax'
```vim
Plug 'vim-pandoc/vim-pandoc-syntax'
```

to `.vimrc`, and then run `:PluginInstall`.
**Vundle** users should add:

For those who need it, a tarball is available from
[here](https://github.com/vim-pandoc/vim-pandoc-syntax/archive/master.zip).
```vim
Plugin 'vim-pandoc/vim-pandoc-syntax'
```

Run `:PluginInstall` after making the changes from within a `vim` session, or you can just run `vim +':PlugInstall' +':q!' +':q!'` from the command line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run `:PluginInstall` after making the changes from within a `vim` session, or you can just run `vim +':PlugInstall' +':q!' +':q!'` from the command line.
Run `:PluginInstall` after making the changes and reloading your rc file from within a `vim` session, or you can just run `vim +PlugInstall +UpdateRemotePlugins +all +qa` from the command line.


A [tarball](https://github.com/vim-pandoc/vim-pandoc-syntax/archive/master.zip) is also available.

### Standalone

If you want to use `vim-pandoc-syntax` without vim-pandoc, you'll need to tell
Vim to load it for certain files. Just add something like this to your vimrc:

~~~ vim
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END
~~~
```vim
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END
```

## Features

* Supports most (if not all) pandoc's markdown features, including tables,
* Supports most (if not all) Pandoc's markdown features, including tables,
delimited codeblocks, references, etc.

* Can handle multiple embedded languages (LaTeX, YAML headers, many languages
in delimited codeblocks). Some commands are provided to help with this (see
`:help pandoc-syntax-commands`)

* Pretty display using `conceal` (optional).

* Configurable (see `:help pandoc-syntax-configuration` for an overview of the
options).

## Screenshots

![img1](http://i.imgur.com/UKXbG2V.png)
![img2](http://i.imgur.com/z8FpxRP.png)
![img3](http://i.imgur.com/ziNjQiE.png)
![img4](http://i.imgur.com/UKoOxzP.png)
![img1](doc/UKXbG2V.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert these changes and drop the image blobs from the commit(s)? For now I think I'd rather leave these out-of-band. One you put screenshots in a plugin they follow the repository around literally forever, and if you update them people start having multiple versions of the images in their repositories. Given that I check out my plugins on all sorts of machines, that starts adding up space and bandwidth for very little gain.

![img2](doc/z8FpxRP.png)
![img3](doc/ziNjQiE.png)
![img4](doc/UKoOxzP.png)
Binary file added doc/UKXbG2V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/UKoOxzP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions doc/pandoc-syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added doc/z8FpxRP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/ziNjQiE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 28 additions & 6 deletions syntax/pandoc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ scriptencoding utf-8
" Maintainer: Caleb Maclennan <[email protected]>
" Contributor: David Sanson <[email protected]>
" Contributor: Jorge Israel Peña <[email protected]>
" Contributor: Rob Muhlestein (twitch.tv/rwxrob) <[email protected]>
" OriginalAuthor: Jeremy Schultz <[email protected]>
" Version: 5.0
" Version: 5.1

" Configuration: {{{1
"
Expand Down Expand Up @@ -223,6 +224,14 @@ endif

" Syntax Rules: {{{1

" corrects distracting conceal (ligature) background colors, blue makes
" it obvious that the character is a ligature instead of an actual Unicode
" character since both can exist in the same file
hi Conceal ctermbg=none ctermfg=Blue

" preferable link color to underlining
hi link pandocDelimitedCodeBlock pandocNoFormatted

" Embeds: {{{2

" HTML: {{{3
Expand Down Expand Up @@ -368,11 +377,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}\|\\\@<!#\+\(\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
syn match pandocSetexHeader /^.\+\n[-]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,@Spell,pandocAmpersandEscape
syn match pandocSetexHeader /^.\+\n[=]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,pandocBeginQuote,pandocEndQuote,pandocBeginSQuote,pandocEndSQuote,pandocApostrophe,pandocEllipses,@Spell,pandocAmpersandEscape
syn match pandocSetexHeader /^.\+\n[-]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,pandocEscapedDollar,pandocBeginQuote,pandocEndQuote,pandocBeginSQuote,pandocEndSQuote,pandocApostrophe,pandocEllipses,@Spell,pandocAmpersandEscape
syn match pandocHeaderAttr /{.*}/ contained containedin=pandocAtxHeader,pandocSetexHeader
syn match pandocHeaderID /#[-_:.[:lower:][:upper:]]*/ contained containedin=pandocHeaderAttr
" }}}2
Expand Down Expand Up @@ -452,12 +461,12 @@ call s:WithConceal('abbrev', 'syn match pandocAbbreviationTail /\]/ contained co
syn match pandocFootnoteID /\[\^[^\]]\+\]/ nextgroup=pandocFootnoteDef

" Inline footnotes
syn region pandocFootnoteDef start=/\^\[/ skip=/\[.\{-}]/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocStrongEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell,pandocAmpersandEscape skipnl keepend
syn region pandocFootnoteDef start=/\^\[/ skip=/\[.\{-}]/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocStrongEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,pandocBeginSQuote,pandocEndSQuote,pandocApostrophe,@Spell,pandocAmpersandEscape skipnl keepend
call s:WithConceal('footnote', 'syn match pandocFootnoteDefHead /\^\[/ contained containedin=pandocFootnoteDef', 'conceal cchar='.s:cchars['footnote'])
call s:WithConceal('footnote', 'syn match pandocFootnoteDefTail /\]/ contained containedin=pandocFootnoteDef', 'conceal')

" regular footnotes
syn region pandocFootnoteBlock start=/\[\^.\{-}\]:\s*\n*/ end=/^\n^\s\@!/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocNewLine,pandocStrongEmphasis,pandocEllipses,pandocBeginQuote,pandocEndQuote,pandocLaTeXInlineMath,pandocEscapedDollar,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXRegion,pandocAmpersandEscape,@Spell skipnl
syn region pandocFootnoteBlock start=/\[\^.\{-}\]:\s*\n*/ end=/^\n^\s\@!/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocNewLine,pandocStrongEmphasis,pandocEllipses,pandocBeginQuote,pandocEndQuote,pandocBeginSQuote,pandocEndSQuote,pandocApostophe,pandocLaTeXInlineMath,pandocEscapedDollar,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXRegion,pandocAmpersandEscape,@Spell skipnl
syn match pandocFootnoteBlockSeparator /:/ contained containedin=pandocFootnoteBlock
syn match pandocFootnoteID /\[\^.\{-}\]/ contained containedin=pandocFootnoteBlock
call s:WithConceal('footnote', 'syn match pandocFootnoteIDHead /\[\^/ contained containedin=pandocFootnoteID', 'conceal cchar='.s:cchars['footnote'])
Expand Down Expand Up @@ -522,6 +531,19 @@ if &encoding ==# 'utf-8'
call s:WithConceal('quotes', 'syn match pandocEndQuote /\(\>[[:punct:]]*\)\@<="[[:blank:][:punct:]\n]\@=/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=”')
endif
" }}}3
"
" Apostrophes: {{{3
if &encoding ==# 'utf-8'
call s:WithConceal('apostrophes', 'syn match pandocApostrophe /[*~_\n[:space:]]\@<!''/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=’')
endif
" }}}3

" Single Quotes: {{{3
if &encoding ==# 'utf-8'
call s:WithConceal('squotes', 'syn match pandocBeginSQuote /[_*\n[:space:]]\@<=''\</ containedin=pandocEmphasis,pandocStrong,pandocListItem,pandocListItemContinuation,pandocUListItem display', 'conceal cchar=‘')
call s:WithConceal('squotes', 'syn match pandocEndSQuote /\(\>[[: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
Expand Down
11 changes: 0 additions & 11 deletions tests/block.pdc
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,3 @@ hello
1) a
2) b

# smart punctuation

ellipses: ....
quote "signs". This only works at the beggining and end of words.
quote "signs."

issue #31:

"Foo"
*"Foo"*
**"Foo"**
63 changes: 63 additions & 0 deletions tests/smart.pdc
Original file line number Diff line number Diff line change
@@ -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