You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: ability to conceal text based on lua patterns
## Details
Request: #397
Adds new top level `document` configuration. The main part of this new
configuration is a nested `conceal` configuration which contains two
fields, `char_patterns` & `line_patterns`.
These 2 fields will have their values iterated over the top level
`markdown` document node text and any ranges that match the text will be
concealed. The difference in behavior is the kind of mark that gets
added over the range.
- char_patterns: `conceal = ''` characters in the range are hidden but
lines rest of line if any is still visible.
- line_patterns: `conceal_lines = ''` entire lines are hidden even if
match is partial, will unfold when user cursor enters the range,
requires neovim `0.11.0` as that is when horizontal conceal was added.
This plugin does not do anything clever for the ranges and will at no
time support doing anything outside of the bounds of lua patterns. It is
entirely up to the user to make good patterns, i.e. using `-` instead of
`+/*` for non-greedy matches, capturing the start of line or start of
document patterns, and any other specific behavior they want.
Any issues opened about how to make a pattern do something or why does
some pattern match like this will be auto-closed, lua patterns are well
defined and easy to iterate and test with.
Providing some examples below:
- Hiding words surrounded by `:`, i.e. `:conceal-me:`:
```lua
require('render-markdown').setup({
document = {
conceal = {
char_patterns = { ':%S-:%s' },
},
},
})
```
- Hiding minus metadata
```lua
require('render-markdown').setup({
document = {
conceal = {
line_patterns = {
'^%-%-%-\n.-\n%-%-%-\n', -- start
'\n%-%-%-\n.-\n%-%-%-\n', -- middle
},
},
},
})
```
- Hiding plus metadata
```lua
require('render-markdown').setup({
document = {
conceal = {
line_patterns = {
'^%+%+%+\n.-\n%+%+%+\n', -- start
'\n%+%+%+\n.-\n%+%+%+\n', -- middle
},
},
},
})
```
0 commit comments