Skip to content

Commit 3c36a25

Browse files
feature! Add more user commands, breaks existing toggle command
## Details Rather than the single toggle command add explicit enable, disable, and toggle commands. So as not to pollute the command space nest these under a single top level 'RenderMarkdown' command which takes a subcommand argument. By default run enable if no arugments are passed in. To fix the breaking change modify any user commands: - 'RenderMarkdownToggle' -> 'RenderMarkdown toggle' Related issue: #72 This should enable lazy loading on the RenderMarkdown command. Unrelated change: modify how demos are recorded, slow them down.
1 parent 4ab8359 commit 3c36a25

File tree

16 files changed

+122
-61
lines changed

16 files changed

+122
-61
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ use({
8888

8989
# Commands
9090

91-
`:RenderMarkdownToggle` - Switch between enabling & disabling this plugin
92-
93-
- Function can also be accessed directly through `require('render-markdown').toggle()`
91+
- `:RenderMarkdown` | `:RenderMarkdown enable` - Enable this plugin
92+
- Can also be accessed directly through `require('render-markdown').enable()`
93+
- `:RenderMarkdown disable` - Disable this plugin
94+
- Can also be accessed directly through `require('render-markdown').disable()`
95+
- `:RenderMarkdown toggle` - Switch between enabling & disabling this plugin
96+
- Can also be accessed directly through `require('render-markdown').toggle()`
9497

9598
# Setup
9699

demo/box_dash_quote.gif

4.19 KB
Loading

demo/callout.gif

-8.16 KB
Loading

demo/heading_code.gif

6.44 KB
Loading

demo/latex.gif

6.64 KB
Loading

demo/list_table.gif

-4.67 KB
Loading

demo/record.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def main(cols: int, rows: int, file: str, cast: str, content: str) -> None:
1010
pyautogui.hotkey("`", "c")
1111
time.sleep(1.0)
1212

13-
# Get length of file so we can scroll down it
14-
num_lines = len(Path(file).read_text().splitlines())
13+
# Get lines so we know how to scroll down, account for starting on first line
14+
lines: list[str] = Path(file).read_text().splitlines()[1:]
1515

1616
# Start recording demo file
1717
# https://docs.asciinema.org/manual/cli/usage/
@@ -29,17 +29,18 @@ def main(cols: int, rows: int, file: str, cast: str, content: str) -> None:
2929
pyautogui.press("o")
3030
pyautogui.press("enter")
3131
pyautogui.write(content, interval=0.1)
32-
3332
# Enter normal mode
3433
pyautogui.press("esc")
3534
time.sleep(2.0)
3635

3736
insert_normal(1)
3837

39-
# Slowly scroll down
40-
for _ in range(num_lines):
38+
# Scroll down
39+
for line in lines:
4140
pyautogui.press("j")
42-
time.sleep(0.1)
41+
skip = (" ", "def", "if")
42+
duration = 0 if len(line) == 0 or line.startswith(skip) else 0.75
43+
time.sleep(duration)
4344

4445
insert_normal(1)
4546

@@ -53,11 +54,11 @@ def main(cols: int, rows: int, file: str, cast: str, content: str) -> None:
5354
pyautogui.press("enter")
5455

5556

56-
def insert_normal(seconds: float) -> None:
57+
def insert_normal(duration: float) -> None:
5758
pyautogui.press("i")
58-
time.sleep(seconds)
59+
time.sleep(duration)
5960
pyautogui.press("esc")
60-
time.sleep(seconds)
61+
time.sleep(duration)
6162

6263

6364
if __name__ == "__main__":

doc/limitations.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66

77
`LaTeX` formula evaluations are placed above text rather than overlayed.
88

9+
# Resolved Limitations
10+
911
## Telescope Opening File
1012

13+
[FIX 4ab8359](https://github.com/MeanderingProgrammer/markdown.nvim/commit/4ab835985de62b46b6785ae160f5f709b77a0f92)
14+
15+
Should no longer be an issue on any version of neovim if up to date.
16+
1117
Since `telescope` performs several mode change operations to enable previewing and
1218
other nice things like setting `marks` when changing buffers there are scenarios
1319
where a `markdown` file will not render when it is initially opened through `telescope`.
@@ -23,8 +29,6 @@ Something about the way these are done causes the file to appear be opened in `i
2329
mode despite being in `normal` mode. Additionally there is no `ModeChanged` event
2430
that occurs after this to go back to `normal` mode.
2531

26-
# Resolved Limitations
27-
2832
## Text Boundaries
2933

3034
[FIX 5ce3566](https://github.com/MeanderingProgrammer/markdown.nvim/commit/5ce35662725b1024c6dddc8d0bc03befc5abc878)

doc/render-markdown.txt

Lines changed: 7 additions & 4 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 16
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 July 18
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -123,9 +123,12 @@ PACKER.NVIM *render-markdown-install-packer.nvim*
123123
==============================================================================
124124
5. Commands *render-markdown-commands*
125125

126-
`:RenderMarkdownToggle` - Switch between enabling & disabling this plugin
127-
128-
- Function can also be accessed directly through `require('render-markdown').toggle()`
126+
- `:RenderMarkdown` | `:RenderMarkdown enable` - Enable this plugin
127+
- Can also be accessed directly through `require('render-markdown').enable()`
128+
- `:RenderMarkdown disable` - Disable this plugin
129+
- Can also be accessed directly through `require('render-markdown').disable()`
130+
- `:RenderMarkdown toggle` - Switch between enabling & disabling this plugin
131+
- Can also be accessed directly through `require('render-markdown').toggle()`
129132

130133

131134
==============================================================================

justfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ test:
99
health:
1010
nvim -c "checkhealth render-markdown" -- .
1111

12-
demo-all: demo-heading demo-list demo-box demo-latex demo-callout
12+
demo: demo-heading demo-list demo-box demo-latex demo-callout
1313

1414
demo-heading:
15-
just demo "heading_code" "30" "## Heading 2"
15+
just demo-file "heading_code" "30" "## Heading 2"
1616

1717
demo-list:
18-
just demo "list_table" "30" ""
18+
just demo-file "list_table" "30" ""
1919

2020
demo-box:
21-
just demo "box_dash_quote" "15" ""
21+
just demo-file "box_dash_quote" "15" ""
2222

2323
demo-latex:
24-
just demo "latex" "15" ""
24+
just demo-file "latex" "15" ""
2525

2626
demo-callout:
27-
just demo "callout" "40" ""
27+
just demo-file "callout" "40" ""
2828

29-
demo file rows content:
29+
demo-file file rows content:
3030
rm -f demo/{{file}}.gif
3131
python demo/record.py \
3232
--cols "60" \

0 commit comments

Comments
 (0)