Skip to content

Commit 15ee2d9

Browse files
Add more depth setting descriptions to README
1 parent 353e445 commit 15ee2d9

File tree

4 files changed

+281
-54
lines changed

4 files changed

+281
-54
lines changed

README.md

Lines changed: 123 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Plugin to improve viewing Markdown files in Neovim
1919
- Headings: highlight depending on level and replaces `#` with icon
2020
- Horizontal breaks: replace with full-width lines
2121
- Code blocks: highlight to better stand out
22-
- Adds language icon, requires `nvim-web-devicons` and neovim >= `0.10.0`
22+
- Adds language icon, requires icon provider (`mini.icons` or `nvim-web-devicons`)
23+
and neovim >= `0.10.0`
2324
- Inline code: highlight to better stand out
2425
- List bullet points: replace with provided icon based on level
2526
- Checkboxes: replace with provided icon based on whether they are checked
@@ -85,8 +86,15 @@ use({
8586

8687
# Setup
8788

88-
Below is the configuration that gets used by default, any part of it can be modified
89-
by the user.
89+
The full default configuration is provided below for reference.
90+
91+
Any part of it can be modified however for many fields this does not make much sense.
92+
93+
Some of the more useful fields are discussed further down.
94+
95+
<details>
96+
97+
<summary>Full Default Configuration</summary>
9098

9199
```lua
92100
require('render-markdown').setup({
@@ -214,14 +222,7 @@ require('render-markdown').setup({
214222
-- Background of heading line
215223
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
216224
-- Foreground of heading character only
217-
foregrounds = {
218-
'markdownH1',
219-
'markdownH2',
220-
'markdownH3',
221-
'markdownH4',
222-
'markdownH5',
223-
'markdownH6',
224-
},
225+
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
225226
},
226227
-- Horizontal break
227228
dash = 'LineNr',
@@ -257,6 +258,117 @@ require('render-markdown').setup({
257258
})
258259
```
259260

261+
</details>
262+
263+
There are 4 main types of settings:
264+
265+
1. Icon: the text that gets rendered
266+
2. Highlight: the color for text & backgrounds
267+
3. Style: how different components are rendered
268+
4. Window Options: handles conceal behavior
269+
270+
There are 2 main ways array like values are accessed:
271+
272+
1. Cycle: Indexed `mod` the length.
273+
Example: `{ 1, 2, 3 }` @ 4 = 1.
274+
2. Clamp: Indexed normally but larger values use the last value in the array.
275+
Example: `{ 1, 2, 3 }` @ 4 = 3.
276+
277+
## Icon
278+
279+
### headings
280+
281+
Replace the `#` characters in front of headings.
282+
283+
The number of `#` characters in the heading determines the level of the heading.
284+
285+
The level is used to index into the table using a cycle.
286+
287+
The icon is pre-pendeded with spaces to fill the gap and hide any additional `#`.
288+
289+
### dash
290+
291+
Gets repeated across the window's width when a `thematic_break` is found.
292+
293+
### bullets
294+
295+
Replace the `-`, `+`, and `*` characters in front of list items.
296+
297+
A different bullet is used depending on the level of nesting for the list item.
298+
299+
The nesting level is used to index into the table using a cycle.
300+
301+
If the character is before a checkbox, rather than changing the icon a conceal
302+
is used to hide the character.
303+
304+
### checkbox
305+
306+
The checked `[ ]` & unchecked `[x]` are directly replaced with these values.
307+
308+
### quote
309+
310+
Replaces the `|` character in front of `block_quotes`.
311+
312+
### callout
313+
314+
This is a special instance of a `block_quote`.
315+
316+
When the `callout` syntax is used the start, i.e. `[!NOTE]`, is replaced
317+
with this text.
318+
319+
## Highlight
320+
321+
Options are all contained in the `highlights` table.
322+
323+
For the most part the highlight group is used directly when writing the
324+
associated icons. We'll cover some of the specific behaviors.
325+
326+
### heading
327+
328+
Both `backgrounds` and `foregrounds` are indexed by the level of the heading
329+
using a clamp.
330+
331+
Both values are applied to the icon, however the background extends through
332+
the entire line.
333+
334+
### table
335+
336+
The `head` is used for the table heading, delimitter, and the line above.
337+
338+
The `row` is used for everything else, so the main table rows and the line below.
339+
340+
## Style
341+
342+
### code_style
343+
344+
Determines how `fenced_code_block`s are rendered.
345+
346+
- `none`: disables all rendering
347+
- `normal`: adds background highlight group to the code block
348+
- `full`: `normal` + language icon & name above the code block
349+
350+
### table_style
351+
352+
Determines how `table`s are rendered.
353+
354+
- `none`: disables all rendering
355+
- `normal`: applies the `cell_style` rendering to each row of the table
356+
- `full`: `normal` + a top & bottom line that fill out the table when lengths match
357+
358+
### cell_style
359+
360+
Determines how `table cell`s are rendered.
361+
362+
- `overlay`: writes completely over the table, removing conceal behavior and highlights
363+
- `raw`: replaces only the `|` icons in each row, leaving the cell completely unmodified
364+
365+
## Window Options
366+
367+
Options are all contained in the `win_options` table.
368+
369+
This changes the `conceallevel` & `concealcursor` when rendering. When not rendering
370+
the value is changed back to the users configured value.
371+
260372
# Additional Info
261373

262374
- [Limitations](doc/limitations.md): Known limitations of this plugin

doc/render-markdown.txt

Lines changed: 143 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 July 05
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 July 06
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -11,6 +11,10 @@ Table of Contents *render-markdown-table-of-contents*
1111
- packer.nvim |render-markdown-install-packer.nvim|
1212
5. Commands |render-markdown-commands|
1313
6. Setup |render-markdown-setup|
14+
- Icon |render-markdown-setup-icon|
15+
- Highlight |render-markdown-setup-highlight|
16+
- Style |render-markdown-setup-style|
17+
- Window Options |render-markdown-setup-window-options|
1418
7. Additional Info |render-markdown-additional-info|
1519

1620
==============================================================================
@@ -38,7 +42,8 @@ Plugin to improve viewing Markdown files in Neovim
3842
- Headings: highlight depending on level and replaces `#` with icon
3943
- Horizontal breaks: replace with full-width lines
4044
- Code blocks: highlight to better stand out
41-
- Adds language icon, requires `nvim-web-devicons` and neovim >= `0.10.0`
45+
- Adds language icon, requires icon provider (`mini.icons` or `nvim-web-devicons`)
46+
and neovim >= `0.10.0`
4247
- Inline code: highlight to better stand out
4348
- List bullet points: replace with provided icon based on level
4449
- Checkboxes: replace with provided icon based on whether they are checked
@@ -114,8 +119,14 @@ PACKER.NVIM *render-markdown-install-packer.nvim*
114119
==============================================================================
115120
6. Setup *render-markdown-setup*
116121

117-
Below is the configuration that gets used by default, any part of it can be
118-
modified by the user.
122+
The full default configuration is provided below for reference.
123+
124+
Any part of it can be modified however for many fields this does not make much
125+
sense.
126+
127+
Some of the more useful fields are discussed further down.
128+
129+
Full Default Configuration ~
119130

120131
>lua
121132
require('render-markdown').setup({
@@ -243,14 +254,7 @@ modified by the user.
243254
-- Background of heading line
244255
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
245256
-- Foreground of heading character only
246-
foregrounds = {
247-
'markdownH1',
248-
'markdownH2',
249-
'markdownH3',
250-
'markdownH4',
251-
'markdownH5',
252-
'markdownH6',
253-
},
257+
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
254258
},
255259
-- Horizontal break
256260
dash = 'LineNr',
@@ -286,6 +290,133 @@ modified by the user.
286290
})
287291
<
288292

293+
There are 4 main types of settings:
294+
295+
1. Icon: the text that gets rendered
296+
2. Highlight: the color for text & backgrounds
297+
3. Style: how different components are rendered
298+
4. Window Options: handles conceal behavior
299+
300+
There are 2 main ways array like values are accessed:
301+
302+
1. Cycle: Indexed `mod` the length.
303+
Example: `{ 1, 2, 3 }` @ 4 = 1.
304+
2. Clamp: Indexed normally but larger values use the last value in the array.
305+
Example: `{ 1, 2, 3 }` @ 4 = 3.
306+
307+
308+
ICON *render-markdown-setup-icon*
309+
310+
311+
HEADINGS ~
312+
313+
Replace the `#` characters in front of headings.
314+
315+
The number of `#` characters in the heading determines the level of the
316+
heading.
317+
318+
The level is used to index into the table using a cycle.
319+
320+
The icon is pre-pendeded with spaces to fill the gap and hide any additional
321+
`#`.
322+
323+
324+
DASH ~
325+
326+
Gets repeated across the window’s width when a `thematic_break` is found.
327+
328+
329+
BULLETS ~
330+
331+
Replace the `-`, `+`, and `*` characters in front of list items.
332+
333+
A different bullet is used depending on the level of nesting for the list item.
334+
335+
The nesting level is used to index into the table using a cycle.
336+
337+
If the character is before a checkbox, rather than changing the icon a conceal
338+
is used to hide the character.
339+
340+
341+
CHECKBOX ~
342+
343+
The checked `[ ]` & unchecked `[x]` are directly replaced with these values.
344+
345+
346+
QUOTE ~
347+
348+
Replaces the `|` character in front of `block_quotes`.
349+
350+
351+
CALLOUT ~
352+
353+
This is a special instance of a `block_quote`.
354+
355+
When the `callout` syntax is used the start, i.e.� `[!NOTE]`, is replaced with
356+
this text.
357+
358+
359+
HIGHLIGHT *render-markdown-setup-highlight*
360+
361+
Options are all contained in the `highlights` table.
362+
363+
For the most part the highlight group is used directly when writing the
364+
associated icons. We’ll cover some of the specific behaviors.
365+
366+
367+
HEADING ~
368+
369+
Both `backgrounds` and `foregrounds` are indexed by the level of the heading
370+
using a clamp.
371+
372+
Both values are applied to the icon, however the background extends through the
373+
entire line.
374+
375+
376+
TABLE ~
377+
378+
The `head` is used for the table heading, delimitter, and the line above.
379+
380+
The `row` is used for everything else, so the main table rows and the line
381+
below.
382+
383+
384+
STYLE *render-markdown-setup-style*
385+
386+
387+
CODE_STYLE ~
388+
389+
Determines how `fenced_code_block`s are rendered.
390+
391+
- `none`: disables all rendering
392+
- `normal`: adds background highlight group to the code block
393+
- `full`: `normal` + language icon & name above the code block
394+
395+
396+
TABLE_STYLE ~
397+
398+
Determines how `table`s are rendered.
399+
400+
- `none`: disables all rendering
401+
- `normal`: applies the `cell_style` rendering to each row of the table
402+
- `full`: `normal` + a top & bottom line that fill out the table when lengths match
403+
404+
405+
CELL_STYLE ~
406+
407+
Determines how `table cell`s are rendered.
408+
409+
- `overlay`: writes completely over the table, removing conceal behavior and highlights
410+
- `raw`: replaces only the `|` icons in each row, leaving the cell completely unmodified
411+
412+
413+
WINDOW OPTIONS *render-markdown-setup-window-options*
414+
415+
Options are all contained in the `win_options` table.
416+
417+
This changes the `conceallevel` & `concealcursor` when rendering. When not
418+
rendering the value is changed back to the users configured value.
419+
289420

290421
==============================================================================
291422
7. Additional Info *render-markdown-additional-info*

lua/render-markdown/init.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,7 @@ M.default_config = {
195195
-- Background of heading line
196196
backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' },
197197
-- Foreground of heading character only
198-
foregrounds = {
199-
'markdownH1',
200-
'markdownH2',
201-
'markdownH3',
202-
'markdownH4',
203-
'markdownH5',
204-
'markdownH6',
205-
},
198+
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
206199
},
207200
-- Horizontal break
208201
dash = 'LineNr',

0 commit comments

Comments
 (0)