From: Ciro Santilli Date: Thu, 6 Feb 2014 09:16:06 +0000 (+0100) Subject: Merge pull request #62 from cirosantilli/readme-add-credits-section X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/e7f9c8699d72f22cb873c3666c8ef84e9462c787?hp=f4d217c14cef4d8ae7d8930d0e1a8c8fc3d0e727 Merge pull request #62 from cirosantilli/readme-add-credits-section Created credits section, remove link to the outdated homepage. --- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d6716ce --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,49 @@ +These contributing guidelines were accepted rather late in the history of this plugin, after much code had already been written. + +If you find any existing behavior which does not conform to these guidelines, please correct it and send a pull request. + +# General Rules + +Every non local identifier must start with `g:vim_markdown_`. + +# Documentation + +Every new feature must be documented under in the [README.md](README.md). Documentation must be written in [GFM](https://help.github.com/articles/github-flavored-markdown) since Github itself is the primary to HTML converter used. In particular, remember that GFM adds line breaks at single newlines, so just forget about the 70 characters wide rule. + +# Markdown Flavors + +There are many flavors of markdown, each one with an unique feature set. This plugin uses the following strategy to deal with all those flavors: + +- Features from the [original markdown](http://daringfireball.net/projects/markdown/syntax) are turned on by default. They may not even have an option that turns them off. + +- Features from other markdown flavors *must* have an option that turns them on or off. If the feature is common enough across multiple versions of markdown, it may be turned on by default. This shall be decided by the community when the merge request is done. + +- If possible, cite the exact point in the documentation of the flavor where a feature is specified. If the feature is not documented, you may also reference the source code itself of the implementation. This way, people who do not know that flavor can check if your implementation is correct. + +- Do not use the name of a flavor for a feature that is used across multiple flavors. Instead, create a separate flavor option, that automatically sets each feature. + + For example, fenced code blocks (putting code between pairs of three backticks) is not part of the original markdown, but is supported by [GFM](https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks) and [Jekyll](http://jekyllrb.com/docs/configuration/). + + Therefore, instead of creating an option `g:vim_markdown_gfm_fenced_code_block`, and an option `g:vim_markdown_jekyll_fenced_code_block`, create a single option `g:vim_markdown_fenced_code_block`. + + Next, if there are many more than one Jekyll feature options, create a `g:vim_markdown_jekyll` option that turns them all on at once. + +# Tests + +All new features must have tests. While we don't require unit tests, which are too hard to do in certain cases, you should create a test under the `test/` directory with a predictable name which allows other users to quickly test your feature. Good tests should explain their expected input / output behavior. Failing test should be marked with `FAIL` somewhere near the test, possibly explaining why it fails. For example: + +``` +## Links + +[Link text](link URL) + +... more correct link tests ... + +###### FAIL: should not be highlighted as a link + +Text (with parenthesis) alone should not be highlighted as a link. (Issue #57) + +... more failed link tests ... + +## Code Blocks +``` diff --git a/README.md b/README.md index 95db711..0be1957 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,24 @@ # Markdown Vim Mode -Syntax highlighting, matching rules and mappings for [Markdown](http://daringfireball.net/projects/markdown/). +Syntax highlighting, matching rules and mappings for [the original Markdown](http://daringfireball.net/projects/markdown/) and extensions. ## Installation -If you use [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)(and you should), do this: +If you use [Vundle](https://github.com/gmarik/vundle), add the following line to your `~/.vimrc`: + + Bundle 'plasticboy/vim-markdown' + +And then run inside Vim: + + :so ~/.vimrc + :BundleInstall + +If you use [Pathogen](https://github.com/tpope/vim-pathogen), do this: $ cd ~/.vim/bundle $ git clone https://github.com/plasticboy/vim-markdown.git -To install without Pathogen, download the [tarball](https://github.com/plasticboy/vim-markdown/archive/master.tar.gz) and do this: +If you are not using any package manager, download the [tarball](https://github.com/plasticboy/vim-markdown/archive/master.tar.gz) and do this: $ cd ~/.vim $ tar --strip=1 -zxf vim-markdown-master.tar.gz @@ -26,9 +35,7 @@ let g:vim_markdown_folding_disabled=1 **Set Initial Foldlevel** -Add the following line to your `.vimrc` to set the initial foldlevel. This -option defaults to 0 (i.e. all folds are closed) and is ignored if folding -is disabled. +Add the following line to your `.vimrc` to set the initial foldlevel. This option defaults to 0 (i.e. all folds are closed) and is ignored if folding is disabled. ```vim let g:vim_markdown_initial_foldlevel=1 diff --git a/syntax/mkd.vim b/syntax/mkd.vim index c4ceec4..82778c2 100644 --- a/syntax/mkd.vim +++ b/syntax/mkd.vim @@ -15,7 +15,10 @@ if version < 600 so :p:h/html.vim else runtime! syntax/html.vim - unlet b:current_syntax + + if exists('b:current_syntax') + unlet b:current_syntax + endif endif if version < 600 @@ -74,7 +77,7 @@ syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdIndentCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained syn match mkdListItem "^\s*[-*+]\s\+" syn match mkdListItem "^\s*\d\+\.\s\+" -syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem +syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/ syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/ diff --git a/test/syntax.md b/test/syntax.md new file mode 100644 index 0000000..8a7421d --- /dev/null +++ b/test/syntax.md @@ -0,0 +1,149 @@ +# Original markdown + +This section covers only features from the [original markdown](daringfireball.net/projects/markdown/syntax), in the same order that they are defined on the specification. + +Extensions will be tested on a separate section. + +## Paragraphs + +Paragraph. + +Line +break. + +## Headers + +The following should be highlighted as headers: + +# h1 + + # h1 + +# h1 # + +h1 +== + +## h2 + +## h2 ## + +h2 +-- + +### h3 + +#### h4 + +##### h5 + +###### h6 + +The following is unspecified by Markdown and may not highlight properly: + +####### h7 + +## Blockquotes + +> Block quote + +> First line only +block quote + +> Block quote +> > Block quote level 2 + +> # Markdown inside block quote +> +> [Link text](link-url) + +## Lists + +Only the list marker should be highlighted: + +* 0 +* 1 + ++ 0 ++ 1 + +- 0 +- 1 + +1. 0 +2. 1 + +*Not* lists: + +1 0 + + - 0 + +## Links + +[Link text](link-url) + +Reference style link: [Link text][reference] + +With space: [Link text] [reference] + +[reference]: address +[reference2]: address "Optional Title" + +## Code blocks + +Inline: `inline code` + +Indented: + + indented code block + + # not a header + + - not a list + +Indented code block and lists: + +- 0 + + Paragraph. + + indented code block inside list + +- 0 + + - 1 + + Paragraph (TODO FAIL). + + indented code block inside list + +## Emphasis + +The following should be italicized: + +*single asterisks* + +_single underscores_ + +The following should be boldface: + +**double asterisks** + +__double underscores__ + +# Extensions + +Fenced code blocks TODO add option to turn ON/OFF: + +``` +fenced code block +``` + +Fenced code block with language: + +```ruby +def f + 0 +end +```