]> git.madduck.net Git - etc/vim.git/blob - mkd.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

6c23415f76f46c06c4a96285e4698f3adf6ddf5c
[etc/vim.git] / mkd.vim
1 " Vim syntax file
2 " Language:     Markdown
3 " Maintainer:   Ben Williams <benw@plasticboy.com>
4 " URL:          http://plasticboy.com/markdown-vim-mode/
5 " Version:      8
6 " Last Change:  2008 April 29 
7 " Remark:       Uses HTML syntax file
8 " Remark:       I don't do anything with angle brackets (<>) because that would too easily
9 "               easily conflict with HTML syntax
10 " TODO:         Do something appropriate with image syntax
11 " TODO:         Handle stuff contained within stuff (e.g. headings within blockquotes)
12
13
14 " Read the HTML syntax to start with
15 if version < 600
16   so <sfile>:p:h/html.vim
17 else
18   runtime! syntax/html.vim
19   unlet b:current_syntax
20 endif
21
22 if version < 600
23   syntax clear
24 elseif exists("b:current_syntax")
25   finish
26 endif
27
28 " don't use standard HiLink, it will not work with included syntax files
29 if version < 508
30   command! -nargs=+ HtmlHiLink hi link <args>
31 else
32   command! -nargs=+ HtmlHiLink hi def link <args>
33 endif
34
35 syn spell toplevel
36 syn case ignore
37 syn sync linebreaks=1
38
39 "additions to HTML groups
40 syn region htmlBold     start=/\(^\|\s\)\*\@<!\*\*\*\@!/     end=/\*\@<!\*\*\*\@!\($\|\s\)/   contains=@Spell,htmlItalic
41 syn region htmlItalic   start=/\(^\|\s\)\*\@<!\*\*\@!/       end=/\*\@<!\*\*\@!\($\|\s\)/      contains=htmlBold,@Spell
42 syn region htmlBold     start=/\(^\|\s\)_\@<!___\@!/         end=/_\@<!___\@!\($\|\s\)/       contains=htmlItalic,@Spell
43 syn region htmlItalic   start=/\(^\|\s\)_\@<!__\@!/          end=/_\@<!__\@!\($\|\s\)/        contains=htmlBold,@Spell
44 syn region htmlString   start="]("ms=s+2             end=")"me=e-1
45 syn region htmlLink     start="\["ms=s+1            end="\]"me=e-1 contains=@Spell
46 syn region htmlString   start="\(\[.*]: *\)\@<=.*"  end="$"
47
48 "define Markdown groups
49 syn match  mkdLineContinue ".$" contained
50 syn match  mkdRule      /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
51 syn match  mkdRule      /^\s*-\s\{0,1}-\s\{0,1}-$/
52 syn match  mkdRule      /^\s*_\s\{0,1}_\s\{0,1}_$/
53 syn match  mkdRule      /^\s*-\{3,}$/
54 syn match  mkdRule      /^\s*\*\{3,5}$/
55 syn match  mkdListItem  "^\s*[-*+]\s\+"
56 syn match  mkdListItem  "^\s*\d\+\.\s\+"
57 syn match  mkdCode      /^\s*\n\(\(\s\{4,}\|[\t]\+\)[^*-+ ].*\n\)\+/
58 syn region mkdCode      start=/`/                   end=/`/
59 syn region mkdCode      start=/\s*``[^`]*/          end=/[^`]*``\s*/
60 syn region mkdBlockquote start=/^\s*>/              end=/$/                 contains=mkdLineContinue,@Spell
61 syn region mkdCode      start="<pre[^>]*>"         end="</pre>"
62 syn region mkdCode      start="<code[^>]*>"        end="</code>"
63
64 "HTML headings
65 syn region htmlH1       start="^\s*#"                   end="\($\|#\+\)" contains=@Spell
66 syn region htmlH2       start="^\s*##"                  end="\($\|#\+\)" contains=@Spell
67 syn region htmlH3       start="^\s*###"                 end="\($\|#\+\)" contains=@Spell
68 syn region htmlH4       start="^\s*####"                end="\($\|#\+\)" contains=@Spell
69 syn region htmlH5       start="^\s*#####"               end="\($\|#\+\)" contains=@Spell
70 syn region htmlH6       start="^\s*######"              end="\($\|#\+\)" contains=@Spell
71 syn match  htmlH1       /^.\+\n=\+$/ contains=@Spell
72 syn match  htmlH2       /^.\+\n-\+$/ contains=@Spell
73
74 "highlighting for Markdown groups
75 HtmlHiLink mkdString        String
76 HtmlHiLink mkdCode          String
77 HtmlHiLink mkdBlockquote    Comment
78 HtmlHiLink mkdLineContinue  Comment
79 HtmlHiLink mkdListItem      Identifier
80 HtmlHiLink mkdRule          Identifier
81
82
83 let b:current_syntax = "mkd"
84
85 delcommand HtmlHiLink
86 " vim: ts=8