From 28727b3971f8daa5e251e6d684942483e522fe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 11 Oct 2018 14:25:55 +0200 Subject: [PATCH 1/9] Add %wiki_path% template variable. --- autoload/vimwiki/html.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index bce5465..54a8346 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -1533,6 +1533,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) @@ -1541,6 +1542,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') From 6f7e40ff781994564a680f402003178e8f7f95e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 21 Oct 2018 20:50:16 +0200 Subject: [PATCH 2/9] Add short documentation for %wiki_path%. --- doc/vimwiki.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index fcea9eb..01e3bfd 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1475,6 +1475,14 @@ The date of the wiki page. The value can be used in the HTML template, see If you omit the date after the placeholder, the date of the HTML conversion is used. +------------------------------------------------------------------------------ +%wiki_path% *vimwiki-path* + +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. ============================================================================== 8. Lists *vimwiki-lists* From 21f5069e48d92af17a0b8b805342e956282e19ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 26 Jan 2019 10:29:29 +0100 Subject: [PATCH 3/9] Code-blocks auto-color. --- autoload/vimwiki/html.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index ba2cc4c..243189a 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -344,7 +344,17 @@ endfunction function! s:tag_code(value) - return ''.s:safe_html_preformatted(s:mid(a:value, 1)).'' + let l:retstr = '' + return l:retstr endfunction From 08ec02a7554e9981967f0a4443ea310b7fbdccd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 19 Feb 2019 21:04:57 +0100 Subject: [PATCH 4/9] Alternative where text color is inverse of background. --- autoload/vimwiki/html.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 243189a..b9ed95c 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -349,8 +349,12 @@ function! s:tag_code(value) 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:retstr .= " style='background-color: " . l:str . ";'" + let l:inv_color = 0xFFFFFF - eval("0x" . l:str[1:]) + + let l:retstr .= printf(" style='background-color: %s; color: #%x;'", + \ l:str, l:inv_color) endif let l:retstr .= '>'.s:safe_html_preformatted(l:str).'' From b4c9a4f0289733c69fffa6e71f52abcaf1ebe0f8 Mon Sep 17 00:00:00 2001 From: Henry Qin Date: Sun, 17 Mar 2019 10:43:12 -0700 Subject: [PATCH 5/9] Add DesignNotes.wiki, a place for internal documentation --- DesignNotes.wiki | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 DesignNotes.wiki 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. From 8941508e359e2edc546e39d54b3fc6d5c78b9493 Mon Sep 17 00:00:00 2001 From: Henry Qin Date: Mon, 11 Feb 2019 14:29:17 -0800 Subject: [PATCH 6/9] Allow AddHeaderLevel and RemoveHeaderLevel to take counts --- autoload/vimwiki/base.vim | 10 ++++++++-- ftplugin/vimwiki.vim | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) 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/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 2d3688b..3f02ab9 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -633,13 +633,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 From 6f687aff5257cb3867fe3f8586f6234e4c15ba54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 17 Mar 2019 22:22:55 +0100 Subject: [PATCH 7/9] Move location of %wiki_path% documentation. --- doc/vimwiki.txt | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 01e3bfd..c88d7a6 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1475,14 +1475,6 @@ The date of the wiki page. The value can be used in the HTML template, see If you omit the date after the placeholder, the date of the HTML conversion is used. ------------------------------------------------------------------------------- -%wiki_path% *vimwiki-path* - -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. ============================================================================== 8. Lists *vimwiki-lists* @@ -2051,13 +2043,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 From 2f87f92060a154f71416e8ac84dc48d96c03dc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 17 Mar 2019 22:40:34 +0100 Subject: [PATCH 8/9] Better foreground for colorcodes. --- autoload/vimwiki/html.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index b9ed95c..0ad9ea4 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -349,12 +349,18 @@ function! s:tag_code(value) 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:inv_color = 0xFFFFFF - eval("0x" . l:str[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:retstr .= printf(" style='background-color: %s; color: #%x;'", - \ l:str, l:inv_color) + 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).'' From da52523710af2f6252eae8fe02ff147e7d498d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 17 Mar 2019 22:50:56 +0100 Subject: [PATCH 9/9] Add documentation for colorcodes. --- doc/vimwiki.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 4f935e5..457b1f3 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -880,6 +880,12 @@ is decorated: > 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*