obsidian.nvim
obsidian.nvim copied to clipboard
Code blocks with conceallevel
I am trying to add code blocks to my documentation but due to the conceallevel, the backticks dissapear, is there a way to tell obsidian to overlay the backtick block because I would like to keep the rest of the UI features enabled
I'd like this feature too.
I tried to fix this myself by adding an autocommand to check if the current line contains backticks and ignore the conceallevel, but I couldn't get it to work correctly.
Is there any progress on the backticks? I was going to open an issue until I saw this one
The workaround I'm currently using for this is to set a replacement character for the concealed triple backtick (```) Making the code block to look like this:
Still not ideal, but at least gives me an indication that this is a code block
I have configured a VimEnter autocmd for that:
vim.api.nvim_create_autocmd('VimEnter', {
callback = function()
vim.cmd [[
augroup MarkdownSyntaxMatch
autocmd!
autocmd FileType markdown syntax match @conceal /```/ conceal cchar=⋯
augroup END
]]
end,
})
You can also set a different character for the triple backticks of the end of the codeblock by changing the match pattern:
syntax match @conceal /```\n/ conceal cchar=x
I'm also suffering from this issue and I would really like a nicer solution to this problem. Maybe a way to only add concealing to your vault folder or a way to do some conceal "scaping".
@igorMSoares Thanks for the autocommand. Although it has a slight issue that when I have ```bash
it will display the concealment characters 7 times, 3 for the backticks and 4 for bash. I tried playing around with the regex expression but I couldn't get it to work. Any ideas on how to fix this?
@gfvioli I started noticing this issue just a couple of days after I commented here with the autocommand. Something has changed after that, that's why in the screenshot I posted the whole ```ts
is replaced with the replacement character. Since then I haven't had the time to figure out why the behaviour has changed or to try any workaround. Looking forward to see if someone has got any ideas about it.