Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP4:FactoryCandidates
vim-plugins
vim-markdown-2.0.0+20220926.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vim-markdown-2.0.0+20220926.obscpio of Package vim-plugins
07070100000000000041ED00000000000000000000000363314A4700000000000000000000000000000000000000000000002400000000vim-markdown-2.0.0+20220926/.github07070100000001000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002E00000000vim-markdown-2.0.0+20220926/.github/workflows07070100000002000081A400000000000000000000000163314A4700000129000000000000000000000000000000000000003C00000000vim-markdown-2.0.0+20220926/.github/workflows/reviewdog.ymlname: Reviewdog on: [pull_request] jobs: vint: name: vint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: vint uses: reviewdog/action-vint@v1 with: github_token: ${{ secrets.github_token }} reporter: github-pr-review 07070100000003000081A400000000000000000000000163314A470000037F000000000000000000000000000000000000003800000000vim-markdown-2.0.0+20220926/.github/workflows/vader.ymlname: Vader on: [push, pull_request] jobs: vader: name: vader runs-on: ubuntu-latest strategy: fail-fast: false matrix: vimFlavor: ["vim", "nvim"] steps: - name: Checkout uses: actions/checkout@v2 - name: Enable Universe package repository run: | sudo add-apt-repository universe sudo apt-get update - name: Install ${{ matrix.vimFlavor }} run: | sudo apt-get install ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }} - name: Review versions run: | ${{ matrix.vimFlavor }} --version - name: Fetch Vader and other dependencies run: | make build/tabular build/vim-toml build/vim-json build/vader.vim - name: Run test suite run: | cd test ${{ matrix.vimFlavor == 'nvim' && 'nvim --headless' || 'vim -N' }} \ -u vimrc "+Vader! *" 07070100000004000081A400000000000000000000000163314A4700000148000000000000000000000000000000000000003700000000vim-markdown-2.0.0+20220926/.github/workflows/vint.ymlname: Vint on: [push] jobs: vint: name: vint runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 - name: Setup dependencies run: pip install vim-vint - name: Lint Vimscript run: vint . 07070100000005000081A400000000000000000000000163314A4700000010000000000000000000000000000000000000002700000000vim-markdown-2.0.0+20220926/.gitignorebuild /doc/tags 07070100000006000081A400000000000000000000000163314A470000004A000000000000000000000000000000000000002900000000vim-markdown-2.0.0+20220926/.vintrc.yamlcmdargs: severity: style_problem color: true env: neovim: false 07070100000007000081A400000000000000000000000163314A4700000D83000000000000000000000000000000000000002C00000000vim-markdown-2.0.0+20220926/CONTRIBUTING.md# CONTRIBUTING 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. Vim help file [doc/vim-markdown.txt](doc/vim-markdown.txt) will be generated from [README.md](README.md) by `make doc` using [vim-tools](https://github.com/xolox/vim-tools). ## 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. ## Style When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: <https://cirosantilli.com/markdown-style-guide> If you wish to have a behavior that differs from that style guide, add an option to turn it on or off, and leave it off by default. ## Tests All new features must have unit tests. ## Issues Issues are tracked within GitHub. When reporting issues, your report is more effective if you include a minimal example file that reproduces the problem. Try to trim out as much as possible, until you have the smallest possible file that still reproduces the issue. Paste the example inline into your issue report, quoted using four spaces at the beginning of each line, like this example from issue [#189](https://github.com/preservim/vim-markdown/issues/189): ``` Minimal example: ``` = ``` bad! ``` 07070100000008000081A400000000000000000000000163314A4700000CDC000000000000000000000000000000000000002500000000vim-markdown-2.0.0+20220926/MakefileVIMDIR=$(DESTDIR)/usr/share/vim ADDONS=${VIMDIR}/addons REGISTRY=${VIMDIR}/registry all: install: mkdir -pv ${ADDONS}/ftdetect cp -v ftdetect/markdown.vim ${ADDONS}/ftdetect/markdown.vim mkdir -pv ${ADDONS}/ftplugin cp -v ftplugin/markdown.vim ${ADDONS}/ftplugin/markdown.vim mkdir -pv ${ADDONS}/syntax cp -v syntax/markdown.vim ${ADDONS}/syntax/markdown.vim mkdir -pv ${ADDONS}/after/ftplugin cp -v after/ftplugin/markdown.vim ${ADDONS}/after/ftplugin/markdown.vim mkdir -pv ${ADDONS}/indent cp -v indent/markdown.vim ${ADDONS}/indent/markdown.vim mkdir -pv ${ADDONS}/doc cp -v doc/vim-markdown.txt ${ADDONS}/doc/vim-markdown.txt mkdir -pv ${REGISTRY} cp -v registry/markdown.yaml ${REGISTRY}/markdown.yaml test: build/tabular build/vim-toml build/vim-json build/vader.vim test/run-tests.sh .PHONY: test update: build/tabular build/vim-toml build/vim-json build/vader.vim cd build/tabular && git pull cd build/vim-toml && git pull cd build/vim-json && git pull cd build/vader.vim && git pull .PHONY: update build/tabular: | build git clone https://github.com/godlygeek/tabular build/tabular build/vim-toml: | build git clone https://github.com/cespare/vim-toml build/vim-toml build/vim-json: | build git clone https://github.com/elzr/vim-json build/vim-json build/vader.vim: | build git clone https://github.com/junegunn/vader.vim build/vader.vim build: mkdir build doc: build/html2vimdoc build/vim-tools sed -e '/^\[!\[Build Status\]/d' \ -e '/^1\. \[/d' README.md > doc/tmp.md # remove table of contents build/html2vimdoc/bin/python build/vim-tools/html2vimdoc.py -f vim-markdown \ doc/tmp.md | \ sed -E -e "s/[[:space:]]*$$//" -e "# remove trailing spaces" \ -e "/^.{79,}\|$$/ {" -e "# wrap table of contents over 79" \ -e "h" -e "# save the matched line to the hold space" \ -e "s/^(.*) (\|[^|]*\|)$$/\1/" -e "# make content title" \ -e "p" -e "# print title" \ -e "g" -e "# restore the matched line" \ -e "s/^.* (\|[^|]*\|)$$/ \1/" -e "# make link" \ -e ":c" -e "s/^(.{1,78})$$/ \1/" -e "tc" -e "# align right" \ -e "}" \ -e "/^- '[^']*':( |$$)/ {" \ -e "h" -e "# save the matched line to the hold space" \ -e "s/^- '([^']{3,})':.*/ \*\1\*/" -e "# make command reference" \ -e "s/^- '([^']{1,2})':.*/ \*vim-markdown-\1\*/" -e "# short command" \ -e ":a" -e "s/^(.{1,78})$$/ \1/" -e "ta" -e "# align right" \ -e "G" -e "# append the matched line after the command reference" \ -e "}" \ -e "/^- 'g:vim_markdown_[[:alnum:]_]*'$$/ {" \ -e "h" -e "# save the matched line to the hold space" \ -e "s/^- '([^']*)'$$/ \*\1\*/" -e "# make global variable reference" \ -e ":g" -e "s/^(.{1,78})$$/ \1/" -e "tg" -e "# align right" \ -e "G" -e "# append the matched line after the global variable reference" \ -e "}" > doc/vim-markdown.txt && rm -f doc/tmp.md .PHONY: doc # Prerequire Python and virtualenv. # $ sudo pip install virtualenv # Create the virtual environment. # Install the dependencies. build/html2vimdoc: | build virtualenv build/html2vimdoc build/html2vimdoc/bin/pip install beautifulsoup coloredlogs==4.0 markdown build/vim-tools: | build git clone https://github.com/xolox/vim-tools.git build/vim-tools 07070100000009000081A400000000000000000000000163314A4700003E69000000000000000000000000000000000000002600000000vim-markdown-2.0.0+20220926/README.md# Vim Markdown [![Vint](https://github.com/preservim/vim-markdown/workflows/Vint/badge.svg)](https://github.com/preservim/vim-markdown/actions?workflow=Vint) [![Vader](https://github.com/preservim/vim-markdown/workflows/Vader/badge.svg)](https://github.com/preservim/vim-markdown/actions?workflow=Vader) Syntax highlighting, matching rules and mappings for [the original Markdown](http://daringfireball.net/projects/markdown/) and extensions. 1. [Installation](#installation) 1. [Basic usage](#basic-usage) 1. [Options](#options) 1. [Mappings](#mappings) 1. [Commands](#commands) 1. [Credits](#credits) 1. [License](#license) ## Installation If you use [Vundle](https://github.com/gmarik/vundle), add the following lines to your `~/.vimrc`: ```vim Plugin 'godlygeek/tabular' Plugin 'preservim/vim-markdown' ``` The `tabular` plugin must come *before* `vim-markdown`. Then run inside Vim: ```vim :so ~/.vimrc :PluginInstall ``` If you use [Pathogen](https://github.com/tpope/vim-pathogen), do this: ```sh cd ~/.vim/bundle git clone https://github.com/preservim/vim-markdown.git ``` To install without Pathogen using the Debian [vim-addon-manager](http://packages.qa.debian.org/v/vim-addon-manager.html), do this: ```sh git clone https://github.com/preservim/vim-markdown.git cd vim-markdown sudo make install vim-addon-manager install markdown ``` If you are not using any package manager, download the [tarball](https://github.com/preservim/vim-markdown/archive/master.tar.gz) and do this: ```sh cd ~/.vim tar --strip=1 -zxf vim-markdown-master.tar.gz ``` ## Basic usage ### Folding Folding is enabled for headers by default. The following commands are useful to open and close folds: - `zr`: reduces fold level throughout the buffer - `zR`: opens all folds - `zm`: increases fold level throughout the buffer - `zM`: folds everything all the way - `za`: open a fold your cursor is on - `zA`: open a fold your cursor is on recursively - `zc`: close a fold your cursor is on - `zC`: close a fold your cursor is on recursively [Options](#options) are available to disable folding or change folding style. Try `:help fold-expr` and `:help fold-commands` for details. ### Concealing Concealing is set for some syntax such as bold, italic, code block and link. Concealing lets you conceal text with other text. The actual source text is not modified. If you put your cursor on the concealed line, the conceal goes away. [Options](#options) are available to disable or change concealing. Try `:help concealcursor` and `:help conceallevel` for details. ## Options ### Disable Folding - `g:vim_markdown_folding_disabled` Add the following line to your `.vimrc` to disable the folding configuration: let g:vim_markdown_folding_disabled = 1 This option only controls Vim Markdown specific folding configuration. To enable/disable folding use Vim's standard folding configuration. set [no]foldenable ### Change fold style - `g:vim_markdown_folding_style_pythonic` To fold in a style like [python-mode](https://github.com/klen/python-mode), add the following to your `.vimrc`: let g:vim_markdown_folding_style_pythonic = 1 `g:vim_markdown_folding_level` setting (default 1) is set to `foldlevel`. Thus level 1 heading which is served as a document title is expanded by default. - `g:vim_markdown_override_foldtext` To prevent foldtext from being set add the following to your `.vimrc`: let g:vim_markdown_override_foldtext = 0 ### Set header folding level - `g:vim_markdown_folding_level` Folding level is a number between 1 and 6. By default, if not specified, it is set to 1. let g:vim_markdown_folding_level = 6 Tip: it can be changed on the fly with: :let g:vim_markdown_folding_level = 1 :edit ### Disable Default Key Mappings - `g:vim_markdown_no_default_key_mappings` Add the following line to your `.vimrc` to disable default key mappings: let g:vim_markdown_no_default_key_mappings = 1 You can also map them by yourself with `<Plug>` mappings. ### Enable TOC window auto-fit - `g:vim_markdown_toc_autofit` Allow for the TOC window to auto-fit when it's possible for it to shrink. It never increases its default size (half screen), it only shrinks. let g:vim_markdown_toc_autofit = 1 ### Text emphasis restriction to single-lines - `g:vim_markdown_emphasis_multiline` By default text emphasis works across multiple lines until a closing token is found. However, it's possible to restrict text emphasis to a single line (i.e., for it to be applied a closing token must be found on the same line). To do so: let g:vim_markdown_emphasis_multiline = 0 ### Syntax Concealing - `g:vim_markdown_conceal` Concealing is set for some syntax. For example, conceal `[link text](link url)` as just `link text`. Also, `_italic_` and `*italic*` will conceal to just _italic_. Similarly `__bold__`, `**bold**`, `___italic bold___`, and `***italic bold***` will conceal to just __bold__, **bold**, ___italic bold___, and ***italic bold*** respectively. To enable conceal use Vim's standard conceal configuration. set conceallevel=2 To disable conceal regardless of `conceallevel` setting, add the following to your `.vimrc`: let g:vim_markdown_conceal = 0 To disable math conceal with LaTeX math syntax enabled, add the following to your `.vimrc`: let g:tex_conceal = "" let g:vim_markdown_math = 1 - `g:vim_markdown_conceal_code_blocks` Disabling conceal for code fences requires an additional setting: let g:vim_markdown_conceal_code_blocks = 0 ### Fenced code block languages - `g:vim_markdown_fenced_languages` You can use filetype name as fenced code block languages for syntax highlighting. If you want to use different name from filetype, you can add it in your `.vimrc` like so: let g:vim_markdown_fenced_languages = ['csharp=cs'] This will cause the following to be highlighted using the `cs` filetype syntax. ```csharp ... ``` Default is `['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']`. ### Follow named anchors - `g:vim_markdown_follow_anchor` This feature allows the `ge` command to follow named anchors in links of the form `file#anchor` or just `#anchor`, where file may omit the `.md` extension as usual. Two variables control its operation: let g:vim_markdown_follow_anchor = 1 This tells vim-markdown whether to attempt to follow a named anchor in a link or not. When it is 1, and only if a link can be split in two parts by the pattern '#', then the first part is interpreted as the file and the second one as the named anchor. This also includes urls of the form `#anchor`, for which the first part is considered empty, meaning that the target file is the current one. After the file is opened, the anchor will be searched. Default is `0`. - `g:vim_markdown_anchorexpr` let g:vim_markdown_anchorexpr = "'<<'.v:anchor.'>>'" This expression will be evaluated substituting `v:anchor` with a quoted string that contains the anchor to visit. The result of the evaluation will become the real anchor to search in the target file. This is useful in order to convert anchors of the form, say, `my-section-title` to searches of the form `My Section Title` or `<<my-section-title>>`. Default is `''`. ### Syntax extensions The following options control which syntax extensions will be turned on. They are off by default. #### LaTeX math - `g:vim_markdown_math` Used as `$x^2$`, `$$x^2$$`, escapable as `\$x\$` and `\$\$x\$\$`. let g:vim_markdown_math = 1 #### YAML Front Matter - `g:vim_markdown_frontmatter` Highlight YAML front matter as used by Jekyll or [Hugo](https://gohugo.io/content/front-matter/). let g:vim_markdown_frontmatter = 1 #### TOML Front Matter - `g:vim_markdown_toml_frontmatter` Highlight TOML front matter as used by [Hugo](https://gohugo.io/content/front-matter/). let g:vim_markdown_toml_frontmatter = 1 #### JSON Front Matter - `g:vim_markdown_json_frontmatter` Highlight JSON front matter as used by [Hugo](https://gohugo.io/content/front-matter/). let g:vim_markdown_json_frontmatter = 1 #### Strikethrough - `g:vim_markdown_strikethrough` Strikethrough uses two tildes. `~~Scratch this.~~` let g:vim_markdown_strikethrough = 1 ### Adjust new list item indent - `g:vim_markdown_new_list_item_indent` You can adjust a new list indent. For example, you insert a single line like below: * item1 Then if you type `o` to insert new line in vim and type `* item2`, the result will be: * item1 * item2 vim-markdown automatically insert the indent. By default, the number of spaces of indent is 4. If you'd like to change the number as 2, just write: let g:vim_markdown_new_list_item_indent = 2 ### Do not require .md extensions for Markdown links - `g:vim_markdown_no_extensions_in_markdown` If you want to have a link like this `[link text](link-url)` and follow it for editing in vim using the `ge` command, but have it open the file "link-url.md" instead of the file "link-url", then use this option: let g:vim_markdown_no_extensions_in_markdown = 1 This is super useful for GitLab and GitHub wiki repositories. Normal behaviour would be that vim-markup required you to do this `[link text](link-url.md)`, but this is not how the Gitlab and GitHub wiki repositories work. So this option adds some consistency between the two. ### Auto-write when following link - `g:vim_markdown_autowrite` If you follow a link like this `[link text](link-url)` using the `ge` shortcut, this option will automatically save any edits you made before moving you: let g:vim_markdown_autowrite = 1 ### Change default file extension - `g:vim_markdown_auto_extension_ext` If you would like to use a file extension other than `.md` you may do so using the `vim_markdown_auto_extension_ext` variable: let g:vim_markdown_auto_extension_ext = 'txt' ### Do not automatically insert bulletpoints - `g:vim_markdown_auto_insert_bullets` Automatically inserting bulletpoints can lead to problems when wrapping text (see issue #232 for details), so it can be disabled: let g:vim_markdown_auto_insert_bullets = 0 In that case, you probably also want to set the new list item indent to 0 as well, or you will have to remove an indent each time you add a new list item: let g:vim_markdown_new_list_item_indent = 0 ### Change how to open new files - `g:vim_markdown_edit_url_in` By default when following a link the target file will be opened in your current buffer. This behavior can change if you prefer using splits or tabs by using the `vim_markdown_edit_url_in` variable. Possible values are `tab`, `vsplit`, `hsplit`, `current` opening in a new tab, vertical split, horizontal split, and current buffer respectively. Defaults to current buffer if not set: let g:vim_markdown_edit_url_in = 'tab' ## Mappings The following work on normal and visual modes: - `gx`: open the link under the cursor in the same browser as the standard `gx` command. `<Plug>Markdown_OpenUrlUnderCursor` The standard `gx` is extended by allowing you to put your cursor anywhere inside a link. For example, all the following cursor positions will work: [Example](http://example.com) ^ ^ ^^ ^ ^ 1 2 34 5 6 <http://example.com> ^ ^ ^ 1 2 3 Known limitation: does not work for links that span multiple lines. - `ge`: open the link under the cursor in Vim for editing. Useful for relative markdown links. Falls back to `gf` with force editing, if not on a markdown link. `<Plug>Markdown_EditUrlUnderCursor` The rules for the cursor position are the same as the `gx` command. - `]]`: go to next header. `<Plug>Markdown_MoveToNextHeader` - `[[`: go to previous header. Contrast with `]h`. `<Plug>Markdown_MoveToPreviousHeader` - `][`: go to next sibling header if any. `<Plug>Markdown_MoveToNextSiblingHeader` - `[]`: go to previous sibling header if any. `<Plug>Markdown_MoveToPreviousSiblingHeader` - `]h`: go to Current header. `<Plug>Markdown_MoveToCurHeader` - `]u`: go to parent header (Up). `<Plug>Markdown_MoveToParentHeader` This plugin follows the recommended Vim plugin mapping interface, so to change the map `]u` to `asdf`, add to your `.vimrc`: map asdf <Plug>Markdown_MoveToParentHeader To disable a map use: map <Plug> <Plug>Markdown_MoveToParentHeader ## Commands The following requires `:filetype plugin on`. - `:HeaderDecrease`: Decrease level of all headers in buffer: `h2` to `h1`, `h3` to `h2`, etc. If range is given, only operate in the range. If an `h1` would be decreased, abort. For simplicity of implementation, Setex headers are converted to Atx. - `:HeaderIncrease`: Analogous to `:HeaderDecrease`, but increase levels instead. - `:SetexToAtx`: Convert all Setex style headers in buffer to Atx. If a range is given, e.g. hit `:` from visual mode, only operate on the range. - `:TableFormat`: Format the table under the cursor [like this](http://www.cirosantilli.com/markdown-style-guide/#tables). Requires [Tabular](https://github.com/godlygeek/tabular). The input table *must* already have a separator line as the second line of the table. That line only needs to contain the correct pipes `|`, nothing else is required. - `:Toc`: create a quickfix vertical window navigable table of contents with the headers. Hit `<Enter>` on a line to jump to the corresponding line of the markdown file. - `:Toch`: Same as `:Toc` but in an horizontal window. - `:Toct`: Same as `:Toc` but in a new tab. - `:Tocv`: Same as `:Toc` for symmetry with `:Toch` and `:Tocv`. - `:InsertToc`: Insert table of contents at the current line. An optional argument can be used to specify how many levels of headers to display in the table of content, e.g., to display up to and including `h3`, use `:InsertToc 3`. - `:InsertNToc`: Same as `:InsertToc`, but the format of `h2` headers in the table of contents is a numbered list, rather than a bulleted list. ## Credits The main contributors of vim-markdown are: - **Ben Williams** (A.K.A. **@plasticboy**). The original developer of vim-markdown. [Homepage](http://plasticboy.com/). If you feel that your name should be on this list, please make a pull request listing your contributions. ## License The MIT License (MIT) Copyright (c) 2012 Benjamin D. Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0707010000000A000041ED00000000000000000000000363314A4700000000000000000000000000000000000000000000002200000000vim-markdown-2.0.0+20220926/after0707010000000B000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/after/ftplugin0707010000000C000081A400000000000000000000000163314A4700001B8F000000000000000000000000000000000000003800000000vim-markdown-2.0.0+20220926/after/ftplugin/markdown.vim" vim: ts=4 sw=4: " folding for Markdown headers, both styles (atx- and setex-) " http://daringfireball.net/projects/markdown/syntax#header " " this code can be placed in file " $HOME/.vim/after/ftplugin/markdown.vim " " original version from Steve Losh's gist: https://gist.github.com/1038710 function! s:is_mkdCode(lnum) let name = synIDattr(synID(a:lnum, 1, 0), 'name') return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)') endfunction if get(g:, 'vim_markdown_folding_style_pythonic', 0) function! Foldexpr_markdown(lnum) let l1 = getline(a:lnum) "~~~~~ keep track of fenced code blocks ~~~~~ "If we hit a code block fence if l1 =~# '````*' || l1 =~# '\~\~\~\~*' " toggle the variable that says if we're in a code block if b:fenced_block == 0 let b:fenced_block = 1 elseif b:fenced_block == 1 let b:fenced_block = 0 endif " else, if we're caring about front matter elseif g:vim_markdown_frontmatter == 1 " if we're in front matter and not on line 1 if b:front_matter == 1 && a:lnum > 2 let l0 = getline(a:lnum-1) " if the previous line fenced front matter if l0 ==# '---' " we must not be in front matter let b:front_matter = 0 endif " else, if we're on line one elseif a:lnum == 1 " if we hit a front matter fence if l1 ==# '---' " we're in the front matter let b:front_matter = 1 endif endif endif " if we're in a code block or front matter if b:fenced_block ==# 1 || b:front_matter ==# 1 if a:lnum ==# 1 " fold any 'preamble' return '>1' else " keep previous foldlevel return '=' endif endif let l2 = getline(a:lnum+1) " if the next line starts with two or more '=' " and is not code if l2 =~# '^==\+\s*' && !s:is_mkdCode(a:lnum+1) " next line is underlined (level 1) return '>0' " else, if the nex line starts with two or more '-' " but is not comment closer (-->) " and is not code elseif l2 =~# '^--\+\s*$' && !s:is_mkdCode(a:lnum+1) " next line is underlined (level 2) return '>1' endif "if we're on a non-code line starting with a pound sign if l1 =~# '^#' && !s:is_mkdCode(a:lnum) " set the fold level to the number of hashes -1 " return '>'.(matchend(l1, '^#\+') - 1) " set the fold level to the number of hashes return '>'.(matchend(l1, '^#\+')) " else, if we're on line 1 elseif a:lnum == 1 " fold any 'preamble' return '>1' else " keep previous foldlevel return '=' endif endfunction function! Foldtext_markdown() let line = getline(v:foldstart) let has_numbers = &number || &relativenumber let nucolwidth = &foldcolumn + has_numbers * &numberwidth let windowwidth = winwidth(0) - nucolwidth - 6 let foldedlinecount = v:foldend - v:foldstart let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) let line = substitute(line, '\%("""\|''''''\)', '', '') let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + 1 return line . ' ' . repeat('-', fillcharcount) . ' ' . foldedlinecount endfunction else " vim_markdown_folding_style_pythonic == 0 function! Foldexpr_markdown(lnum) if (a:lnum == 1) let l0 = '' else let l0 = getline(a:lnum-1) endif " keep track of fenced code blocks if l0 =~# '````*' || l0 =~# '\~\~\~\~*' if b:fenced_block == 0 let b:fenced_block = 1 elseif b:fenced_block == 1 let b:fenced_block = 0 endif elseif g:vim_markdown_frontmatter == 1 if b:front_matter == 1 if l0 ==# '---' let b:front_matter = 0 endif elseif a:lnum == 2 if l0 ==# '---' let b:front_matter = 1 endif endif endif if b:fenced_block == 1 || b:front_matter == 1 " keep previous foldlevel return '=' endif let l2 = getline(a:lnum+1) if l2 =~# '^==\+\s*' && !s:is_mkdCode(a:lnum+1) " next line is underlined (level 1) return '>1' elseif l2 =~# '^--\+\s*$' && !s:is_mkdCode(a:lnum+1) " next line is underlined (level 2) if s:vim_markdown_folding_level >= 2 return '>1' else return '>2' endif endif let l1 = getline(a:lnum) if l1 =~# '^#' && !s:is_mkdCode(a:lnum) " fold level according to option if s:vim_markdown_folding_level == 1 || matchend(l1, '^#\+') > s:vim_markdown_folding_level if a:lnum == line('$') return matchend(l1, '^#\+') - 1 else return -1 endif else " headers are not folded return 0 endif endif if l0 =~# '^#' && !s:is_mkdCode(a:lnum-1) " previous line starts with hashes return '>'.matchend(l0, '^#\+') else " keep previous foldlevel return '=' endif endfunction endif let b:fenced_block = 0 let b:front_matter = 0 let s:vim_markdown_folding_level = get(g:, 'vim_markdown_folding_level', 1) function! s:MarkdownSetupFolding() if !get(g:, 'vim_markdown_folding_disabled', 0) if get(g:, 'vim_markdown_folding_style_pythonic', 0) if get(g:, 'vim_markdown_override_foldtext', 1) setlocal foldtext=Foldtext_markdown() endif endif setlocal foldexpr=Foldexpr_markdown(v:lnum) setlocal foldmethod=expr endif endfunction function! s:MarkdownSetupFoldLevel() if get(g:, 'vim_markdown_folding_style_pythonic', 0) " set default foldlevel execute 'setlocal foldlevel='.s:vim_markdown_folding_level endif endfunction call s:MarkdownSetupFoldLevel() call s:MarkdownSetupFolding() augroup Mkd " These autocmds need to be kept in sync with the autocmds calling " s:MarkdownRefreshSyntax in ftplugin/markdown.vim. autocmd BufWinEnter,BufWritePost <buffer> call s:MarkdownSetupFolding() autocmd InsertEnter,InsertLeave <buffer> call s:MarkdownSetupFolding() autocmd CursorHold,CursorHoldI <buffer> call s:MarkdownSetupFolding() augroup END 0707010000000D000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002000000000vim-markdown-2.0.0+20220926/doc0707010000000E000081A400000000000000000000000163314A47000067D3000000000000000000000000000000000000003100000000vim-markdown-2.0.0+20220926/doc/vim-markdown.txt*vim-markdown* Vim Markdown =============================================================================== Contents ~ 1. Introduction |vim-markdown-introduction| 2. Installation |vim-markdown-installation| 3. Basic usage |vim-markdown-basic-usage| 1. Folding |vim-markdown-folding| 2. Concealing |vim-markdown-concealing| 4. Options |vim-markdown-options| 1. Disable Folding |vim-markdown-disable-folding| 2. Change fold style |vim-markdown-change-fold-style| 3. Set header folding level |vim-markdown-set-header-folding-level| 4. Disable Default Key Mappings |vim-markdown-disable-default-key-mappings| 5. Enable TOC window auto-fit |vim-markdown-enable-toc-window-auto-fit| 6. Text emphasis restriction to single-lines |vim-markdown-text-emphasis-restriction-to-single-lines| 7. Syntax Concealing |vim-markdown-syntax-concealing| 8. Fenced code block languages |vim-markdown-fenced-code-block-languages| 9. Follow named anchors |vim-markdown-follow-named-anchors| 10. Syntax extensions |vim-markdown-syntax-extensions| 1. LaTeX math |vim-markdown-latex-math| 2. YAML Front Matter |vim-markdown-yaml-front-matter| 3. TOML Front Matter |vim-markdown-toml-front-matter| 4. JSON Front Matter |vim-markdown-json-front-matter| 5. Strikethrough |vim-markdown-strikethrough| 11. Adjust new list item indent |vim-markdown-adjust-new-list-item-indent| 12. Do not require .md extensions for Markdown links |vim-markdown-do-not-require-.md-extensions-for-markdown-links| 13. Auto-write when following link |vim-markdown-auto-write-when-following-link| 14. Change default file extension |vim-markdown-change-default-file-extension| 15. Do not automatically insert bulletpoints |vim-markdown-do-not-automatically-insert-bulletpoints| 16. Change how to open new files |vim-markdown-change-how-to-open-new-files| 5. Mappings |vim-markdown-mappings| 6. Commands |vim-markdown-commands| 7. Credits |vim-markdown-credits| 8. License |vim-markdown-license| 9. References |vim-markdown-references| =============================================================================== *vim-markdown-introduction* Introduction ~ Syntax highlighting, matching rules and mappings for the original Markdown [1] and extensions. =============================================================================== *vim-markdown-installation* Installation ~ If you use Vundle [2], add the following lines to your '~/.vimrc': > Plugin 'godlygeek/tabular' Plugin 'preservim/vim-markdown' < The 'tabular' plugin must come _before_ 'vim-markdown'. Then run inside Vim: > :so ~/.vimrc :PluginInstall < If you use Pathogen [3], do this: > cd ~/.vim/bundle git clone https://github.com/preservim/vim-markdown.git < To install without Pathogen using the Debian vim-addon-manager [4], do this: > git clone https://github.com/preservim/vim-markdown.git cd vim-markdown sudo make install vim-addon-manager install markdown < If you are not using any package manager, download the tarball [5] and do this: > cd ~/.vim tar --strip=1 -zxf vim-markdown-master.tar.gz < =============================================================================== *vim-markdown-basic-usage* Basic usage ~ ------------------------------------------------------------------------------- *vim-markdown-folding* Folding ~ Folding is enabled for headers by default. The following commands are useful to open and close folds: *vim-markdown-zr* - 'zr': reduces fold level throughout the buffer *vim-markdown-zR* - 'zR': opens all folds *vim-markdown-zm* - 'zm': increases fold level throughout the buffer *vim-markdown-zM* - 'zM': folds everything all the way *vim-markdown-za* - 'za': open a fold your cursor is on *vim-markdown-zA* - 'zA': open a fold your cursor is on recursively *vim-markdown-zc* - 'zc': close a fold your cursor is on *vim-markdown-zC* - 'zC': close a fold your cursor is on recursively Options are available to disable folding or change folding style. Try ':help fold-expr' and ':help fold-commands' for details. ------------------------------------------------------------------------------- *vim-markdown-concealing* Concealing ~ Concealing is set for some syntax such as bold, italic, code block and link. Concealing lets you conceal text with other text. The actual source text is not modified. If you put your cursor on the concealed line, the conceal goes away. Options are available to disable or change concealing. Try ':help concealcursor' and ':help conceallevel' for details. =============================================================================== *vim-markdown-options* Options ~ ------------------------------------------------------------------------------- *vim-markdown-disable-folding* Disable Folding ~ *g:vim_markdown_folding_disabled* - 'g:vim_markdown_folding_disabled' Add the following line to your '.vimrc' to disable the folding configuration: > let g:vim_markdown_folding_disabled = 1 < This option only controls Vim Markdown specific folding configuration. To enable/disable folding use Vim's standard folding configuration. > set [no]foldenable < ------------------------------------------------------------------------------- *vim-markdown-change-fold-style* Change fold style ~ *g:vim_markdown_folding_style_pythonic* - 'g:vim_markdown_folding_style_pythonic' To fold in a style like python-mode [6], add the following to your '.vimrc': > let g:vim_markdown_folding_style_pythonic = 1 < 'g:vim_markdown_folding_level' setting (default 1) is set to 'foldlevel'. Thus level 1 heading which is served as a document title is expanded by default. *g:vim_markdown_override_foldtext* - 'g:vim_markdown_override_foldtext' To prevent foldtext from being set add the following to your '.vimrc': > let g:vim_markdown_override_foldtext = 0 < ------------------------------------------------------------------------------- *vim-markdown-set-header-folding-level* Set header folding level ~ *g:vim_markdown_folding_level* - 'g:vim_markdown_folding_level' Folding level is a number between 1 and 6. By default, if not specified, it is set to 1. > let g:vim_markdown_folding_level = 6 < Tip: it can be changed on the fly with: > :let g:vim_markdown_folding_level = 1 :edit < ------------------------------------------------------------------------------- *vim-markdown-disable-default-key-mappings* Disable Default Key Mappings ~ *g:vim_markdown_no_default_key_mappings* - 'g:vim_markdown_no_default_key_mappings' Add the following line to your '.vimrc' to disable default key mappings: > let g:vim_markdown_no_default_key_mappings = 1 < You can also map them by yourself with '<Plug>' mappings. ------------------------------------------------------------------------------- *vim-markdown-enable-toc-window-auto-fit* Enable TOC window auto-fit ~ *g:vim_markdown_toc_autofit* - 'g:vim_markdown_toc_autofit' Allow for the TOC window to auto-fit when it's possible for it to shrink. It never increases its default size (half screen), it only shrinks. > let g:vim_markdown_toc_autofit = 1 < ------------------------------------------------------------------------------- *vim-markdown-text-emphasis-restriction-to-single-lines* Text emphasis restriction to single-lines ~ *g:vim_markdown_emphasis_multiline* - 'g:vim_markdown_emphasis_multiline' By default text emphasis works across multiple lines until a closing token is found. However, it's possible to restrict text emphasis to a single line (i.e., for it to be applied a closing token must be found on the same line). To do so: > let g:vim_markdown_emphasis_multiline = 0 < ------------------------------------------------------------------------------- *vim-markdown-syntax-concealing* Syntax Concealing ~ *g:vim_markdown_conceal* - 'g:vim_markdown_conceal' Concealing is set for some syntax. For example, conceal '[link text](link url)' as just 'link text'. Also, '_italic_' and '*italic*' will conceal to just _italic_. Similarly '__bold__', '**bold**', '___italic bold___', and '***italic bold***' will conceal to just **bold**, **bold**, **_italic bold_**, and **_italic bold_** respectively. To enable conceal use Vim's standard conceal configuration. > set conceallevel=2 < To disable conceal regardless of 'conceallevel' setting, add the following to your '.vimrc': > let g:vim_markdown_conceal = 0 < To disable math conceal with LaTeX math syntax enabled, add the following to your '.vimrc': > let g:tex_conceal = "" let g:vim_markdown_math = 1 < *g:vim_markdown_conceal_code_blocks* - 'g:vim_markdown_conceal_code_blocks' Disabling conceal for code fences requires an additional setting: > let g:vim_markdown_conceal_code_blocks = 0 < ------------------------------------------------------------------------------- *vim-markdown-fenced-code-block-languages* Fenced code block languages ~ *g:vim_markdown_fenced_languages* - 'g:vim_markdown_fenced_languages' You can use filetype name as fenced code block languages for syntax highlighting. If you want to use different name from filetype, you can add it in your '.vimrc' like so: > let g:vim_markdown_fenced_languages = ['csharp=cs'] < This will cause the following to be highlighted using the 'cs' filetype syntax. > ```csharp ... ``` < Default is "['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']". ------------------------------------------------------------------------------- *vim-markdown-follow-named-anchors* Follow named anchors ~ *g:vim_markdown_follow_anchor* - 'g:vim_markdown_follow_anchor' This feature allows the 'ge' command to follow named anchors in links of the form 'file#anchor' or just '#anchor', where file may omit the '.md' extension as usual. Two variables control its operation: > let g:vim_markdown_follow_anchor = 1 < This tells vim-markdown whether to attempt to follow a named anchor in a link or not. When it is 1, and only if a link can be split in two parts by the pattern '#', then the first part is interpreted as the file and the second one as the named anchor. This also includes urls of the form '#anchor', for which the first part is considered empty, meaning that the target file is the current one. After the file is opened, the anchor will be searched. Default is '0'. *g:vim_markdown_anchorexpr* - 'g:vim_markdown_anchorexpr' > let g:vim_markdown_anchorexpr = "'<<'.v:anchor.'>>'" < This expression will be evaluated substituting 'v:anchor' with a quoted string that contains the anchor to visit. The result of the evaluation will become the real anchor to search in the target file. This is useful in order to convert anchors of the form, say, 'my-section-title' to searches of the form 'My Section Title' or '<<my-section-title>>'. Default is "''". ------------------------------------------------------------------------------- *vim-markdown-syntax-extensions* Syntax extensions ~ The following options control which syntax extensions will be turned on. They are off by default. ------------------------------------------------------------------------------- *vim-markdown-latex-math* LaTeX math ~ *g:vim_markdown_math* - 'g:vim_markdown_math' Used as '$x^2$', '$$x^2$$', escapable as '\$x\$' and '\$\$x\$\$'. > let g:vim_markdown_math = 1 < ------------------------------------------------------------------------------- *vim-markdown-yaml-front-matter* YAML Front Matter ~ *g:vim_markdown_frontmatter* - 'g:vim_markdown_frontmatter' Highlight YAML front matter as used by Jekyll or Hugo [7]. > let g:vim_markdown_frontmatter = 1 < ------------------------------------------------------------------------------- *vim-markdown-toml-front-matter* TOML Front Matter ~ *g:vim_markdown_toml_frontmatter* - 'g:vim_markdown_toml_frontmatter' Highlight TOML front matter as used by Hugo [7]. TOML syntax highlight requires vim-toml [8]. > let g:vim_markdown_toml_frontmatter = 1 < ------------------------------------------------------------------------------- *vim-markdown-json-front-matter* JSON Front Matter ~ *g:vim_markdown_json_frontmatter* - 'g:vim_markdown_json_frontmatter' Highlight JSON front matter as used by Hugo [7]. JSON syntax highlight requires vim-json [9]. > let g:vim_markdown_json_frontmatter = 1 < ------------------------------------------------------------------------------- *vim-markdown-strikethrough* Strikethrough ~ *g:vim_markdown_strikethrough* - 'g:vim_markdown_strikethrough' Strikethrough uses two tildes. '~~Scratch this.~~' > let g:vim_markdown_strikethrough = 1 < ------------------------------------------------------------------------------- *vim-markdown-adjust-new-list-item-indent* Adjust new list item indent ~ *g:vim_markdown_new_list_item_indent* - 'g:vim_markdown_new_list_item_indent' You can adjust a new list indent. For example, you insert a single line like below: > * item1 < Then if you type 'o' to insert new line in vim and type '* item2', the result will be: > * item1 * item2 < vim-markdown automatically insert the indent. By default, the number of spaces of indent is 4. If you'd like to change the number as 2, just write: > let g:vim_markdown_new_list_item_indent = 2 < ------------------------------------------------------------------------------- *vim-markdown-do-not-require-.md-extensions-for-markdown-links* Do not require .md extensions for Markdown links ~ *g:vim_markdown_no_extensions_in_markdown* - 'g:vim_markdown_no_extensions_in_markdown' If you want to have a link like this '[link text](link-url)' and follow it for editing in vim using the 'ge' command, but have it open the file "link- url.md" instead of the file "link-url", then use this option: > let g:vim_markdown_no_extensions_in_markdown = 1 < This is super useful for GitLab and GitHub wiki repositories. Normal behaviour would be that vim-markup required you to do this '[link text](link-url.md)', but this is not how the Gitlab and GitHub wiki repositories work. So this option adds some consistency between the two. ------------------------------------------------------------------------------- *vim-markdown-auto-write-when-following-link* Auto-write when following link ~ *g:vim_markdown_autowrite* - 'g:vim_markdown_autowrite' If you follow a link like this '[link text](link-url)' using the 'ge' shortcut, this option will automatically save any edits you made before moving you: > let g:vim_markdown_autowrite = 1 < ------------------------------------------------------------------------------- *vim-markdown-change-default-file-extension* Change default file extension ~ *g:vim_markdown_auto_extension_ext* - 'g:vim_markdown_auto_extension_ext' If you would like to use a file extension other than '.md' you may do so using the 'vim_markdown_auto_extension_ext' variable: > let g:vim_markdown_auto_extension_ext = 'txt' < ------------------------------------------------------------------------------- *vim-markdown-do-not-automatically-insert-bulletpoints* Do not automatically insert bulletpoints ~ *g:vim_markdown_auto_insert_bullets* - 'g:vim_markdown_auto_insert_bullets' Automatically inserting bulletpoints can lead to problems when wrapping text (see issue #232 for details), so it can be disabled: > let g:vim_markdown_auto_insert_bullets = 0 < In that case, you probably also want to set the new list item indent to 0 as well, or you will have to remove an indent each time you add a new list item: > let g:vim_markdown_new_list_item_indent = 0 < ------------------------------------------------------------------------------- *vim-markdown-change-how-to-open-new-files* Change how to open new files ~ *g:vim_markdown_edit_url_in* - 'g:vim_markdown_edit_url_in' By default when following a link the target file will be opened in your current buffer. This behavior can change if you prefer using splits or tabs by using the 'vim_markdown_edit_url_in' variable. Possible values are 'tab', 'vsplit', 'hsplit', 'current' opening in a new tab, vertical split, horizontal split, and current buffer respectively. Defaults to current buffer if not set: > let g:vim_markdown_edit_url_in = 'tab' < =============================================================================== *vim-markdown-mappings* Mappings ~ The following work on normal and visual modes: *vim-markdown-gx* - 'gx': open the link under the cursor in the same browser as the standard 'gx' command. '<Plug>Markdown_OpenUrlUnderCursor' The standard 'gx' is extended by allowing you to put your cursor anywhere inside a link. For example, all the following cursor positions will work: > [Example](http://example.com) ^ ^ ^^ ^ ^ 1 2 34 5 6 <http://example.com> ^ ^ ^ 1 2 3 < Known limitation: does not work for links that span multiple lines. *vim-markdown-ge* - 'ge': open the link under the cursor in Vim for editing. Useful for relative markdown links. '<Plug>Markdown_EditUrlUnderCursor' The rules for the cursor position are the same as the 'gx' command. *vim-markdown-]]* - ']]': go to next header. '<Plug>Markdown_MoveToNextHeader' *vim-markdown-[[* - '[[': go to previous header. Contrast with ']h'. '<Plug>Markdown_MoveToPreviousHeader' *vim-markdown-][* - '][': go to next sibling header if any. '<Plug>Markdown_MoveToNextSiblingHeader' *vim-markdown-[]* - '[]': go to previous sibling header if any. '<Plug>Markdown_MoveToPreviousSiblingHeader' *vim-markdown-]h* - ']h': go to Current header. '<Plug>Markdown_MoveToCurHeader' *vim-markdown-]u* - ']u': go to parent header (Up). '<Plug>Markdown_MoveToParentHeader' This plugin follows the recommended Vim plugin mapping interface, so to change the map ']u' to 'asdf', add to your '.vimrc': > map asdf <Plug>Markdown_MoveToParentHeader < To disable a map use: > map <Plug> <Plug>Markdown_MoveToParentHeader < =============================================================================== *vim-markdown-commands* Commands ~ The following requires ':filetype plugin on'. *:HeaderDecrease* - ':HeaderDecrease': Decrease level of all headers in buffer: 'h2' to 'h1', 'h3' to 'h2', etc. If range is given, only operate in the range. If an 'h1' would be decreased, abort. For simplicity of implementation, Setex headers are converted to Atx. *:HeaderIncrease* - ':HeaderIncrease': Analogous to ':HeaderDecrease', but increase levels instead. *:SetexToAtx* - ':SetexToAtx': Convert all Setex style headers in buffer to Atx. If a range is given, e.g. hit ':' from visual mode, only operate on the range. *:TableFormat* - ':TableFormat': Format the table under the cursor like this [10]. Requires Tabular [11]. The input table _must_ already have a separator line as the second line of the table. That line only needs to contain the correct pipes '|', nothing else is required. *:Toc* - ':Toc': create a quickfix vertical window navigable table of contents with the headers. Hit '<Enter>' on a line to jump to the corresponding line of the markdown file. *:Toch* - ':Toch': Same as ':Toc' but in an horizontal window. *:Toct* - ':Toct': Same as ':Toc' but in a new tab. *:Tocv* - ':Tocv': Same as ':Toc' for symmetry with ':Toch' and ':Tocv'. =============================================================================== *vim-markdown-credits* Credits ~ The main contributors of vim-markdown are: - **Ben Williams** (A.K.A. **plasticboy**). The original developer of vim- markdown. Homepage [12]. If you feel that your name should be on this list, please make a pull request listing your contributions. =============================================================================== *vim-markdown-license* License ~ The MIT License (MIT) Copyright (c) 2012 Benjamin D. Williams Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================================================== *vim-markdown-references* References ~ [1] http://daringfireball.net/projects/markdown/ [2] https://github.com/gmarik/vundle [3] https://github.com/tpope/vim-pathogen [4] http://packages.qa.debian.org/v/vim-addon-manager.html [5] https://github.com/preservim/vim-markdown/archive/master.tar.gz [6] https://github.com/klen/python-mode [7] https://gohugo.io/content/front-matter/ [8] https://github.com/cespare/vim-toml [9] https://github.com/elzr/vim-json [10] http://www.cirosantilli.com/markdown-style-guide/#tables [11] https://github.com/godlygeek/tabular [12] http://plasticboy.com/ vim: ft=help 0707010000000F000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002500000000vim-markdown-2.0.0+20220926/ftdetect07070100000010000081A400000000000000000000000163314A470000017D000000000000000000000000000000000000003200000000vim-markdown-2.0.0+20220926/ftdetect/markdown.vimif !has('patch-7.4.480') " Before this patch, vim used modula2 for .md. au! filetypedetect BufRead,BufNewFile *.md endif " vint: -ProhibitAutocmdWithNoGroup au BufRead,BufNewFile *.{md,mdx,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown au BufRead,BufNewFile *.{md,mdx,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown 07070100000011000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002500000000vim-markdown-2.0.0+20220926/ftplugin07070100000012000081A400000000000000000000000163314A470000715B000000000000000000000000000000000000003200000000vim-markdown-2.0.0+20220926/ftplugin/markdown.vim"TODO print messages when on visual mode. I only see VISUAL, not the messages. " Function interface phylosophy: " " - functions take arbitrary line numbers as parameters. " Current cursor line is only a suitable default parameter. " " - only functions that bind directly to user actions: " " - print error messages. " All intermediate functions limit themselves return `0` to indicate an error. " " - move the cursor. All other functions do not move the cursor. " " This is how you should view headers for the header mappings: " " |BUFFER " | " |Outside any header " | " a-+# a " | " |Inside a " | " a-+ " b-+## b " | " |inside b " | " b-+ " c-+### c " | " |Inside c " | " c-+ " d-|# d " | " |Inside d " | " d-+ " e-|e " |==== " | " |Inside e " | " e-+ " For each level, contains the regexp that matches at that level only. " let s:levelRegexpDict = { \ 1: '\v^(#[^#]@=|.+\n\=+$)', \ 2: '\v^(##[^#]@=|.+\n-+$)', \ 3: '\v^###[^#]@=', \ 4: '\v^####[^#]@=', \ 5: '\v^#####[^#]@=', \ 6: '\v^######[^#]@=' \ } " Maches any header level of any type. " " This could be deduced from `s:levelRegexpDict`, but it is more " efficient to have a single regexp for this. " let s:headersRegexp = '\v^(#|.+\n(\=+|-+)$)' " Returns the line number of the first header before `line`, called the " current header. " " If there is no current header, return `0`. " " @param a:1 The line to look the header of. Default value: `getpos('.')`. " function! s:GetHeaderLineNum(...) if a:0 == 0 let l:l = line('.') else let l:l = a:1 endif while(l:l > 0) if join(getline(l:l, l:l + 1), "\n") =~ s:headersRegexp return l:l endif let l:l -= 1 endwhile return 0 endfunction " - if inside a header goes to it. " Return its line number. " " - if on top level outside any headers, " print a warning " Return `0`. " function! s:MoveToCurHeader() let l:lineNum = s:GetHeaderLineNum() if l:lineNum !=# 0 call cursor(l:lineNum, 1) else echo 'outside any header' "normal! gg endif return l:lineNum endfunction " Move cursor to next header of any level. " " If there are no more headers, print a warning. " function! s:MoveToNextHeader() if search(s:headersRegexp, 'W') == 0 "normal! G echo 'no next header' endif endfunction " Move cursor to previous header (before current) of any level. " " If it does not exist, print a warning. " function! s:MoveToPreviousHeader() let l:curHeaderLineNumber = s:GetHeaderLineNum() let l:noPreviousHeader = 0 if l:curHeaderLineNumber <= 1 let l:noPreviousHeader = 1 else let l:previousHeaderLineNumber = s:GetHeaderLineNum(l:curHeaderLineNumber - 1) if l:previousHeaderLineNumber == 0 let l:noPreviousHeader = 1 else call cursor(l:previousHeaderLineNumber, 1) endif endif if l:noPreviousHeader echo 'no previous header' endif endfunction " - if line is inside a header, return the header level (h1 -> 1, h2 -> 2, etc.). " " - if line is at top level outside any headers, return `0`. " function! s:GetHeaderLevel(...) if a:0 == 0 let l:line = line('.') else let l:line = a:1 endif let l:linenum = s:GetHeaderLineNum(l:line) if l:linenum !=# 0 return s:GetLevelOfHeaderAtLine(l:linenum) else return 0 endif endfunction " Return list of headers and their levels. " function! s:GetHeaderList() let l:bufnr = bufnr('%') let l:fenced_block = 0 let l:front_matter = 0 let l:header_list = [] let l:vim_markdown_frontmatter = get(g:, 'vim_markdown_frontmatter', 0) for i in range(1, line('$')) let l:lineraw = getline(i) let l:l1 = getline(i+1) let l:line = substitute(l:lineraw, '#', "\\\#", 'g') " exclude lines in fenced code blocks if l:line =~# '````*' || l:line =~# '\~\~\~\~*' if l:fenced_block == 0 let l:fenced_block = 1 elseif l:fenced_block == 1 let l:fenced_block = 0 endif " exclude lines in frontmatters elseif l:vim_markdown_frontmatter == 1 if l:front_matter == 1 if l:line ==# '---' let l:front_matter = 0 endif elseif i == 1 if l:line ==# '---' let l:front_matter = 1 endif endif endif " match line against header regex if join(getline(i, i + 1), "\n") =~# s:headersRegexp && l:line =~# '^\S' let l:is_header = 1 else let l:is_header = 0 endif if l:is_header ==# 1 && l:fenced_block ==# 0 && l:front_matter ==# 0 " remove hashes from atx headers if match(l:line, '^#') > -1 let l:line = substitute(l:line, '\v^#*[ ]*', '', '') let l:line = substitute(l:line, '\v[ ]*#*$', '', '') endif " append line to list let l:level = s:GetHeaderLevel(i) let l:item = {'level': l:level, 'text': l:line, 'lnum': i, 'bufnr': bufnr} let l:header_list = l:header_list + [l:item] endif endfor return l:header_list endfunction " Returns the level of the header at the given line. " " If there is no header at the given line, returns `0`. " function! s:GetLevelOfHeaderAtLine(linenum) let l:lines = join(getline(a:linenum, a:linenum + 1), "\n") for l:key in keys(s:levelRegexpDict) if l:lines =~ get(s:levelRegexpDict, l:key) return l:key endif endfor return 0 endfunction " Move cursor to parent header of the current header. " " If it does not exit, print a warning and do nothing. " function! s:MoveToParentHeader() let l:linenum = s:GetParentHeaderLineNumber() if l:linenum != 0 call setpos("''", getpos('.')) call cursor(l:linenum, 1) else echo 'no parent header' endif endfunction " Return the line number of the parent header of line `line`. " " If it has no parent, return `0`. " function! s:GetParentHeaderLineNumber(...) if a:0 == 0 let l:line = line('.') else let l:line = a:1 endif let l:level = s:GetHeaderLevel(l:line) if l:level > 1 let l:linenum = s:GetPreviousHeaderLineNumberAtLevel(l:level - 1, l:line) return l:linenum endif return 0 endfunction " Return the line number of the previous header of given level. " in relation to line `a:1`. If not given, `a:1 = getline()` " " `a:1` line is included, and this may return the current header. " " If none return 0. " function! s:GetNextHeaderLineNumberAtLevel(level, ...) if a:0 < 1 let l:line = line('.') else let l:line = a:1 endif let l:l = l:line while(l:l <= line('$')) if join(getline(l:l, l:l + 1), "\n") =~ get(s:levelRegexpDict, a:level) return l:l endif let l:l += 1 endwhile return 0 endfunction " Return the line number of the previous header of given level. " in relation to line `a:1`. If not given, `a:1 = getline()` " " `a:1` line is included, and this may return the current header. " " If none return 0. " function! s:GetPreviousHeaderLineNumberAtLevel(level, ...) if a:0 == 0 let l:line = line('.') else let l:line = a:1 endif let l:l = l:line while(l:l > 0) if join(getline(l:l, l:l + 1), "\n") =~ get(s:levelRegexpDict, a:level) return l:l endif let l:l -= 1 endwhile return 0 endfunction " Move cursor to next sibling header. " " If there is no next siblings, print a warning and don't move. " function! s:MoveToNextSiblingHeader() let l:curHeaderLineNumber = s:GetHeaderLineNum() let l:curHeaderLevel = s:GetLevelOfHeaderAtLine(l:curHeaderLineNumber) let l:curHeaderParentLineNumber = s:GetParentHeaderLineNumber() let l:nextHeaderSameLevelLineNumber = s:GetNextHeaderLineNumberAtLevel(l:curHeaderLevel, l:curHeaderLineNumber + 1) let l:noNextSibling = 0 if l:nextHeaderSameLevelLineNumber == 0 let l:noNextSibling = 1 else let l:nextHeaderSameLevelParentLineNumber = s:GetParentHeaderLineNumber(l:nextHeaderSameLevelLineNumber) if l:curHeaderParentLineNumber == l:nextHeaderSameLevelParentLineNumber call cursor(l:nextHeaderSameLevelLineNumber, 1) else let l:noNextSibling = 1 endif endif if l:noNextSibling echo 'no next sibling header' endif endfunction " Move cursor to previous sibling header. " " If there is no previous siblings, print a warning and do nothing. " function! s:MoveToPreviousSiblingHeader() let l:curHeaderLineNumber = s:GetHeaderLineNum() let l:curHeaderLevel = s:GetLevelOfHeaderAtLine(l:curHeaderLineNumber) let l:curHeaderParentLineNumber = s:GetParentHeaderLineNumber() let l:previousHeaderSameLevelLineNumber = s:GetPreviousHeaderLineNumberAtLevel(l:curHeaderLevel, l:curHeaderLineNumber - 1) let l:noPreviousSibling = 0 if l:previousHeaderSameLevelLineNumber == 0 let l:noPreviousSibling = 1 else let l:previousHeaderSameLevelParentLineNumber = s:GetParentHeaderLineNumber(l:previousHeaderSameLevelLineNumber) if l:curHeaderParentLineNumber == l:previousHeaderSameLevelParentLineNumber call cursor(l:previousHeaderSameLevelLineNumber, 1) else let l:noPreviousSibling = 1 endif endif if l:noPreviousSibling echo 'no previous sibling header' endif endfunction function! s:Toc(...) if a:0 > 0 let l:window_type = a:1 else let l:window_type = 'vertical' endif let l:cursor_line = line('.') let l:cursor_header = 0 let l:header_list = s:GetHeaderList() let l:indented_header_list = [] if len(l:header_list) == 0 echom 'Toc: No headers.' return endif let l:header_max_len = 0 let l:vim_markdown_toc_autofit = get(g:, 'vim_markdown_toc_autofit', 0) for h in l:header_list " set header number of the cursor position if l:cursor_header == 0 let l:header_line = h.lnum if l:header_line == l:cursor_line let l:cursor_header = index(l:header_list, h) + 1 elseif l:header_line > l:cursor_line let l:cursor_header = index(l:header_list, h) endif endif " indent header based on level let l:text = repeat(' ', h.level-1) . h.text " keep track of the longest header size (heading level + title) let l:total_len = strdisplaywidth(l:text) if l:total_len > l:header_max_len let l:header_max_len = l:total_len endif " append indented line to list let l:item = {'lnum': h.lnum, 'text': l:text, 'valid': 1, 'bufnr': h.bufnr, 'col': 1} let l:indented_header_list = l:indented_header_list + [l:item] endfor call setloclist(0, l:indented_header_list) if l:window_type ==# 'horizontal' lopen elseif l:window_type ==# 'vertical' vertical lopen " auto-fit toc window when possible to shrink it if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1 " header_max_len + 1 space for first header + 3 spaces for line numbers execute 'vertical resize ' . (l:header_max_len + 1 + 3) else execute 'vertical resize ' . (&columns/2) endif elseif l:window_type ==# 'tab' tab lopen else lopen endif setlocal modifiable for i in range(1, line('$')) " this is the location-list data for the current item let d = getloclist(0)[i-1] call setline(i, d.text) endfor setlocal nomodified setlocal nomodifiable execute 'normal! ' . l:cursor_header . 'G' endfunction function! s:InsertToc(format, ...) if a:0 > 0 if type(a:1) != type(0) echohl WarningMsg echomsg '[vim-markdown] Invalid argument, must be an integer >= 2.' echohl None return endif let l:max_level = a:1 if l:max_level < 2 echohl WarningMsg echomsg '[vim-markdown] Maximum level cannot be smaller than 2.' echohl None return endif else let l:max_level = 0 endif let l:toc = [] let l:header_list = s:GetHeaderList() if len(l:header_list) == 0 echom 'InsertToc: No headers.' return endif if a:format ==# 'numbers' let l:h2_count = 0 for header in l:header_list if header.level == 2 let l:h2_count += 1 endif endfor let l:max_h2_number_len = strlen(string(l:h2_count)) else let l:max_h2_number_len = 0 endif let l:h2_count = 0 for header in l:header_list let l:level = header.level if l:level == 1 " skip level-1 headers continue elseif l:max_level != 0 && l:level > l:max_level " skip unwanted levels continue elseif l:level == 2 " list of level-2 headers can be bullets or numbers if a:format ==# 'bullets' let l:indent = '' let l:marker = '* ' else let l:h2_count += 1 let l:number_len = strlen(string(l:h2_count)) let l:indent = repeat(' ', l:max_h2_number_len - l:number_len) let l:marker = l:h2_count . '. ' endif else let l:indent = repeat(' ', l:max_h2_number_len + 2 * (l:level - 2)) let l:marker = '* ' endif let l:text = '[' . header.text . ']' let l:link = '(#' . substitute(tolower(header.text), '\v[ ]+', '-', 'g') . ')' let l:line = l:indent . l:marker . l:text . l:link let l:toc = l:toc + [l:line] endfor call append(line('.'), l:toc) endfunction " Convert Setex headers in range `line1 .. line2` to Atx. " " Return the number of conversions. " function! s:SetexToAtx(line1, line2) let l:originalNumLines = line('$') execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n\=+$/# \1/' execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n-+$/## \1/' return l:originalNumLines - line('$') endfunction " If `a:1` is 0, decrease the level of all headers in range `line1 .. line2`. " " Otherwise, increase the level. `a:1` defaults to `0`. " function! s:HeaderDecrease(line1, line2, ...) if a:0 > 0 let l:increase = a:1 else let l:increase = 0 endif if l:increase let l:forbiddenLevel = 6 let l:replaceLevels = [5, 1] let l:levelDelta = 1 else let l:forbiddenLevel = 1 let l:replaceLevels = [2, 6] let l:levelDelta = -1 endif for l:line in range(a:line1, a:line2) if join(getline(l:line, l:line + 1), "\n") =~ s:levelRegexpDict[l:forbiddenLevel] echomsg 'There is an h' . l:forbiddenLevel . ' at line ' . l:line . '. Aborting.' return endif endfor let l:numSubstitutions = s:SetexToAtx(a:line1, a:line2) let l:flags = (&gdefault ? '' : 'g') for l:level in range(replaceLevels[0], replaceLevels[1], -l:levelDelta) execute 'silent! ' . a:line1 . ',' . (a:line2 - l:numSubstitutions) . 'substitute/' . s:levelRegexpDict[l:level] . '/' . repeat('#', l:level + l:levelDelta) . '/' . l:flags endfor endfunction " Format table under cursor. " " Depends on Tabularize. " function! s:TableFormat() let l:pos = getpos('.') normal! { " Search instead of `normal! j` because of the table at beginning of file edge case. call search('|') normal! j " Remove everything that is not a pipe, colon or hyphen next to a colon othewise " well formated tables would grow because of addition of 2 spaces on the separator " line by Tabularize /|. let l:flags = (&gdefault ? '' : 'g') execute 's/\(:\@<!-:\@!\|[^|:-]\)//e' . l:flags execute 's/--/-/e' . l:flags Tabularize /| " Move colons for alignment to left or right side of the cell. execute 's/:\( \+\)|/\1:|/e' . l:flags execute 's/|\( \+\):/|:\1/e' . l:flags execute 's/|:\?\zs[ -]\+\ze:\?|/\=repeat("-", len(submatch(0)))/' . l:flags call setpos('.', l:pos) endfunction " Wrapper to do move commands in visual mode. " function! s:VisMove(f) norm! gv call function(a:f)() endfunction " Map in both normal and visual modes. " function! s:MapNormVis(rhs,lhs) execute 'nn <buffer><silent> ' . a:rhs . ' :call ' . a:lhs . '()<cr>' execute 'vn <buffer><silent> ' . a:rhs . ' <esc>:call <sid>VisMove(''' . a:lhs . ''')<cr>' endfunction " Parameters: " " - step +1 for right, -1 for left " " TODO: multiple lines. " function! s:FindCornerOfSyntax(lnum, col, step) let l:col = a:col let l:syn = synIDattr(synID(a:lnum, l:col, 1), 'name') while synIDattr(synID(a:lnum, l:col, 1), 'name') ==# l:syn let l:col += a:step endwhile return l:col - a:step endfunction " Return the next position of the given syntax name, " inclusive on the given position. " " TODO: multiple lines " function! s:FindNextSyntax(lnum, col, name) let l:col = a:col let l:step = 1 while synIDattr(synID(a:lnum, l:col, 1), 'name') !=# a:name let l:col += l:step endwhile return [a:lnum, l:col] endfunction function! s:FindCornersOfSyntax(lnum, col) return [<sid>FindLeftOfSyntax(a:lnum, a:col), <sid>FindRightOfSyntax(a:lnum, a:col)] endfunction function! s:FindRightOfSyntax(lnum, col) return <sid>FindCornerOfSyntax(a:lnum, a:col, 1) endfunction function! s:FindLeftOfSyntax(lnum, col) return <sid>FindCornerOfSyntax(a:lnum, a:col, -1) endfunction " Returns: " " - a string with the the URL for the link under the cursor " - an empty string if the cursor is not on a link " " TODO " " - multiline support " - give an error if the separator does is not on a link " function! s:Markdown_GetUrlForPosition(lnum, col) let l:lnum = a:lnum let l:col = a:col let l:syn = synIDattr(synID(l:lnum, l:col, 1), 'name') if l:syn ==# 'mkdInlineURL' || l:syn ==# 'mkdURL' || l:syn ==# 'mkdLinkDefTarget' " Do nothing. elseif l:syn ==# 'mkdLink' let [l:lnum, l:col] = <sid>FindNextSyntax(l:lnum, l:col, 'mkdURL') let l:syn = 'mkdURL' elseif l:syn ==# 'mkdDelimiter' let l:line = getline(l:lnum) let l:char = l:line[col - 1] if l:char ==# '<' let l:col += 1 elseif l:char ==# '>' || l:char ==# ')' let l:col -= 1 elseif l:char ==# '[' || l:char ==# ']' || l:char ==# '(' let [l:lnum, l:col] = <sid>FindNextSyntax(l:lnum, l:col, 'mkdURL') else return '' endif else return '' endif let [l:left, l:right] = <sid>FindCornersOfSyntax(l:lnum, l:col) return getline(l:lnum)[l:left - 1 : l:right - 1] endfunction " Front end for GetUrlForPosition. " function! s:OpenUrlUnderCursor() let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.')) if l:url !=# '' call s:VersionAwareNetrwBrowseX(l:url) else echomsg 'The cursor is not on a link.' endif endfunction " We need a definition guard because we invoke 'edit' which will reload this " script while this function is running. We must not replace it. if !exists('*s:EditUrlUnderCursor') function s:EditUrlUnderCursor() let l:editmethod = '' " determine how to open the linked file (split, tab, etc) if exists('g:vim_markdown_edit_url_in') if g:vim_markdown_edit_url_in ==# 'tab' let l:editmethod = 'tabnew' elseif g:vim_markdown_edit_url_in ==# 'vsplit' let l:editmethod = 'vsp' elseif g:vim_markdown_edit_url_in ==# 'hsplit' let l:editmethod = 'sp' else let l:editmethod = 'edit' endif else " default to current buffer let l:editmethod = 'edit' endif let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.')) if l:url !=# '' if get(g:, 'vim_markdown_autowrite', 0) write endif let l:anchor = '' if get(g:, 'vim_markdown_follow_anchor', 0) let l:parts = split(l:url, '#', 1) if len(l:parts) == 2 let [l:url, l:anchor] = parts let l:anchorexpr = get(g:, 'vim_markdown_anchorexpr', '') if l:anchorexpr !=# '' let l:anchor = eval(substitute( \ l:anchorexpr, 'v:anchor', \ escape('"'.l:anchor.'"', '"'), '')) endif endif endif if l:url !=# '' let l:ext = '' if get(g:, 'vim_markdown_no_extensions_in_markdown', 0) " use another file extension if preferred if exists('g:vim_markdown_auto_extension_ext') let l:ext = '.'.g:vim_markdown_auto_extension_ext else let l:ext = '.md' endif endif let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.')) execute l:editmethod l:url endif if l:anchor !=# '' silent! execute '/'.l:anchor endif else execute l:editmethod . ' <cfile>' endif endfunction endif function! s:VersionAwareNetrwBrowseX(url) if has('patch-7.4.567') call netrw#BrowseX(a:url, 0) else call netrw#NetrwBrowseX(a:url, 0) endif endf function! s:MapNotHasmapto(lhs, rhs) if !hasmapto('<Plug>' . a:rhs) execute 'nmap <buffer>' . a:lhs . ' <Plug>' . a:rhs execute 'vmap <buffer>' . a:lhs . ' <Plug>' . a:rhs endif endfunction call <sid>MapNormVis('<Plug>Markdown_MoveToNextHeader', '<sid>MoveToNextHeader') call <sid>MapNormVis('<Plug>Markdown_MoveToPreviousHeader', '<sid>MoveToPreviousHeader') call <sid>MapNormVis('<Plug>Markdown_MoveToNextSiblingHeader', '<sid>MoveToNextSiblingHeader') call <sid>MapNormVis('<Plug>Markdown_MoveToPreviousSiblingHeader', '<sid>MoveToPreviousSiblingHeader') call <sid>MapNormVis('<Plug>Markdown_MoveToParentHeader', '<sid>MoveToParentHeader') call <sid>MapNormVis('<Plug>Markdown_MoveToCurHeader', '<sid>MoveToCurHeader') nnoremap <Plug>Markdown_OpenUrlUnderCursor :call <sid>OpenUrlUnderCursor()<cr> nnoremap <Plug>Markdown_EditUrlUnderCursor :call <sid>EditUrlUnderCursor()<cr> if !get(g:, 'vim_markdown_no_default_key_mappings', 0) call <sid>MapNotHasmapto(']]', 'Markdown_MoveToNextHeader') call <sid>MapNotHasmapto('[[', 'Markdown_MoveToPreviousHeader') call <sid>MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader') call <sid>MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader') call <sid>MapNotHasmapto(']u', 'Markdown_MoveToParentHeader') call <sid>MapNotHasmapto(']h', 'Markdown_MoveToCurHeader') call <sid>MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor') call <sid>MapNotHasmapto('ge', 'Markdown_EditUrlUnderCursor') endif command! -buffer -range=% HeaderDecrease call s:HeaderDecrease(<line1>, <line2>) command! -buffer -range=% HeaderIncrease call s:HeaderDecrease(<line1>, <line2>, 1) command! -buffer -range=% SetexToAtx call s:SetexToAtx(<line1>, <line2>) command! -buffer TableFormat call s:TableFormat() command! -buffer Toc call s:Toc() command! -buffer Toch call s:Toc('horizontal') command! -buffer Tocv call s:Toc('vertical') command! -buffer Toct call s:Toc('tab') command! -buffer -nargs=? InsertToc call s:InsertToc('bullets', <args>) command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', <args>) " Heavily based on vim-notes - http://peterodding.com/code/vim/notes/ if exists('g:vim_markdown_fenced_languages') let s:filetype_dict = {} for s:filetype in g:vim_markdown_fenced_languages let key = matchstr(s:filetype, '[^=]*') let val = matchstr(s:filetype, '[^=]*$') let s:filetype_dict[key] = val endfor else let s:filetype_dict = { \ 'c++': 'cpp', \ 'viml': 'vim', \ 'bash': 'sh', \ 'ini': 'dosini' \ } endif function! s:MarkdownHighlightSources(force) " Syntax highlight source code embedded in notes. " Look for code blocks in the current file let filetypes = {} for line in getline(1, '$') let ft = matchstr(line, '\(`\{3,}\|\~\{3,}\)\s*\zs[0-9A-Za-z_+-]*\ze.*') if !empty(ft) && ft !~# '^\d*$' | let filetypes[ft] = 1 | endif endfor if !exists('b:mkd_known_filetypes') let b:mkd_known_filetypes = {} endif if !exists('b:mkd_included_filetypes') " set syntax file name included let b:mkd_included_filetypes = {} endif if !a:force && (b:mkd_known_filetypes == filetypes || empty(filetypes)) return endif " Now we're ready to actually highlight the code blocks. let startgroup = 'mkdCodeStart' let endgroup = 'mkdCodeEnd' for ft in keys(filetypes) if a:force || !has_key(b:mkd_known_filetypes, ft) if has_key(s:filetype_dict, ft) let filetype = s:filetype_dict[ft] else let filetype = ft endif let group = 'mkdSnippet' . toupper(substitute(filetype, '[+-]', '_', 'g')) if !has_key(b:mkd_included_filetypes, filetype) let include = s:SyntaxInclude(filetype) let b:mkd_included_filetypes[filetype] = 1 else let include = '@' . toupper(filetype) endif let command_backtick = 'syntax region %s matchgroup=%s start="^\s*`\{3,}\s*%s.*$" matchgroup=%s end="\s*`\{3,}$" keepend contains=%s%s' let command_tilde = 'syntax region %s matchgroup=%s start="^\s*\~\{3,}\s*%s.*$" matchgroup=%s end="\s*\~\{3,}$" keepend contains=%s%s' execute printf(command_backtick, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '') execute printf(command_tilde, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '') execute printf('syntax cluster mkdNonListItem add=%s', group) let b:mkd_known_filetypes[ft] = 1 endif endfor endfunction function! s:SyntaxInclude(filetype) " Include the syntax highlighting of another {filetype}. let grouplistname = '@' . toupper(a:filetype) " Unset the name of the current syntax while including the other syntax " because some syntax scripts do nothing when "b:current_syntax" is set if exists('b:current_syntax') let syntax_save = b:current_syntax unlet b:current_syntax endif try execute 'syntax include' grouplistname 'syntax/' . a:filetype . '.vim' execute 'syntax include' grouplistname 'after/syntax/' . a:filetype . '.vim' catch /E484/ " Ignore missing scripts endtry " Restore the name of the current syntax if exists('syntax_save') let b:current_syntax = syntax_save elseif exists('b:current_syntax') unlet b:current_syntax endif return grouplistname endfunction function! s:MarkdownRefreshSyntax(force) " Use != to compare &syntax's value to use the same logic run on " $VIMRUNTIME/syntax/synload.vim. " " vint: next-line -ProhibitEqualTildeOperator if &filetype =~# 'markdown' && line('$') > 1 && &syntax != 'OFF' call s:MarkdownHighlightSources(a:force) endif endfunction function! s:MarkdownClearSyntaxVariables() if &filetype =~# 'markdown' unlet! b:mkd_included_filetypes endif endfunction augroup Mkd " These autocmd calling s:MarkdownRefreshSyntax need to be kept in sync with " the autocmds calling s:MarkdownSetupFolding in after/ftplugin/markdown.vim. autocmd! * <buffer> autocmd BufWinEnter <buffer> call s:MarkdownRefreshSyntax(1) autocmd BufUnload <buffer> call s:MarkdownClearSyntaxVariables() autocmd BufWritePost <buffer> call s:MarkdownRefreshSyntax(0) autocmd InsertEnter,InsertLeave <buffer> call s:MarkdownRefreshSyntax(0) autocmd CursorHold,CursorHoldI <buffer> call s:MarkdownRefreshSyntax(0) augroup END 07070100000013000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002300000000vim-markdown-2.0.0+20220926/indent07070100000014000081ED00000000000000000000000163314A47000008B1000000000000000000000000000000000000003000000000vim-markdown-2.0.0+20220926/indent/markdown.vimif exists('b:did_indent') | finish | endif let b:did_indent = 1 setlocal indentexpr=GetMarkdownIndent() setlocal nolisp setlocal autoindent " Automatically continue blockquote on line break setlocal formatoptions+=r setlocal comments=b:> if get(g:, 'vim_markdown_auto_insert_bullets', 1) " Do not automatically insert bullets when auto-wrapping with text-width setlocal formatoptions-=c " Accept various markers as bullets setlocal comments+=b:*,b:+,b:- endif " Only define the function once if exists('*GetMarkdownIndent') | finish | endif function! s:IsMkdCode(lnum) let name = synIDattr(synID(a:lnum, 1, 0), 'name') return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)') endfunction function! s:IsLiStart(line) return a:line !~# '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' && \ a:line =~# '^\s*[*+-] \+' endfunction function! s:IsHeaderLine(line) return a:line =~# '^\s*#' endfunction function! s:IsBlankLine(line) return a:line =~# '^$' endfunction function! s:PrevNonBlank(lnum) let i = a:lnum while i > 1 && s:IsBlankLine(getline(i)) let i -= 1 endwhile return i endfunction function GetMarkdownIndent() if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2)) return 0 endif let list_ind = get(g:, 'vim_markdown_new_list_item_indent', 4) " Find a non-blank line above the current line. let lnum = s:PrevNonBlank(v:lnum - 1) " At the start of the file use zero indent. if lnum == 0 | return 0 | endif let ind = indent(lnum) let line = getline(lnum) " Last line let cline = getline(v:lnum) " Current line if s:IsLiStart(cline) " Current line is the first line of a list item, do not change indent return indent(v:lnum) elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum) " Current line is the header, do not indent return 0 elseif s:IsLiStart(line) if s:IsMkdCode(lnum) return ind else " Last line is the first line of a list item, increase indent return ind + list_ind end else return ind endif endfunction 07070100000015000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002500000000vim-markdown-2.0.0+20220926/registry07070100000016000081A400000000000000000000000163314A47000000E0000000000000000000000000000000000000003300000000vim-markdown-2.0.0+20220926/registry/markdown.yamladdon: markdown description: "Markdown syntax highlighting" files: - ftdetect/markdown.vim - ftplugin/markdown.vim - syntax/markdown.vim - after/ftplugin/markdown.vim - indent/markdown.vim - doc/vim-markdown.txt 07070100000017000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002300000000vim-markdown-2.0.0+20220926/syntax07070100000018000081A400000000000000000000000163314A4700002672000000000000000000000000000000000000003000000000vim-markdown-2.0.0+20220926/syntax/markdown.vim" Vim syntax file " Language: Markdown " Maintainer: Ben Williams <benw@plasticboy.com> " URL: http://plasticboy.com/markdown-vim-mode/ " Remark: Uses HTML syntax file " TODO: Handle stuff contained within stuff (e.g. headings within blockquotes) " Read the HTML syntax to start with if v:version < 600 so <sfile>:p:h/html.vim else runtime! syntax/html.vim if exists('b:current_syntax') unlet b:current_syntax endif endif if v:version < 600 syntax clear elseif exists('b:current_syntax') finish endif " don't use standard HiLink, it will not work with included syntax files if v:version < 508 command! -nargs=+ HtmlHiLink hi link <args> else command! -nargs=+ HtmlHiLink hi def link <args> endif syn spell toplevel syn case ignore syn sync linebreaks=1 let s:conceal = '' let s:concealends = '' let s:concealcode = '' if has('conceal') && get(g:, 'vim_markdown_conceal', 1) let s:conceal = ' conceal' let s:concealends = ' concealends' endif if has('conceal') && get(g:, 'vim_markdown_conceal_code_blocks', 1) let s:concealcode = ' concealends' endif " additions to HTML groups if get(g:, 'vim_markdown_emphasis_multiline', 1) let s:oneline = '' else let s:oneline = ' oneline' endif syn region mkdItalic matchgroup=mkdItalic start="\%(\*\|_\)" end="\%(\*\|_\)" syn region mkdBold matchgroup=mkdBold start="\%(\*\*\|__\)" end="\%(\*\*\|__\)" syn region mkdBoldItalic matchgroup=mkdBoldItalic start="\%(\*\*\*\|___\)" end="\%(\*\*\*\|___\)" execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend contains=@Spell' . s:oneline . s:concealends execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend contains=@Spell' . s:oneline . s:concealends execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend contains=@Spell' . s:oneline . s:concealends execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend contains=@Spell' . s:oneline . s:concealends " [link](URL) | [link][id] | [link][] | ![image](URL) syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]" execute 'syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline' . s:conceal execute 'syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline' . s:conceal execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!!\?\[\ze[^]\n]*\n\?[^]\n]*\][[(]" end="\]" contains=@mkdNonListItem,@Spell nextgroup=mkdURL,mkdID skipwhite' . s:concealends " Autolink without angle brackets. " mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment " ------------ _____________________ ----------------------------- _________________________ ----------------- __ syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*/ " Autolink with parenthesis. syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*)\)\@=" end=")" " Autolink with angle brackets. syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!<\ze[a-z][a-z0-9,.-]\{1,22}:\/\/[^> ]*>" end=">" " Link definitions: [id]: URL (Optional Title) syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[\^\@!" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained "HTML headings syn region htmlH1 matchgroup=mkdHeading start="^\s*#" end="$" contains=mkdLink,mkdInlineURL,@Spell syn region htmlH2 matchgroup=mkdHeading start="^\s*##" end="$" contains=mkdLink,mkdInlineURL,@Spell syn region htmlH3 matchgroup=mkdHeading start="^\s*###" end="$" contains=mkdLink,mkdInlineURL,@Spell syn region htmlH4 matchgroup=mkdHeading start="^\s*####" end="$" contains=mkdLink,mkdInlineURL,@Spell syn region htmlH5 matchgroup=mkdHeading start="^\s*#####" end="$" contains=mkdLink,mkdInlineURL,@Spell syn region htmlH6 matchgroup=mkdHeading start="^\s*######" end="$" contains=mkdLink,mkdInlineURL,@Spell syn match htmlH1 /^.\+\n=\+$/ contains=mkdLink,mkdInlineURL,@Spell syn match htmlH2 /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell "define Markdown groups syn match mkdLineBreak / \+$/ syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/`/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!``/ skip=/[^`]`[^`]/ end=/``/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/ end=/\(\([^\\]\|^\)\\\)\@<!\~\~/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\z1\~*\s*$/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre\(\|\_s[^>]*\)\\\@<!>" end="</pre>"' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code\(\|\_s[^>]*\)\\\@<!>" end="</code>"' . s:concealcode syn region mkdFootnote start="\[^" end="\]" syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,@Spell syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*\(\*\|\s\)*$/ syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-\(-\|\s\)*$/ syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_\(_\|\s\)*$/ " YAML frontmatter if get(g:, 'vim_markdown_frontmatter', 0) syn include @yamlTop syntax/yaml.vim syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^\(---\|\.\.\.\)$" contains=@yamlTop keepend unlet! b:current_syntax endif if get(g:, 'vim_markdown_toml_frontmatter', 0) try syn include @tomlTop syntax/toml.vim syn region Comment matchgroup=mkdDelimiter start="\%^+++$" end="^+++$" transparent contains=@tomlTop keepend unlet! b:current_syntax catch /E484/ syn region Comment matchgroup=mkdDelimiter start="\%^+++$" end="^+++$" endtry endif if get(g:, 'vim_markdown_json_frontmatter', 0) try syn include @jsonTop syntax/json.vim syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" contains=@jsonTop keepend unlet! b:current_syntax catch /E484/ syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" endtry endif if get(g:, 'vim_markdown_math', 0) syn include @tex syntax/tex.vim syn region mkdMath start="\\\@<!\$" end="\$" skip="\\\$" contains=@tex keepend syn region mkdMath start="\\\@<!\$\$" end="\$\$" skip="\\\$" contains=@tex keepend endif " Strike through if get(g:, 'vim_markdown_strikethrough', 0) execute 'syn region mkdStrike matchgroup=htmlStrike start="\%(\~\~\)" end="\%(\~\~\)"' . s:concealends HtmlHiLink mkdStrike htmlStrike endif syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike "highlighting for Markdown groups HtmlHiLink mkdString String HtmlHiLink mkdCode String HtmlHiLink mkdCodeDelimiter String HtmlHiLink mkdCodeStart String HtmlHiLink mkdCodeEnd String HtmlHiLink mkdFootnote Comment HtmlHiLink mkdBlockquote Comment HtmlHiLink mkdListItem Identifier HtmlHiLink mkdRule Identifier HtmlHiLink mkdLineBreak Visual HtmlHiLink mkdFootnotes htmlLink HtmlHiLink mkdLink htmlLink HtmlHiLink mkdURL htmlString HtmlHiLink mkdInlineURL htmlLink HtmlHiLink mkdID Identifier HtmlHiLink mkdLinkDef mkdID HtmlHiLink mkdLinkDefTarget mkdURL HtmlHiLink mkdLinkTitle htmlString HtmlHiLink mkdDelimiter Delimiter let b:current_syntax = 'mkd' delcommand HtmlHiLink " vim: ts=8 07070100000019000041ED00000000000000000000000263314A4700000000000000000000000000000000000000000000002100000000vim-markdown-2.0.0+20220926/test0707010000001A000081A400000000000000000000000163314A47000000A1000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/test/README.mdYou can run the tests using the Makefile from the top directory: make test To run them manually please refer to the instructions/commands in the Makefile. 0707010000001B000081A400000000000000000000000163314A4700001074000000000000000000000000000000000000003300000000vim-markdown-2.0.0+20220926/test/folding-toc.vader" Tests atx and setext folding, and :Toc. Before: source ../after/ftplugin/markdown.vim setlocal foldtext=foldtext() After: setlocal foldexpr=0 setlocal foldmethod=manual Given markdown; # chap 1 hello world ```bash # some bash scripting pwd # this is another comment # other echo "foo" ``` ## chap 1.1 - dog - cat ~~~~bash mkdir foo # comment in ~ ~~~~ ### chap 1.1.1 - dragons - fenixs # chap 2 another ## chap 2.1 - uk - japan - china # chap 3 nothing here chap 4 ====== setext are evil chap 4.1 -------- evil indeed ````bash # get system info uname -a ```` Execute (fold level): AssertEqual foldlevel(1), 0, '# chap 1' AssertEqual foldlevel(3), 1, 'hello' AssertEqual foldlevel(6), 1, '```bash' AssertEqual foldlevel(7), 1, '# some bash scripting' AssertEqual foldlevel(15), 1, '## chap 1.1' AssertEqual foldlevel(21), 2, 'mkdir foo' AssertEqual foldlevel(22), 2, 'comment in ~' AssertEqual foldlevel(25), 2, '### chap 1.1.1' AssertEqual foldlevel(27), 3, '- dragons' AssertEqual foldlevel(30), 1, '# chap 2' AssertEqual foldlevel(32), 1, 'another' AssertEqual foldlevel(34), 1, '# chap 2.1' AssertEqual foldlevel(37), 2, '- japan' AssertEqual foldlevel(41), 1, '# chap 3' AssertEqual foldlevel(45), 1, 'chap 4\n======' AssertEqual foldlevel(48), 1, 'setext are evil' AssertEqual foldlevel(50), 2, 'chap 4.1\n------' Execute (fold text result): AssertEqual foldtextresult(2), '+-- 28 lines: hello' AssertEqual foldtextresult(31), '+-- 10 lines: another' AssertEqual foldtextresult(42), '+-- 3 lines: nothing here' AssertEqual foldtextresult(45), '+-- 14 lines: chap 4' Execute (fold level with setting): let g:vim_markdown_folding_level = 2 source ../after/ftplugin/markdown.vim AssertEqual foldlevel(1), 0, '# chap 1' AssertEqual foldlevel(3), 1, 'hello' AssertEqual foldlevel(6), 1, '```bash' AssertEqual foldlevel(7), 1, '# some bash scripting' AssertEqual foldlevel(15), 0, '## chap 1.1' AssertEqual foldlevel(21), 2, 'mkdir foo' AssertEqual foldlevel(22), 2, 'comment in ~' AssertEqual foldlevel(25), 2, '### chap 1.1.1' AssertEqual foldlevel(27), 3, '- dragons' AssertEqual foldlevel(30), 0, '# chap 2' AssertEqual foldlevel(32), 1, 'another' AssertEqual foldlevel(34), 0, '# chap 2.1' AssertEqual foldlevel(37), 2, '- japan' AssertEqual foldlevel(41), 0, '# chap 3' AssertEqual foldlevel(45), 1, 'chap 4\n======' AssertEqual foldlevel(48), 1, 'setext are evil' AssertEqual foldlevel(50), 1, 'chap 4.1\n------' let g:vim_markdown_folding_level = 0 Execute (check TOC): :Toc :lclose let res = getloclist(0) let elem = res[0] AssertEqual elem.lnum, 1 AssertEqual elem.text, 'chap 1' let elem = res[1] AssertEqual elem.lnum, 15 AssertEqual elem.text, ' chap 1.1' let elem = res[2] AssertEqual elem.lnum, 25 AssertEqual elem.text, ' chap 1.1.1' let elem = res[3] AssertEqual elem.lnum, 30 AssertEqual elem.text, 'chap 2' let elem = res[4] AssertEqual elem.lnum, 34 AssertEqual elem.text, ' chap 2.1' let elem = res[5] AssertEqual elem.lnum, 41 AssertEqual elem.text, 'chap 3' let elem = res[6] AssertEqual elem.lnum, 45 AssertEqual elem.text, 'chap 4' let elem = res[7] AssertEqual elem.lnum, 50 AssertEqual elem.text, ' chap 4.1' Given markdown; --- layout: article title: A test of the heading folding when there is YAML frontmatter tags: markdown yaml vim-markdown --- body heading ------- Execute (fold level of yaml front matter): let g:vim_markdown_frontmatter = 1 source ../after/ftplugin/markdown.vim AssertEqual foldlevel(1), 0, '---' AssertEqual foldlevel(2), 0, 'layout: article' AssertEqual foldlevel(4), 0, 'tags: markdown yaml vim-markdown' AssertEqual foldlevel(5), 0, '---' AssertEqual foldlevel(6), 0, 'body' AssertEqual foldlevel(8), 2, 'heading' AssertEqual foldlevel(9), 2, '-------' unlet g:vim_markdown_frontmatter Execute (check Toc of yaml front matter): let g:vim_markdown_frontmatter = 1 :Toc :lclose let res = getloclist(0) AssertEqual len(res), 1 let elem = res[0] AssertEqual elem.lnum, 8 AssertEqual elem.text, ' heading' unlet g:vim_markdown_frontmatter 0707010000001C000081A400000000000000000000000163314A47000003AE000000000000000000000000000000000000002F00000000vim-markdown-2.0.0+20220926/test/folding.vaderBefore: source ../after/ftplugin/markdown.vim After: setlocal foldexpr=0 setlocal foldmethod=manual Given markdown; # Title ## Chapter 1 ``` This is code block # This is just a comment ``` ## Capter 2 foobar Execute (fold level # in code block): AssertEqual foldlevel(1), 0, '# Title' AssertEqual foldlevel(3), 1, '## Chapter 1' AssertEqual foldlevel(7), 2, '# This is just a comment' AssertEqual foldlevel(8), 2, '```' AssertEqual foldlevel(10), 1, '## Chapter 2' AssertEqual foldlevel(12), 2, 'foobar' Given markdown; Fold Level 1 ============ Fold Level 2 ------------ Execute (fold level ==, --): AssertEqual foldlevel(2), 1, '==' AssertEqual foldlevel(4), 2, '--' Given markdown; # H1 ## H1.1 ## H1.2 # H2 Execute (fold level # in last line): AssertEqual foldlevel(1), 0, '# H1' AssertEqual foldlevel(3), 1, '## H1.1' AssertEqual foldlevel(5), 1, '## H1.2' AssertEqual foldlevel(7), 0, '# H2' 0707010000001D000081A400000000000000000000000163314A4700000008000000000000000000000000000000000000002C00000000vim-markdown-2.0.0+20220926/test/ge_test.mdge test 0707010000001E000081A400000000000000000000000163314A4700000122000000000000000000000000000000000000003C00000000vim-markdown-2.0.0+20220926/test/indent-new-list-item.vaderBefore: let g:vim_markdown_new_list_item_indent = 2 After: unlet g:vim_markdown_new_list_item_indent Given markdown; * item1 Do (new line from the first item of the list and add the second item): o* item2 Expect (insert 2 spaces to the head of second item): * item1 * item2 0707010000001F000081A400000000000000000000000163314A47000001D0000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/test/indent.md1. Confirm indent with new line insert after list items '\' is not list item. \ foo If only space and three '*' or '-' character are in the line, this line means horizontal item. If current line is below horizontal item, it need not to indent. Following example is horizontal item. --- *** - - - * * * And list item must be specified space after [*-+]. Following example is list item. * foo - bar + baz But following example is not list item. *foo -bar +baz 07070100000020000081A400000000000000000000000163314A470000039D000000000000000000000000000000000000002E00000000vim-markdown-2.0.0+20220926/test/indent.vaderGiven markdown; * item1 Do (insert enter at list end): A\<cr>item2 Expect (auto insert * and indent level is same): * item1 * item2 Given markdown; Execute: syntax off Do (insert enter at list end with syntax off): i* item1\<cr>item2 Expect (auto insert * and indent level is same): * item1 * item2 Execute: syntax on Given markdown; ``` * item1 Do (insert after list items in code block): jotext Expect (no autoindent in code block): ``` * item1 text Given markdown; * item1 a Do (insert enter after list): jji\<cr>b Expect (no autoindent outside list): * item1 ba Given markdown; - a # b Do (insert header after list): jjwi# Expect (no indent header after list): - a ## b Given markdown; * item1 Do (new line from the first item of the list and add the second item): o* item2 Expect (insert 4 spaces to the head of second item): * item1 * item2 07070100000021000081A400000000000000000000000163314A47000007A0000000000000000000000000000000000000003200000000vim-markdown-2.0.0+20220926/test/insert-toc.vaderGiven markdown; # a ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ### Bar Level 3 Execute (InsertToc format): :2 :call append('.', '') :InsertToc Expect (format): # a * [Foo Level 2](#foo-level-2) * [Foo Level 3](#foo-level-3) * [Foo Level 4](#foo-level-4) * [Bar Level 2](#bar-level-2) * [Bar Level 3](#bar-level-3) ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ### Bar Level 3 Given markdown; # a ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ### Bar Level 3 Execute (InsertToc only h2 headers): :2 :call append('.', '') :InsertToc 2 Expect (only h2 headers): # a * [Foo Level 2](#foo-level-2) * [Bar Level 2](#bar-level-2) ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ### Bar Level 3 Given markdown; # a ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ## Baz Level 2 ## Foobar Level 2 ## Foobaz Level 2 ## Barfoo Level 2 ## Barbaz Level 2 ## Bazfoo Level 2 ## Bazbar Level 2 ## Foobarbaz Level 2 Execute (InsertNToc format, and up to h3 headers): :2 :call append('.', '') :InsertNToc 3 Expect (format, and up to h3 headers): # a 1. [Foo Level 2](#foo-level-2) * [Foo Level 3](#foo-level-3) 2. [Bar Level 2](#bar-level-2) 3. [Baz Level 2](#baz-level-2) 4. [Foobar Level 2](#foobar-level-2) 5. [Foobaz Level 2](#foobaz-level-2) 6. [Barfoo Level 2](#barfoo-level-2) 7. [Barbaz Level 2](#barbaz-level-2) 8. [Bazfoo Level 2](#bazfoo-level-2) 9. [Bazbar Level 2](#bazbar-level-2) 10. [Foobarbaz Level 2](#foobarbaz-level-2) ## Foo Level 2 ### Foo Level 3 #### Foo Level 4 Bar Level 2 ----------- ## Baz Level 2 ## Foobar Level 2 ## Foobaz Level 2 ## Barfoo Level 2 ## Barbaz Level 2 ## Bazfoo Level 2 ## Bazbar Level 2 ## Foobarbaz Level 2 07070100000022000081A400000000000000000000000163314A4700000D92000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/test/map.vaderGiven markdown; a <http://b> c Execute (gx autolink): let b:url = 'http://b' let b:line = getline(1) let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition') AssertEqual b:func(1, match(b:line, 'a') + 1), '' AssertEqual b:func(1, match(b:line, '<') + 1), b:url AssertEqual b:func(1, match(b:line, 'h') + 1), b:url AssertEqual b:func(1, match(b:line, '>') + 1), b:url AssertEqual b:func(1, match(b:line, 'c') + 1), '' Given markdown; a http://b.bb c Execute (gx implicit autolink): let b:url = 'http://b.bb' let b:line = getline(1) let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition') AssertEqual b:func(1, match(b:line, 'a') + 1), '' AssertEqual b:func(1, match(b:line, 'h') + 1), b:url AssertEqual b:func(1, match(b:line, 'c') + 1), '' Given markdown; [a]: http://b "c" Execute (gx link reference definition): let b:url = 'http://b' let b:line = getline(1) let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition') " TODO would be cool if all of the following gave the link. AssertEqual b:func(1, match(b:line, 'a') + 1), '' AssertEqual b:func(1, match(b:line, 'h') + 1), b:url AssertEqual b:func(1, match(b:line, 'c') + 1), '' Given markdown; a [b](c) d Execute (gx autolink): let b:url = 'c' let b:line = getline(1) let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition') AssertEqual b:func(1, match(b:line, 'a') + 1), '' AssertEqual b:func(1, match(b:line, '[') + 1), b:url AssertEqual b:func(1, match(b:line, 'b') + 1), b:url AssertEqual b:func(1, match(b:line, ']') + 1), b:url AssertEqual b:func(1, match(b:line, '(') + 1), b:url AssertEqual b:func(1, match(b:line, 'c') + 1), b:url AssertEqual b:func(1, match(b:line, ')') + 1), b:url AssertEqual b:func(1, match(b:line, 'd') + 1), '' Given markdown; [ge_test.md](ge_test.md) Execute (ge opens file): normal ge AssertEqual @%, 'ge_test.md' AssertEqual getline(1), 'ge test' Given markdown; [ge_test](ge_test) Execute (ge opens file without .md extensions): let g:vim_markdown_no_extensions_in_markdown = 1 normal ge AssertEqual @%, 'ge_test.md' AssertEqual getline(1), 'ge test' unlet g:vim_markdown_no_extensions_in_markdown Given markdown; [ge_test.md](ge_test.md) Execute (ge does not write before opening file): normal ia normal l normal ge AssertEqual @%, 'ge_test.md' AssertEqual getline(1), 'ge test' Given markdown; [ge_test.md](ge_test.md) Execute (ge auto-write before opening file): let g:vim_markdown_autowrite = 1 normal ia normal l AssertThrows normal ge AssertEqual g:vader_exception, 'Vim(write):E382: Cannot write, ''buftype'' option is set' unlet g:vim_markdown_autowrite Given markdown; # a b # c d Execute (]] same level): AssertEqual line('.'), 1 normal ]] AssertEqual line('.'), 5 normal [[ AssertEqual line('.'), 1 Given markdown; # a b ## c d Execute (]] different levels level): AssertEqual line('.'), 1 normal ]] AssertEqual line('.'), 5 normal [[ AssertEqual line('.'), 1 Given markdown; # a b ## c d # e f Execute (][ different levels level): AssertEqual line('.'), 1 normal ][ AssertEqual line('.'), 9 normal [] AssertEqual line('.'), 1 Given markdown; # a b Execute (]h): normal! 3G AssertEqual line('.'), 3 normal ]h AssertEqual line('.'), 1 07070100000023000081A400000000000000000000000163314A470000080E000000000000000000000000000000000000003600000000vim-markdown-2.0.0+20220926/test/python-folding.vaderBefore: let g:vim_markdown_folding_style_pythonic = 1 source ../after/ftplugin/markdown.vim After: setlocal foldexpr=0 setlocal foldmethod=manual Given markdown; # Title ## Chapter 1 ``` This is code block # This is just a comment ``` ## Chapter 2 foobar Execute (fold level # in code block): AssertEqual foldlevel(1), 1, '# Title' AssertEqual foldlevel(3), 2, '## Chapter 1' AssertEqual foldlevel(7), 2, '# This is just a comment' AssertEqual foldlevel(8), 2, '```' AssertEqual foldlevel(10), 2, '## Chapter 2' AssertEqual foldlevel(12), 2, 'foobar' Execute (fold text of chapters): let b:width = winwidth(0) let b:hyphen = repeat('-', b:width - 18 > 2 ? b:width - 18 : b:width - 9 > 0 ? 3 : 2) AssertEqual foldtextresult(10), strpart('## Chapter 2', 0, b:width - 9) . ' ' . b:hyphen . ' 2' Given markdown; Fold text 1 =========== Fold text 2 ----------- Execute (fold level ==, --): AssertEqual foldlevel(2), 0, '==' AssertEqual foldlevel(4), 1, '--' Execute (fold text of ==, --): let b:width = winwidth(0) let b:hyphen = repeat('-', b:width - 17 > 2 ? b:width - 17 : b:width - 9 > 0 ? 3 : 2) AssertEqual foldtextresult(3), strpart('Fold text 2', 0, b:width - 9) . ' ' . b:hyphen . ' 1' Given markdown; Headline foobar # Title Execute (fold any preamble): AssertEqual foldlevel(1), 1, 'Headline' AssertEqual foldlevel(3), 1, 'foobar' AssertEqual foldlevel(5), 1, '# Title' Given markdown; --- layout: article title: A test of the heading folding when there is YAML frontmatter tags: markdown yaml vim-markdown --- body heading ------- Execute (fold level of yaml front matter): let g:vim_markdown_frontmatter = 1 source ../after/ftplugin/markdown.vim AssertEqual foldlevel(1), 1, '---' AssertEqual foldlevel(2), 1, 'layout: article' AssertEqual foldlevel(4), 1, 'tags: markdown yaml vim-markdown' AssertEqual foldlevel(5), 1, '---' AssertEqual foldlevel(6), 1, 'body' AssertEqual foldlevel(8), 1, 'heading' AssertEqual foldlevel(9), 1, '-------' unlet g:vim_markdown_frontmatter 07070100000024000081ED00000000000000000000000163314A470000015A000000000000000000000000000000000000002E00000000vim-markdown-2.0.0+20220926/test/run-tests.sh#!/usr/bin/env bash # Exit on error. set -e cd "$( dirname "${BASH_SOURCE[0]}" )" for dep in ../build/tabular ../build/vim-toml ../build/vim-json ../build/vader.vim; do if [[ ! -d $dep ]]; then echo "Missing dependency: $dep" echo "You may just want to use 'make test'." exit 1 fi done vim -Nu vimrc -c 'Vader! *' > /dev/null 07070100000025000081A400000000000000000000000163314A4700000F59000000000000000000000000000000000000003900000000vim-markdown-2.0.0+20220926/test/syntax-singleline.vaderBefore: let g:vim_markdown_emphasis_multiline = 0 syn off | syn on After: let g:vim_markdown_emphasis_multiline = 1 syn off | syn on Given markdown; a **b** c Execute (bold): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' Given markdown; a __b__ c Execute (bold): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' Given markdown; a *b* c Execute (italic): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a _b_ c Execute (italic): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; _a_b_ Execute (italic text has underscores): AssertEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' Given markdown; a \*b\* c Execute (not italic with escaped asterisks): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a \_b\_ c Execute (not italic with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a _b\_c_ d Execute (italic with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; a_b_c Execute (not italic underscores within text): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a *b\*c* d Execute (italic with escaped asterisks): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; a __b\_\_c__ d Execute (bold with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; _a b c_ d Execute (italic with underscores in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; __a b c__ d Execute (bold with underscores in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertNotEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; ___a b c___ d Execute (bold italic with underscores in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic' Given markdown; *a b c* d Execute (italic with asterisks in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; **a b c** d Execute (bold with asterisks in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertNotEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; ***a b c*** d Execute (bold italic with asterisks in multiple lines): AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic' 07070100000026000081A400000000000000000000000163314A470000034E000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/test/syntax.md# Fenced code living in an indented environment is correctly highlighted 1. run this command to do this: ``` some command ``` 2. Subsequent list items are correctly highlighted. Fenced code block with language: ```ruby def f 0 end ``` # Links [a](b "c") [a]() [good spell](a) [badd spell](a) [a](b "c") [a]( b "c" ) a (`a`) b. Fix: <https://github.com/preservim/vim-markdown/issues/113> Escaped: \[a](b) [a\]b](c) ## Known failures Escape does not work: [a\](b) Should not be links because of whitespace: [a] (b) [a](a b) [a](a b) # Reference links Single links: [a][b] [good spell][a] [badd spell][a] [a][] [a] [] [a][b] c [d][e] Reference link followed by inline link: [a] [b](c) ## Known failures Should be shortcut reference links: [a] [a] b [c] Should be a single link: [a] [b] [a] b [c](d) 07070100000027000081A400000000000000000000000163314A470000746A000000000000000000000000000000000000002E00000000vim-markdown-2.0.0+20220926/test/syntax.vaderBefore: unlet! b:mkd_known_filetypes unlet! b:mkd_included_filetypes unlet! g:vim_markdown_math Given markdown; a **b** c Execute (bold): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' Given markdown; a __b__ c Execute (bold): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertNotEqual SyntaxOf('c'), 'htmlBold' Given markdown; a *b* c Execute (italic): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a _b_ c Execute (italic): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; _a_b_ Execute (italic text has underscores): AssertEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' Given markdown; a \*b\* c Execute (not italic with escaped asterisks): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a \_b\_ c Execute (not italic with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a _b\_c_ d Execute (italic with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; a_b_c Execute (not italic underscores within text): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertNotEqual SyntaxOf('b'), 'htmlItalic' AssertNotEqual SyntaxOf('c'), 'htmlItalic' Given markdown; a *b\*c* d Execute (italic with escaped asterisks): AssertNotEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; a __b\_\_c__ d Execute (bold with escaped underscores): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; _a b c_ d Execute (italic with underscores in multiple lines): AssertEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; __a b c__ d Execute (bold with underscores in multiple lines): AssertEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; ___a b c___ d Execute (bold italic with underscores in multiple lines): AssertEqual SyntaxOf('a'), 'htmlBoldItalic' AssertEqual SyntaxOf('b'), 'htmlBoldItalic' AssertEqual SyntaxOf('c'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic' Given markdown; *a b c* d Execute (italic with asterisks in multiple lines): AssertEqual SyntaxOf('a'), 'htmlItalic' AssertEqual SyntaxOf('b'), 'htmlItalic' AssertEqual SyntaxOf('c'), 'htmlItalic' AssertNotEqual SyntaxOf('d'), 'htmlItalic' Given markdown; **a b c** d Execute (bold with asterisks in multiple lines): AssertEqual SyntaxOf('a'), 'htmlBold' AssertEqual SyntaxOf('b'), 'htmlBold' AssertEqual SyntaxOf('c'), 'htmlBold' AssertNotEqual SyntaxOf('d'), 'htmlBold' Given markdown; ***a b c*** d Execute (bold italic with asterisks in multiple lines): AssertEqual SyntaxOf('a'), 'htmlBoldItalic' AssertEqual SyntaxOf('b'), 'htmlBoldItalic' AssertEqual SyntaxOf('c'), 'htmlBoldItalic' AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic' Given markdown; *a Execute (not italic with an asterisk): AssertNotEqual SyntaxOf('a'), 'htmlItalic' Given markdown; [__](a) b Execute (not bold with double underscores): AssertNotEqual SyntaxOf('_'), 'htmlBold' AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertNotEqual SyntaxOf('b'), 'htmlBold' Given markdown; _a_ Execute (conceal italic): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif Given markdown; *a* Execute (conceal italic): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif Given markdown; __a__ Execute (conceal bold): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif Given markdown; **a** Execute (conceal bold): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif Given markdown; ___a___ Execute (conceal italic bold): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 0 AssertEqual synconcealed(1, 6)[0], 0 AssertEqual synconcealed(1, 7)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif Given markdown; ***a*** Execute (conceal italic bold): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 0 AssertEqual synconcealed(1, 6)[0], 0 AssertEqual synconcealed(1, 7)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 1 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif # Links Given markdown; [a](b) Execute (link with title): AssertEqual SyntaxOf('a'), 'mkdLink' AssertEqual SyntaxOf('b'), 'mkdURL' Given markdown; [a b](c) Execute (link text with newline): AssertEqual SyntaxOf('a'), 'mkdLink' AssertEqual SyntaxOf('b'), 'mkdLink' AssertEqual SyntaxOf('c'), 'mkdURL' Given markdown; [a] b [c](d) Execute (link text with bracket sections): AssertNotEqual SyntaxOf('a'), 'mkdLink' AssertNotEqual SyntaxOf('b'), 'mkdLink' AssertEqual SyntaxOf('c'), 'mkdLink' AssertEqual SyntaxOf('d'), 'mkdURL' Given markdown; [^a]: b Execute (footnote is not link): AssertNotEqual SyntaxOf('a'), 'mkdLinkDef' Given markdown; (a) (b) Execute (parenthesis not in link): AssertNotEqual SyntaxOf('a'), 'mkdURL' AssertNotEqual SyntaxOf('b'), 'mkdURL' Given markdown; [a](b) c [d](e) Execute (multiple links on a line): AssertNotEqual SyntaxOf('c'), 'mkdLink' AssertNotEqual SyntaxOf('c'), 'mkdURL' Given markdown; [a] (b) Execute (space is not allowed between link text and parenthesis): AssertNotEqual SyntaxOf('a'), 'mkdLink' AssertNotEqual SyntaxOf('b'), 'mkdURL' Given markdown; [a](b) Execute (conceal link): if has('conceal') setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 setlocal conceallevel=0 endif Execute (disable conceal): if has('conceal') let g:vim_markdown_conceal=0 syn off | syn on setlocal conceallevel=2 AssertEqual synconcealed(1, 1)[0], 0 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 0 AssertEqual synconcealed(1, 6)[0], 0 let g:vim_markdown_conceal=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1 AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 1 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 4)[0], 1 AssertEqual synconcealed(1, 5)[0], 1 AssertEqual synconcealed(1, 6)[0], 1 setlocal conceallevel=0 unlet g:vim_markdown_conceal syn off | syn on endif # Autolinks Given markdown; a <http://b> c Execute (autolink): AssertNotEqual SyntaxOf('a'), 'mkdInlineURL' AssertEqual SyntaxOf('<'), 'mkdDelimiter' AssertEqual SyntaxOf('b'), 'mkdInlineURL' AssertEqual SyntaxOf('>'), 'mkdDelimiter' AssertNotEqual SyntaxOf('c'), 'mkdInlineURL' Given markdown; http://12monkeys.foo Execute (autolink with domain starting with a number): AssertEqual SyntaxOf('12monkeys'), 'mkdInlineURL' Given markdown; <HtTp://a> Execute (autolink with scheme case is insensitive): AssertEqual SyntaxOf('a'), 'mkdInlineURL' Given markdown; <a> Execute (autolink without scheme is not a link): AssertNotEqual SyntaxOf('a'), 'mkdInlineURL' Given markdown; < http://a > <http://b c> <http://d e> Execute (autolink with space is not a link): AssertNotEqual SyntaxOf('a'), 'mkdInlineURL' AssertNotEqual SyntaxOf('b'), 'mkdInlineURL' AssertNotEqual SyntaxOf('c'), 'mkdInlineURL' AssertNotEqual SyntaxOf('d'), 'mkdInlineURL' AssertNotEqual SyntaxOf('e'), 'mkdInlineURL' Given markdown; \<http://a> Execute (autolinks can be backslash escaped): AssertNotEqual SyntaxOf('<'), 'mkdDelimiter' Given markdown; a (http://b.bb) c Execute (autolink in parenthesis): AssertNotEqual SyntaxOf('a'), 'mkdInlineURL' AssertEqual SyntaxOf('('), 'mkdDelimiter' AssertEqual SyntaxOf('b'), 'mkdInlineURL' AssertEqual SyntaxOf(')'), 'mkdDelimiter' AssertNotEqual SyntaxOf('c'), 'mkdInlineURL' Given markdown; [![a](http://b)](http://c) Execute (autolink in link text): AssertEqual SyntaxOf('!'), 'mkdDelimiter' AssertEqual SyntaxOf('a'), 'mkdLink' AssertEqual SyntaxOf('b'), 'mkdURL' AssertEqual SyntaxOf('c'), 'mkdURL' Given markdown; # [h1link](url) ## [h2link](url) ### [h3link](url) #### [h4link](url) ##### [h5link](url) ###### [h6link](url) [h1link_b](url) =============== [h2link_b](url) --------------- Execute (link in headers): AssertEqual SyntaxOf('h1link'), 'mkdLink' AssertEqual SyntaxOf('h2link'), 'mkdLink' AssertEqual SyntaxOf('h3link'), 'mkdLink' AssertEqual SyntaxOf('h4link'), 'mkdLink' AssertEqual SyntaxOf('h5link'), 'mkdLink' AssertEqual SyntaxOf('h6link'), 'mkdLink' AssertEqual SyntaxOf('h1link_b'), 'mkdLink' AssertEqual SyntaxOf('h2link_b'), 'mkdLink' Given markdown; # http://h1link.foo ## http://h2link.foo ### http://h3link.foo #### http://h4link.foo ##### http://h5link.foo ###### http://h6link.foo http://h1link_b.foo =================== http://h2link_b.foo ------------------- Execute (inline url in headers): AssertEqual SyntaxOf('h1link'), 'mkdInlineURL' AssertEqual SyntaxOf('h2link'), 'mkdInlineURL' AssertEqual SyntaxOf('h3link'), 'mkdInlineURL' AssertEqual SyntaxOf('h4link'), 'mkdInlineURL' AssertEqual SyntaxOf('h5link'), 'mkdInlineURL' AssertEqual SyntaxOf('h6link'), 'mkdInlineURL' AssertEqual SyntaxOf('h1link_b'), 'mkdInlineURL' AssertEqual SyntaxOf('h2link_b'), 'mkdInlineURL' Given markdown; > [a](b) > http://foo.bar Execute (link in blockquote): AssertEqual SyntaxOf('a'), 'mkdLink' AssertEqual SyntaxOf('foo'), 'mkdInlineURL' Given markdown; [https://domain.tld](https://domain.com) not_a_link Execute (link with url title): AssertEqual SyntaxOf('https://domain.tld'), 'mkdInlineURL' AssertNotEqual SyntaxOf(']'), 'mkdInlineURL' AssertEqual SyntaxOf('https://domain.com'), 'mkdURL' AssertNotEqual SyntaxOf('not_a_link'), 'mkdInlineURL' # Code Blocks Given markdown; ~~~ code ~~~ Execute (code blocks can be fenced with tildes): AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; ~~~~ code ~~~~~ Execute (code blocks can be fenced with tildes longer than 3): AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; ```` code ````` Execute (code blocks can be fenced with backticks longer than 3): AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; ~~~ruby code ~~~ Execute (code blocks can have a language specifier): AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; ```c++ code ``` text Execute (code blocks can be fenced with backticks and a language specifier): AssertEqual SyntaxOf('code'), 'mkdCode' AssertNotEqual SyntaxOf('text'), 'mkdCode' # Indent Code Blocks Given markdown; a b c Execute (indent code blocks): AssertNotEqual SyntaxOf('a'), 'mkdCode' AssertEqual SyntaxOf('b'), 'mkdCode' AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; # a b c Execute (indent code blocks after header): AssertNotEqual SyntaxOf('a'), 'mkdCode' AssertNotEqual SyntaxOf('b'), 'mkdCode' AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; - a b c Execute (indent code blocks after list): AssertNotEqual SyntaxOf('a'), 'mkdCode' AssertNotEqual SyntaxOf('b'), 'mkdCode' AssertEqual SyntaxOf('c'), 'mkdCode' Given markdown; a b Execute (indent code block at beginning of file): AssertEqual SyntaxOf('a'), 'mkdCode' AssertEqual SyntaxOf('b'), 'mkdCode' Given markdown; ```c++ #include <iostream> code ``` ```ruby def a end ``` ```ruby {linenos=table,hl_lines=[8,"15-17"],linenostart=199} class b end ``` Execute (fenced code block syntax with a language specifier): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('include'), 'cInclude' AssertEqual SyntaxOf('code'), 'mkdSnippetCPP' AssertEqual SyntaxOf('def'), 'rubyDefine' AssertEqual SyntaxOf('class'), 'rubyClass' Given markdown; ``` c++ #include <iostream> code ``` ``` vim let g:a = 1 ``` ``` ruby def a end ``` ``` ruby class B end ``` Execute (fenced code block syntax with a language specifier after whitespace): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('include'), 'cInclude' AssertEqual SyntaxOf('code'), 'mkdSnippetCPP' AssertEqual SyntaxOf('g:a'), 'vimVar' AssertEqual SyntaxOf('def'), 'rubyDefine' AssertNotEqual SyntaxOf('class'), 'rubyClass' Given markdown; ```vim let g:a = 1 ``` ```viml let g:b = 1 ``` Execute (fenced code block syntax with alias language specifier): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('g:a'), 'vimVar' AssertEqual SyntaxOf('g:b'), 'vimVar' Given markdown; ```csharp var s = "foo"; ``` Execute (fenced code block languages setting): let g:vim_markdown_fenced_languages = ['csharp=cs'] source ../ftplugin/markdown.vim let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('foo'), 'csString' unlet g:vim_markdown_fenced_languages Given markdown; ```vim let g:a = 1 ``` Execute (fenced code block includes language syntax with reopening same buffer): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) split quit edit set filetype=markdown execute "normal! i```vim\<cr>let g:a = 1\<cr>```" call b:func(1) AssertEqual SyntaxOf('g:a'), 'vimVar' Given markdown; ```a+b- code ``` Execute (fenced code block syntax with an unknown language specifier): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('code'), 'mkdSnippetA_B_' Given markdown; ``` = a - ``` Execute (first = or - in fenced code block is not setex headers): AssertEqual SyntaxOf('='), 'mkdCode' AssertEqual SyntaxOf('-'), 'mkdCode' Given markdown; ``` {style=""} a ``` Execute (fenced code block with extended info strings): AssertEqual SyntaxOf('a'), 'mkdCode' # Code Blocks in pre and code tag Given markdown; <pre> a </pre> Execute (code block in pre tag): AssertEqual SyntaxOf('a'), 'mkdCode' Given markdown; <code> a </code> Execute (code block in code tag): AssertEqual SyntaxOf('a'), 'mkdCode' Given markdown; \<pre\> a \</pre\> Execute (not code block in escaped pre tag): AssertNotEqual SyntaxOf('a'), 'mkdCode' Given markdown; \<code\> a \</code\> Execute (not code block in escaped code tag): AssertNotEqual SyntaxOf('a'), 'mkdCode' # Code quotes Given markdown; `a` Execute (code in code quotes): AssertEqual SyntaxOf('a'), 'mkdCode' Given markdown; `a\` b `c\` d Execute (code quotes not escaped ending with backslash): AssertEqual SyntaxOf('a\'), 'mkdCode' AssertNotEqual SyntaxOf('b'), 'mkdCode' AssertEqual SyntaxOf('c\'), 'mkdCode' AssertNotEqual SyntaxOf('d'), 'mkdCode' Given markdown; ``a\`` b ``c`\`1`` d Execute (double code quotes not escaped ending with backslash): AssertEqual SyntaxOf('a\'), 'mkdCode' AssertNotEqual SyntaxOf('b'), 'mkdCode' AssertEqual SyntaxOf('c`\\`1'), 'mkdCode' AssertNotEqual SyntaxOf('d'), 'mkdCode' # Math Given markdown; a $x$ b c $$y$$ d \$e\$ \$\$f\$\$ Execute (math): AssertNotEqual SyntaxOf('x')[0:2], 'tex' AssertNotEqual SyntaxOf('y')[0:2], 'tex' let g:vim_markdown_math=1 syn off | syn on AssertNotEqual SyntaxOf('a')[0:2], 'tex' AssertNotEqual SyntaxOf('b')[0:2], 'tex' AssertNotEqual SyntaxOf('c')[0:2], 'tex' AssertNotEqual SyntaxOf('d')[0:2], 'tex' AssertNotEqual SyntaxOf('e')[0:2], 'tex' AssertNotEqual SyntaxOf('f')[0:2], 'tex' AssertEqual SyntaxOf('x')[0:2], 'tex' AssertEqual SyntaxOf('y')[0:2], 'tex' let g:vim_markdown_math=0 syn off | syn on AssertNotEqual SyntaxOf('x')[0:2], 'tex' AssertNotEqual SyntaxOf('y')[0:2], 'tex' Given markdown; a $ b $ c Execute (multiline math): let g:vim_markdown_math=1 syn off | syn on AssertNotEqual SyntaxOf('a')[0:2], 'tex' AssertEqual SyntaxOf('b')[0:2], 'tex' AssertNotEqual SyntaxOf('c')[0:2], 'tex' Given markdown; $ \sqrt{a}{b} $ $$ \frac{a}{b} $$ Execute (math tex highlighting): let g:vim_markdown_math=0 syn off | syn on AssertNotEqual SyntaxOf('sqrt')[0:2], 'tex' AssertNotEqual SyntaxOf('frac')[0:2], 'tex' let g:vim_markdown_math=1 syn off | syn on AssertEqual SyntaxOf('sqrt')[0:2], 'tex' AssertEqual SyntaxOf('frac')[0:2], 'tex' Given markdown; $a b[$ c Execute (math ends with $): let g:vim_markdown_math=1 syn off | syn on AssertEqual SyntaxOf('a')[0:2], 'tex' AssertEqual SyntaxOf('b')[0:2], 'tex' AssertNotEqual SyntaxOf('c')[0:2], 'tex' Given markdown; $$a b[$$ c Execute (math ends with $$): let g:vim_markdown_math=1 syn off | syn on AssertEqual SyntaxOf('a')[0:2], 'tex' AssertEqual SyntaxOf('b')[0:2], 'tex' AssertNotEqual SyntaxOf('c')[0:2], 'tex' Given markdown; $(0 \leq 1)$ Execute (math conceal in $): if has('conceal') setlocal conceallevel=2 let g:vim_markdown_math=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1, '$' AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 AssertEqual synconcealed(1, 5)[0], 1, '\leq' AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 AssertEqual synconcealed(1, 8)[0], 1 AssertEqual synconcealed(1, 9)[0], 0 AssertEqual synconcealed(1, 10)[0], 0 AssertEqual synconcealed(1, 11)[0], 0 AssertEqual synconcealed(1, 12)[0], 1, '$' setlocal conceallevel=0 endif Given markdown; $$ \omega 0 \leq 1 $$ Execute (math conceal in $$): if has('conceal') setlocal conceallevel=2 let g:vim_markdown_math=1 syn off | syn on AssertEqual synconcealed(1, 1)[0], 1, '$$' AssertEqual synconcealed(2, 1)[0], 1, '\omega' AssertEqual synconcealed(3, 1)[0], 0, '0' AssertEqual synconcealed(3, 3)[0], 1, '\leq' AssertEqual synconcealed(3, 8)[0], 0, '1' AssertEqual synconcealed(4, 1)[0], 1, '$$' setlocal conceallevel=0 endif # YAML frontmatter Given markdown; --- a: b --- Execute (YAML frontmatter is controlled by the option): AssertNotEqual SyntaxOf('a')[0:3], 'yaml' let g:vim_markdown_frontmatter=1 syn off | syn on AssertEqual SyntaxOf('a')[0:3], 'yaml' let g:vim_markdown_frontmatter=0 syn off | syn on AssertNotEqual SyntaxOf('a')[0:3], 'yaml' Given markdown; --- a: b --- Execute (YAML frontmatter only works if it's the first thing in the file): let g:vim_markdown_frontmatter=1 syn off | syn on AssertNotEqual SyntaxOf('a')[0:3], 'yaml' Given markdown; --- a: b --- --- Execute (rules are not mistaken by YAML frontmatter delimiters): let g:vim_markdown_frontmatter=1 syn off | syn on AssertEqual SyntaxAt(5, 1), 'mkdRule' unlet g:vim_markdown_frontmatter # TOML frontmatter Given markdown; +++ a = "b" +++ Execute (TOML frontmatter is controlled by the option): syn off | syn on AssertNotEqual SyntaxOf('b'), 'tomlString' let g:vim_markdown_toml_frontmatter=1 syn off | syn on AssertEqual SyntaxOf('b'), 'tomlString' let g:vim_markdown_toml_frontmatter=0 syn off | syn on AssertNotEqual SyntaxOf('b'), 'tomlString' Given markdown; +++ a = "b" +++ Execute (TOML frontmatter only works if it's the first thing in the file): let g:vim_markdown_toml_frontmatter=1 syn off | syn on AssertNotEqual SyntaxOf('b'), 'tomlString' unlet g:vim_markdown_toml_frontmatter # JSON frontmatter Given markdown; { "a": "b" } Execute (JSON frontmatter is controlled by the option): syn off | syn on AssertNotEqual SyntaxOf('a'), 'jsonKeyword' let g:vim_markdown_json_frontmatter=1 syn off | syn on AssertEqual SyntaxOf('a'), 'jsonKeyword' let g:vim_markdown_json_frontmatter=0 syn off | syn on AssertNotEqual SyntaxOf('a'), 'jsonKeyword' Given markdown; { "a": "b" } Execute (JSON frontmatter only works if it's the first thing in the file): let g:vim_markdown_json_frontmatter=1 syn off | syn on AssertNotEqual SyntaxOf('a'), 'jsonKeyword' unlet g:vim_markdown_json_frontmatter # Header Given markdown; # #a ccc ## #b ddd Execute (header title starts with #): AssertEqual SyntaxOf('a'), 'htmlH1' AssertEqual SyntaxOf('b'), 'htmlH2' Given markdown; # h1 space #h1 nospace # h1 2 spaces # h1 trailing hash # ## h2 space ##h2 nospace ## h2 trailing hash ## ### h3 space ###h3 nospace ### h3 trailing hash ### #### h4 ##### h5 ###### h6 Execute (atx headers): AssertEqual SyntaxOf(' h1 space'), 'htmlH1' AssertEqual SyntaxOf('h1 nospace'), 'htmlH1' AssertEqual SyntaxOf(' h1 2 spaces'), 'htmlH1' AssertEqual SyntaxOf(' h1 trailing hash '), 'htmlH1' AssertEqual SyntaxOf(' h2 space'), 'htmlH2' AssertEqual SyntaxOf('h2 nospace'), 'htmlH2' AssertEqual SyntaxOf(' h2 trailing hash '), 'htmlH2' AssertEqual SyntaxOf(' h3 space'), 'htmlH3' AssertEqual SyntaxOf('h3 nospace'), 'htmlH3' AssertEqual SyntaxOf(' h3 trailing hash '), 'htmlH3' AssertEqual SyntaxOf(' h4'), 'htmlH4' AssertEqual SyntaxOf(' h5'), 'htmlH5' AssertEqual SyntaxOf(' h6'), 'htmlH6' Given markdown; # h1 before h2 ## h2 between h1s # h1 after h2 Execute (atx headers relative positions): AssertEqual SyntaxOf(' h1 before h2'), 'htmlH1' AssertEqual SyntaxOf(' h2 between h1s'), 'htmlH2' AssertEqual SyntaxOf(' h1 after h2'), 'htmlH1' Given markdown; setex h1 ======== setex h2 -------- setex h1 single punctuation = setex h1 punctuation longer than header ================================ Execute (setex headers): AssertEqual SyntaxOf('setex h1'), 'htmlH1' AssertEqual SyntaxOf('^========$'), 'htmlH1' AssertEqual SyntaxOf('setex h2'), 'htmlH2' AssertEqual SyntaxOf('--------'), 'htmlH2' AssertEqual SyntaxOf('setex h1 single punctuation'), 'htmlH1' AssertEqual SyntaxOf('^=$'), 'htmlH1' AssertEqual SyntaxOf('setex h1 punctuation longer than header'), 'htmlH1' AssertEqual SyntaxOf('^================================$'), 'htmlH1' Given markdown; - not Setex - because list Execute (prevent list vs Setex confusion): AssertNotEqual SyntaxOf('- not Setex'), 'htmlH2' AssertNotEqual SyntaxOf('- becuase list'), 'htmlH2' Given markdown; setex h1 before atx =================== ## atx h2 ### atx h3 # atx h1 setex h2 ------------------ ### atx h3 2 Execute (mixed atx and setex headers): AssertEqual SyntaxOf('setex h1 before atx'), 'htmlH1' AssertEqual SyntaxOf('==================='), 'htmlH1' AssertEqual SyntaxOf(' atx h2'), 'htmlH2' AssertEqual SyntaxOf(' atx h3'), 'htmlH3' AssertEqual SyntaxOf(' atx h1'), 'htmlH1' AssertEqual SyntaxOf('setex h2'), 'htmlH2' AssertEqual SyntaxOf('------------------'), 'htmlH2' # List Given markdown; - a & b 1. c > d Execute (& and > are not marked as htmlError in lists): AssertEqual SyntaxOf('-'), 'mkdListItem' AssertEqual SyntaxOf('1.'), 'mkdListItem' AssertNotEqual SyntaxOf('&'), 'htmlError' AssertNotEqual SyntaxOf('>'), 'htmlError' Given markdown; 1. a 2. b Execute (list after line break): AssertEqual SyntaxOf('1'), 'mkdListItem' AssertEqual SyntaxOf('2'), 'mkdListItem' # HTML Given markdown; a <p>b</p> - <span>c</span> Execute (HTML tag in text): AssertEqual SyntaxOf('p'), 'htmlTagName' AssertEqual SyntaxOf('<p>'), 'htmlTag' AssertEqual SyntaxOf('</p>'), 'htmlEndTag' AssertEqual SyntaxOf('span'), 'htmlTagName' AssertEqual SyntaxOf('<span>'), 'htmlTag' AssertEqual SyntaxOf('</span>'), 'htmlEndTag' 07070100000028000081A400000000000000000000000163314A470000053D000000000000000000000000000000000000003400000000vim-markdown-2.0.0+20220926/test/table-format.vaderBefore: let &gdefault = 1 After: let &gdefault = 0 Given markdown; | normal |no space| 2 spaces || | - |-| --- || | normal |no space| 2 spaces || Execute (format unformatted table): TableFormat Expect (table is formatted): | normal | no space | 2 spaces | | |--------|----------|----------|--| | normal | no space | 2 spaces | | Given markdown; | a | b | |---|---| | c | d | Execute (format well formatted table): TableFormat Expect (table is not modified): | a | b | |---|---| | c | d | Given markdown (indented table); | a | b | |---|---| | c | d | Execute (format well formatted, indented table): TableFormat Expect (table is not modified): | a | b | |---|---| | c | d | Given markdown; | left |right| center || | :- | --: |:---:|:| | left |right| center || Execute (format table with colons): TableFormat Expect (preserve colons to align text): | left | right | center | | |:-----|------:|:------:|:--| | left | right | center | | Given markdown (indented table with colons); | left |right| center || | :- | --: |:---:|:| | left |right| center || Execute (format indented table with colons): TableFormat Expect (preserve colons to align text): | left | right | center | | |:-----|------:|:------:|:--| | left | right | center | | 07070100000029000081A400000000000000000000000163314A470000031E000000000000000000000000000000000000003300000000vim-markdown-2.0.0+20220926/test/toc-autofit.vader" Tests toc window auto-fit to longest header, but without exceeding half screen. Given markdown; # chap 1 # chap 2 # chap 3 # chap 4 # chap 5 # chap 6 # chap 7 # chap 8 # chap 9 # chap 10 # chap 11 # chap 12 ## chap 12.1 ### chap 12.1.1 #### chap 12.1.1.1 ##### chap 12.1.1.1.1 ###### chap 12.1.1.1.1.1 # chap 13 Execute (toc window autofit width): set number let g:vim_markdown_toc_autofit = 1 let line = '###### chap 12.1.1.1.1.1' AssertEqual getline('33'), line :Toc let real_width = winwidth(0) :lclose let expected_width = len(line) + 2*5 + 1 + 3 - 7 AssertEqual real_width, expected_width set nonumber " 2 spaces * 5 additional header levels + 1 space for first header + " 3 spaces for line numbers - 7 chars ('###### ') that don't show up on the TOC 0707010000002A000081A400000000000000000000000163314A4700000741000000000000000000000000000000000000002B00000000vim-markdown-2.0.0+20220926/test/toc.vaderGiven markdown; # a Execute (Toc does not set nomodifiable on other files): " Sanity check. Assert &modifiable :Toc :lclose :edit a Assert &modifiable Given markdown; header 1 ======== test header 2 -------- test ### header 3 test Execute (Toc setex headers): :Toc Expect (setex headers): header 1 header 2 header 3 Given markdown; # header 1 test ## header 2 test ### header 3 test Execute (Toc atx headers): :Toc Expect (atx headers): header 1 header 2 header 3 Given markdown; ATX tests. # h1 space #h1 nospace # h1 2 spaces # h1 trailing hash # ## h2 space ##h2 nospace ## h2 trailing hash ## ### h3 space ###h3 nospace ### h3 trailing hash ### #### h4 ##### h5 ###### h6 --- Relative positions. # h1 before h2 ## h2 between h1s # h1 after h2 --- Setex tests. setex h1 ======== setex h2 -------- setex h1 single punctuation = setex h1 punctuation longer than header ================================ Prevent list vs Setex confusion: - not Setex - because list --- Mixed tests. setex h1 before atx =================== ## atx h2 ### atx h3 # atx h1 setex h2 ------------------ ### atx h3 2 Execute (Toc multiple headers): :Toc Expect (multiple headers): h1 space h1 nospace h1 2 spaces h1 trailing hash h2 space h2 nospace h2 trailing hash h3 space h3 nospace h3 trailing hash h4 h5 h6 h1 before h2 h2 between h1s h1 after h2 setex h1 setex h2 setex h1 single punctuation setex h1 punctuation longer than header setex h1 before atx atx h2 atx h3 atx h1 setex h2 atx h3 2 Execute: :lclose Given markdown; # header 1 ## header 2 ### header 3 Execute (Toc cursor on the current header): normal! G :Toc AssertEqual line('.'), 3 :lclose 0707010000002B000081A400000000000000000000000163314A470000030A000000000000000000000000000000000000002700000000vim-markdown-2.0.0+20220926/test/vimrcset nocompatible let $LANG='en_US' filetype off set runtimepath+=../ set runtimepath+=../build/tabular/ set runtimepath+=../build/vim-toml/ set runtimepath+=../build/vim-json/ set runtimepath+=../build/vader.vim/ filetype on filetype plugin indent on syntax enable function! Markdown_GetScriptID(fname) abort let l:snlist = '' redir => l:snlist silent! scriptnames redir END let l:mx = '^\s*\(\d\+\):\s*\(.*\)$' for l:line in split(l:snlist, "\n") if stridx(substitute(l:line, '\\', '/', 'g'), a:fname) >= 0 return substitute(l:line, l:mx, '\1', '') endif endfor endfunction function! Markdown_GetFunc(fname, funcname) abort return function('<SNR>' . Markdown_GetScriptID(a:fname) . '_' . a:funcname) endfunction 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!315 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor