add HTML processing for tags

Ref #85
This commit is contained in:
EinfachToll 2015-11-10 14:37:25 +01:00
parent 642a94ffae
commit 52634a6753
2 changed files with 23 additions and 0 deletions

View File

@ -289,6 +289,27 @@ function! s:tag_strong(value, header_ids) "{{{
\ .id.'">'.text.'</strong>' \ .id.'">'.text.'</strong>'
endfunction "}}} endfunction "}}}
function! s:tag_tags(value, header_ids) "{{{
let complete_id = ''
for level in range(6)
if a:header_ids[level][0] != ''
let complete_id .= a:header_ids[level][0].'-'
endif
endfor
if a:header_ids[5][0] == ''
let complete_id = complete_id[:-2]
endif
let complete_id = s:safe_html_anchor(complete_id)
let result = []
for tag in split(a:value, ':')
let id = s:safe_html_anchor(tag)
call add(result, '<span id="'.complete_id.'-'.id.'"></span><span class="tag" id="'
\ .id.'">'.tag.'</span>')
endfor
return join(result)
endfunction "}}}
function! s:tag_todo(value) "{{{ function! s:tag_todo(value) "{{{
return '<span class="todo">'.a:value.'</span>' return '<span class="todo">'.a:value.'</span>'
endfunction "}}} endfunction "}}}
@ -552,6 +573,7 @@ function! s:process_tags_typefaces(line, header_ids) "{{{
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub') let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code') let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin') let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin')
let line = s:make_tag(line, g:vimwiki_rxTags, 's:tag_tags', a:header_ids)
return line return line
endfunction " }}} endfunction " }}}

View File

@ -24,6 +24,7 @@ del {text-decoration: line-through; color: #777777;}
.justright {text-align: right;} .justright {text-align: right;}
.justcenter {text-align: center;} .justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;} .center {margin-left: auto; margin-right: auto;}
.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;}
/* classes for items of todo lists */ /* classes for items of todo lists */
.done0 { .done0 {