Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inline code spans inside emphasis #709

Closed
davidsierradz opened this issue May 15, 2019 · 3 comments
Closed

Support inline code spans inside emphasis #709

davidsierradz opened this issue May 15, 2019 · 3 comments
Labels
enhancement good first issue markdown Problems specific to markdown syntax

Comments

@davidsierradz
Copy link
Contributor

I think conceal is broken when using backticks inside bold or italic sentences:

Input Spec Vimwiki rendering
**hello `world`** hello world **hello world**
*hello `world`* hello world *hello world*

init.vim:

let g:vimwiki_list = [
      \ {'path': '~/notes/',
      \ 'links_space_char': '-',
      \ 'syntax': 'markdown', 'ext': '.md'}]

let g:vimwiki_global_ext = 0

let g:vimwiki_folding = 'custom'

let g:vimwiki_auto_header = 1

nnoremap <F4> "=strftime("%Y-%m-%d_%H:%M:%S")<CR>P
inoremap <F4> <C-R>=strftime("%Y-%m-%d_%H:%M:%S")<CR>
iab <expr> dts strftime("%Y-%m-%d_%H:%M:%S")

autocmd FileType vimwiki setlocal fdm=marker fmr={{{,}}}
:VimwikiShowVersion

Branch: dev

Revision: cf8a16c

Date: 2019-05-11 14:01:45 -0600
@ranebrown ranebrown added enhancement markdown Problems specific to markdown syntax labels May 16, 2019
@ranebrown
Copy link
Contributor

See commonmark spec rule 17 and example 477.

@ranebrown ranebrown changed the title Conceal is broken when using backticks inside bold or italic sentences Support inline code spans inside emphasis May 16, 2019
@tinmarino
Copy link
Member

Also the "inline" code must support multiple lines as example 635 and issue #847

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Aug 3, 2020
…imwiki#709)

More syntax pattern are defined as regions => Faster, enable nesting
@tinmarino
Copy link
Member

tinmarino commented Aug 3, 2020

I'm happy to announce that this has been fixed by the last referencing commit: 94a7885 in the dev branch

Commit Description

  • It uses regions syntaxes instead of previous matches:

    function! vimwiki#u#hi_tag(tag_pre, tag_post, syntax_group, contains, ...) abort
    let opt_is_contained = a:0 > 0 && a:1 > 0 ? 'contained ' : ''
    let opt_more = a:0 > 1 ? ' ' . a:2 : ''
    let opt_contains = ''
    if a:contains !=# ''
    let opt_contains = 'contains=' . a:contains . ' '
    endif
    let cmd = 'syn region ' . a:syntax_group . ' matchgroup=VimwikiDelimiter ' .
    \ opt_is_contained .
    \ 'start="' . a:tag_pre . '" ' .
    \ 'end="' . a:tag_post . '" ' .
    \ 'keepend ' .
    \ opt_contains .
    \ b:vimwiki_syntax_concealends .
    \ opt_more
    "echom cmd
    exe cmd
    endfunction

  • The magic of the nesting is from these lines:

    " Declare nesting capabilities
    " -- to be embeded in standard: bold, italic, underline
    let nested = 'VimwikiCode,VimwikiEqIn,VimwikiDelText,VimwikiSuperScript,VimwikiSubScript'
    " -- to be embeded in exetended (the one above)
    let nested .= ',VimwikiBold,VimwikiItalic,VimwikiUmderline'

  • It includes extended tests:

    Given vimwiki (Extended Types nested in basic):
    From __bold `code in bold ` end of bold__ morF
    From _it and ~~ strieout in i~~ end of it_ morF
    From __bold $ equation $ end bold __
    **bold ^superscript ^ end of bold morF**
    From normal ,, subscript ,, still normal morF
    Execute (Set syntax markdown):
    call SetSyntax('markdown')
    Execute (Assert Syntax extended types mono):
    AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
    AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
    AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 23)
    AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
    AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)

Screenshot

So at the end it looks like this (conceal=3, conceal=0)

Screenshot from 2020-08-03 18-50-44-vimwiki-typeface

Get strikethrough working (gnome-terminal, tmux)

To get the new strikethrough font, you need vim >= 8.1 and a terminfo well configured and not disconfigured by tmux or screen

Bashrc

if command -v tmux &> /dev/null && [ -n "$PS1" ] \
    && [[ ! "$TERM" =~ screen ]]  && [[ ! "$TERM" =~ "screen-256color" ]] \
    && [[ ! "$TERM" =~ tmux ]] && [[ ! "$TERM" =~ "tmux-256color" ]] \
    && [ -z "$TMUX" ]; then
  exec env TERM=tmux-256color tmux
fi

TmuxRc

# get strikethought
set -as terminal-overrides ',*:smxx=\E[9m'
set -g default-terminal "tmux-256color"

Thanks for the issue with such a nice array.

deepredsky pushed a commit to deepredsky/vimwiki that referenced this issue Jan 16, 2021
…imwiki#709)

More syntax pattern are defined as regions => Faster, enable nesting
jls83 pushed a commit to jls83/vimwiki that referenced this issue Jan 17, 2023
…imwiki#709)

More syntax pattern are defined as regions => Faster, enable nesting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue markdown Problems specific to markdown syntax
Projects
None yet
Development

No branches or pull requests

3 participants