Add html_filename_parameterization option.
This adds the vimwiki_local `html_filename_parameterization` option (0|1) which performs the same sanitization of filenames as does the vimwiki_markdown gem. For example, if your file is called "My File.md" it will be written out as "my-file.html". If the html_filename_parameterization options is enabled, we also _do not delete_ non-matching html files when the VimwikiAllToHtml command is run. Closes #129
This commit is contained in:
parent
ae67790ad5
commit
5f01182468
@ -239,8 +239,15 @@ function! s:is_html_uptodate(wikifile)
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
|
||||
if vimwiki#vars#get_wikilocal('html_filename_parameterization')
|
||||
let parameterized_wikiname = s:parameterized_wikiname(wikifile)
|
||||
let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') .
|
||||
\ vimwiki#vars#get_bufferlocal('subdir') . parameterized_wikiname)
|
||||
else
|
||||
let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') .
|
||||
\ vimwiki#vars#get_bufferlocal('subdir') . fnamemodify(wikifile, ":t:r").".html")
|
||||
endif
|
||||
|
||||
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
|
||||
return 1
|
||||
@ -248,6 +255,15 @@ function! s:is_html_uptodate(wikifile)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:parameterized_wikiname(wikifile)
|
||||
let initial = fnamemodify(a:wikifile, ":t:r")
|
||||
let lower_sanitized = tolower(initial)
|
||||
let substituted = substitute(lower_sanitized, '[^a-z0-9_-]\+',"-", "g")
|
||||
let substituted = substitute(substituted, '\-\+',"-", "g")
|
||||
let substituted = substitute(substituted, '^-', '', "g")
|
||||
let substituted = substitute(substituted, '-$', '', "g")
|
||||
return substitute(substituted, '\-\+',"-", "g") . ".html"
|
||||
endfunction
|
||||
|
||||
function! s:html_insert_contents(html_lines, content)
|
||||
let lines = []
|
||||
@ -1614,8 +1630,10 @@ function! vimwiki#html#WikiAll2HTML(path_html)
|
||||
let path_html = expand(a:path_html)
|
||||
call vimwiki#path#mkdir(path_html)
|
||||
|
||||
if !vimwiki#vars#get_wikilocal('html_filename_parameterization')
|
||||
echomsg 'Vimwiki: Deleting non-wiki html files ...'
|
||||
call s:delete_html_files(path_html)
|
||||
endif
|
||||
|
||||
echomsg 'Vimwiki: Converting wiki to html files ...'
|
||||
let setting_more = &more
|
||||
|
@ -281,6 +281,7 @@ function! s:populate_wikilocal_options()
|
||||
\ 'template_default': {'type': type(''), 'default': 'default', 'min_length': 1},
|
||||
\ 'template_ext': {'type': type(''), 'default': '.tpl'},
|
||||
\ 'template_path': {'type': type(''), 'default': $HOME . '/vimwiki/templates/'},
|
||||
\ 'html_filename_parameterization': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
|
||||
\ }
|
||||
|
||||
let g:vimwiki_wikilocal_vars = []
|
||||
|
@ -1802,6 +1802,16 @@ Get it from http://www.vim.org/scripts/script.php?script_id=52
|
||||
See |g:vimwiki_use_calendar| option to turn it off/on.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Markdown export
|
||||
|
||||
If you use markdown as the syntax for your wiki, there is a rubygem available
|
||||
at https://github.com/patrickdavey/vimwiki_markdown which you can use to
|
||||
convert the wiki markdown files into html.
|
||||
|
||||
Also See |vimwiki-option-html_filename_parameterization| for supporting
|
||||
functionality.
|
||||
|
||||
==============================================================================
|
||||
11. Anchors *vimwiki-anchors*
|
||||
|
||||
@ -2427,6 +2437,21 @@ generating links: >
|
||||
let g:vimwiki_list = [{'path': '~/my_site/', 'exclude_files': ['**/README.md']}]
|
||||
|
||||
|
||||
*vimwiki-option-html_filename_parameterization*
|
||||
------------------------------------------------------------------------------
|
||||
Key Default value Values~
|
||||
html_filename_parameterization 0 0, 1
|
||||
|
||||
Description~
|
||||
This setting is for integration with the vimwiki_markdown gem. If this is set
|
||||
to 1 it alters the check for generated html filenames to match what
|
||||
vimwiki_markdown generates. This means that it prevents unnecessary
|
||||
regeneration of HTML files.
|
||||
|
||||
This setting also turns off the automatic deletion of files
|
||||
in the site_html directory which don't match existing wiki files.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
12.4 Global Options *vimwiki-global-options*
|
||||
|
||||
@ -3256,6 +3281,12 @@ https://github.com/vimwiki-backup/vimwiki/issues.
|
||||
2.5 (in progress)~
|
||||
|
||||
New:~
|
||||
* PR #665: Integration with vimwiki_markdown gem
|
||||
https://github.com/patrickdavey/vimwiki_markdown
|
||||
This provides the |vimwiki-option-html_filename_parameterization|
|
||||
which alters the filenames vimiwiki checks against when running the
|
||||
html conversion. It also disables the deleting of html files which
|
||||
no longer match against a wiki file.
|
||||
* PR #663: New option |g:vimwiki_conceal_onechar_markers| to control
|
||||
whether to show or hide single-character format markers.
|
||||
* PR #636: Wiki local option |vimwiki-option-exclude_files| which is
|
||||
|
Loading…
Reference in New Issue
Block a user