Skip to content
Convert mark.vim highlighting to markup inside the text.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
autoload
doc
plugin
tests
.gitignore
MarkMarkup.manifest
README.md

README.md

MARK MARKUP

by Ingo Karkat

DESCRIPTION

This plugin can persist the highlightings you've added to text via the mark.vim plugin (vimscript #2666) as markup - directly inside the text. Any kind of markup can be configured, and the plugin ships with predefined formats that use <span> tags (to render the text as HTML) in order to reproduce the original mark colors. Other formats append numbers[1] or symbols※, and additionally a legend listing all used marks and their names or patterns can be added to the buffer, too. [1] Example ※: \<s\w\+s\>

SEE ALSO

  • ExtractLinks.vim (vimscript #4870) uses a regular expression instead of marked text to identify text. Instead of appending the label, it replaces the text with it, and then collects references for use in a legend.

USAGE

:[range]MarkMarkup [N[,M]] [{format}]
                        Put markup [in the passed {format}] around each match
                        of any defined :Mark / the mark(s) with numbers [N]
                        to [M], in the current buffer / within [range].
                        Formats (e.g. HTML markup) are taken from
                        g:MarkMarkup_Formats. If more than one is defined,
                        a valid {format} has to be passed.

:[line]PutMarkLookup [N[,M]] [{format}]
                        Put a lookup table [for {format}] after [line]
                        (default current line). Depending on the format, this
                        could be the optional |:MarkName|s, or text attributes
                        and color definitions taken from the mark
                        highlightings. See g:MarkMarkup_Lookups.

The plugin ships with these default {format}s:

html                    Surrounds the marked text with an HTML <span> tag that
                        reproduces the mark's colors and text attributes. A
                        mark name is rendered as a title attribute, which the
                        browser usually shows on hover.
        <span style="color: #001e80; background-color: #a1b7ff">Lorem</span>
        <span title="latin" style="color: #80005d; background-color: #ffa1c6">ipsum</span>

css                     Surrounds the marked text with an HTML <span> tag that
                        works like the html format, but uses "markN" CSS
                        classes.
        <span class="mark1">Lorem</span> <span class="mark2" title="latin">ipsum</span>
                        The corresponding CSS definitions can be obtained via
                            :PutMarkLookup css
        .mark1 {
            color: #001e80;
            background-color: #a1b7ff;
        }
        .mark2 {
            color: #80005d;
            background-color: #ffa1c6;
        }

number                  Appends a [1], [2], ... counter behind each mark.
                        Lorem[1] ipsum[2]
                        A legend that maps those numbers to the mark's
                        name or (if unnamed) to the regular expression that
                        defines the mark can be inserted via
                            :PutMarkLookup number
                        [1] \<Lorem\>
                        [2] latin

symbol                  Like number, but appends a single-character (Unicode)
                        symbol, taken from g:MarkMarkup_Symbols.
                        Lorem※ ipsum†
                        ※: \<Lorem\>
                        †: latin

INSTALLATION

The code is hosted in a Git repo at https://github.com/inkarkat/vim-MarkMarkup You can use your favorite plugin manager, or "git clone" into a directory used for Vim packages. Releases are on the "stable" branch, the latest unstable development snapshot on "master".

This script is also packaged as a vimball. If you have the "gunzip" decompressor in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress the archive first, e.g. using WinZip. Inside Vim, install by sourcing the vimball or via the :UseVimball command.

vim MarkMarkup*.vmb.gz
:so %

To uninstall, use the :RmVimball command.

DEPENDENCIES

  • Requires Vim 7.0 or higher.
  • Requires the ingo-library.vim plugin (vimscript #4433), version 1.037 or higher.
  • Requires the mark.vim plugin (vimscript #2666), version 3.0.0 or higher.
  • Requires the PatternsOnText.vim plugin (vimscript #4602), version 2.11 or higher.

CONFIGURATION

For a permanent configuration, put the following commands into your vimrc:

The available markup formats are configured as a Dictionary of {format} keys mapping to a Funcref that is passed an object with the following attributes:

  • number: the number of the mark, starting with 1
  • name: the name given to the mark via :MarkName, or empty
  • pattern: the regular expression that defines the mark It should return a List of [{prefix}, {suffix}].
let g:MarkMarkup_Formats = {'html': function('MarkToHtml')}

The global configuration can be overwritten by a buffer-local one.

The available markup lookups are configured as a Dictionary of {format} keys mapping to a Funcref (like above). Here, it should return a String or a List. All lookups are then concatenated; Strings as-is (without separator), each List element as a separate line.

let g:MarkMarkup_Lookups = {'html': function('MarkToHtmlLookup')}

The global configuration can be overwritten by a buffer-local one.

String of (single-character) symbols to be used (from left to right) for the default "symbol" format.

CONTRIBUTING

Report any bugs, send patches, or suggest features via the issue tracker at https://github.com/inkarkat/vim-MarkMarkup/issues or email (address below).

HISTORY

GOAL

First published version.

0.01 19-Mar-2019
  • Started development.

Copyright: (C) 2019 Ingo Karkat - The VIM LICENSE applies to this plugin.

Maintainer: Ingo Karkat <ingo@karkat.de>

You can’t perform that action at this time.