Merge branch 'wiki-path' into 'dev'. Closes #573.

Introduce a `%wiki_path%` variable which can be used in HTML template
files to output the path of the wiki file being converted to HTML.
This commit is contained in:
Henry Qin 2019-03-17 18:14:17 -07:00
commit efcc3f1fa5
2 changed files with 11 additions and 5 deletions

View File

@ -1549,6 +1549,7 @@ function! s:convert_file(path_html, wikifile)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let date = s:process_date(placeholders, strftime('%Y-%m-%d')) 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) let html_lines = s:get_html_template(template_name)
@ -1557,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, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'. call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")') \ 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 = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g') let css_name = substitute(css_name, '\', '/', 'g')

View File

@ -2064,13 +2064,17 @@ Each template could look like: >
</html> </html>
where where
%title% is replaced by a wiki page name or by a |vimwiki-title| `%title%` is replaced by a wiki page name or by a |vimwiki-title|
%date% is replaced with the current date or by |vimwiki-date| `%date%` is replaced with the current date or by |vimwiki-date|
%root_path% is replaced by a count of ../ for pages buried in subdirs: `%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 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 The default template will be applied to all wiki pages unless a page specifies