diff --git a/DesignNotes.wiki b/DesignNotes.wiki new file mode 100644 index 0000000..2b8705c --- /dev/null +++ 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 index 7986609..bbb1963 100644 --- 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 index ba2cc4c..dcb491d 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -344,7 +344,27 @@ endfunction function! s:tag_code(value) - return ''.s:safe_html_preformatted(s:mid(a:value, 1)).'' + let l:retstr = ' 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).'' + 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 index b1b2c77..e8de748 100644 --- 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 > + #ffe119 + ------------------------------------------------------------------------------ 5.2. Links *vimwiki-syntax-links* @@ -2064,13 +2070,17 @@ Each template could look like: > 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 index 217359f..7e812a4 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -635,13 +635,14 @@ vnoremap il :call vimwiki#lst#TO_list_item(1, 1) if !hasmapto('VimwikiAddHeaderLevel') nmap = VimwikiAddHeaderLevel endif -nnoremap VimwikiAddHeaderLevel :call vimwiki#base#AddHeaderLevel() +nnoremap VimwikiAddHeaderLevel : + \call vimwiki#base#AddHeaderLevel(v:count) if !hasmapto('VimwikiRemoveHeaderLevel') nmap - VimwikiRemoveHeaderLevel endif nnoremap VimwikiRemoveHeaderLevel : - \call vimwiki#base#RemoveHeaderLevel() + \call vimwiki#base#RemoveHeaderLevel(v:count) if !hasmapto('VimwikiGoToParentHeader') nmap ]u VimwikiGoToParentHeader