commit 0c82d9dcb8a0d2808c2d5f142ee9c6eb7b50bf0f
parent 88a6820e9eefe4db4785dc20dd9b453340286591
Author: lyokha <alexey.radkov@gmail.com>
Date: Mon, 18 Mar 2019 13:13:30 +0300
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat:
5 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/DesignNotes.wiki b/DesignNotes.wiki
@@ -0,0 +1,5 @@
+= Design Notes =
+
+This file is meant to document design decisions and algorithms inside vimwiki
+which are too large for code comments, and not necessarily interesting to
+users. Please create a new section to document each behavior.
diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
@@ -1618,7 +1618,10 @@ function! vimwiki#base#TO_table_col(inner, visual)
endfunction
-function! vimwiki#base#AddHeaderLevel()
+function! vimwiki#base#AddHeaderLevel(...)
+ if a:1 > 1
+ call vimwiki#base#AddHeaderLevel(a:1 - 1)
+ endif
let lnum = line('.')
let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
@@ -1646,7 +1649,10 @@ function! vimwiki#base#AddHeaderLevel()
endfunction
-function! vimwiki#base#RemoveHeaderLevel()
+function! vimwiki#base#RemoveHeaderLevel(...)
+ if a:1 > 1
+ call vimwiki#base#RemoveHeaderLevel(a:1 - 1)
+ endif
let lnum = line('.')
let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH')
diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim
@@ -344,7 +344,27 @@ endfunction
function! s:tag_code(value)
- return '<code>'.s:safe_html_preformatted(s:mid(a:value, 1)).'</code>'
+ let l:retstr = '<code'
+
+ let l:str = s:mid(a:value, 1)
+ let l:match = match(l:str, '^#[a-fA-F0-9]\{6\}$')
+
+ if l:match != -1
+ let l:r = eval("0x".l:str[1:2])
+ let l:g = eval("0x".l:str[3:4])
+ let l:b = eval("0x".l:str[5:6])
+
+ let l:fg_color =
+ \ (((0.299 * r + 0.587 * g + 0.114 * b) / 0xFF) > 0.5)
+ \ ? "black" : "white"
+
+ let l:retstr .=
+ \ " style='background-color:" . l:str .
+ \ ";color:" . l:fg_color . ";'"
+ endif
+
+ let l:retstr .= '>'.s:safe_html_preformatted(l:str).'</code>'
+ return l:retstr
endfunction
@@ -1529,6 +1549,7 @@ function! s:convert_file(path_html, wikifile)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
+ let wiki_path = strpart(s:current_wiki_file, strlen(vimwiki#vars#get_wikilocal('path')))
let html_lines = s:get_html_template(template_name)
@@ -1537,6 +1558,7 @@ function! s:convert_file(path_html, wikifile)
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
+ call map(html_lines, 'substitute(v:val, "%wiki_path%", "'. wiki_path .'", "g")')
let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
@@ -892,6 +892,12 @@ For Markdown syntax these variations are used: >
Furthermore, there are a number of words which are highlighted extra flashy:
TODO, DONE, STARTED, FIXME, FIXED, XXX.
+When rendered as HTML, code blocks containing only a hash prefixed 6 digit hex
+number will be colored as themselves. For example >
+ `#ffe119`
+Becomes >
+ <code style='background-color:#ffe119;color:black;'>#ffe119</code>
+
------------------------------------------------------------------------------
5.2. Links *vimwiki-syntax-links*
@@ -2064,13 +2070,17 @@ Each template could look like: >
</html>
where
- %title% is replaced by a wiki page name or by a |vimwiki-title|
- %date% is replaced with the current date or by |vimwiki-date|
- %root_path% is replaced by a count of ../ for pages buried in subdirs:
+ `%title%` is replaced by a wiki page name or by a |vimwiki-title|
+ `%date%` is replaced with the current date or by |vimwiki-date|
+ `%root_path%` is replaced by a count of ../ for pages buried in subdirs:
if you have wikilink [[dir1/dir2/dir3/my page in a subdir]] then
- %root_path% is replaced by '../../../'.
+ `%root_path%` is replaced by '../../../'.
+ `%wiki_path%` Path to current wiki-file.` The file path to the current wiki
+ file. For example, if you are on page a/b.wiki %wiki-path% contains
+ "a/b.wiki". Mostly useful if you want to link the to raw wiki page from
+ the rendered version.
- %content% is replaced by a wiki file content.
+ `%content%` is replaced by a wiki file content.
The default template will be applied to all wiki pages unless a page specifies
diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
@@ -635,13 +635,14 @@ vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif
-nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :<C-U>call vimwiki#base#AddHeaderLevel()<CR>
+nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
+ \<C-U>call vimwiki#base#AddHeaderLevel(v:count)<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
- \<C-U>call vimwiki#base#RemoveHeaderLevel()<CR>
+ \<C-U>call vimwiki#base#RemoveHeaderLevel(v:count)<CR>
if !hasmapto('<Plug>VimwikiGoToParentHeader')
nmap <silent><buffer> ]u <Plug>VimwikiGoToParentHeader