Skip to content

Commit 46b2aac

Browse files
authored
Merge pull request #2 from jdbaldry/2023-07-add-support-for-escaped-shortcodes
Ignore tokens in shortcodes with comment syntax
2 parents 6412e60 + 99da30d commit 46b2aac

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

testdata/shortcodes/.vale.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
BasedOnStyles = Vale
33

44
# Exclude `{{< ... >}}`, `{{% ... %}}`, [Who]({{< ... >}})
5-
TokenIgnores = ({{[%<] .* [%>]}}.*?{{[%<] ?/.* [%>]}}), \
6-
(\[.+\]\({{< .+ >}}\)), \
7-
({{[%<] .+ [%>]}})
5+
TokenIgnores = ({{[%<](?:/\*)? .* (?:\*/)?[%>]}}.*?{{[%<](?:/\*| )?/.* (?:\*/)?[%>]}}), \
6+
(\[.+\]\({{<(?:/\*)? .+ (?:\*/)?>}}\)), \
7+
({{[%<](?:/\*)? .+ (?:\*/)?[%>]}})
88

99
# Exclude `{{< myshortcode `This is some <b>HTML</b>, ... >}}`
10-
BlockIgnores = (?sm)^({{[%<] [^{]*? [%>]}})\n$, \
11-
(?s) *({{< highlight [^>]* ?>}}.*?{{< ?/ ?highlight >}}), \
12-
({{[%<] .+ [%>]}})
10+
BlockIgnores = (?sm)^({{[%<](?:/\*)? [^{]*? (?:\*/)?[%>]}})\n$, \
11+
(?s) *({{<(?:/\*)? highlight [^>]*(?:\*/| )?>}}.*?{{<(?:/\*| )?/ ?highlight (?:\*/)?>}}), \
12+
({{[%<](?:/\*)? .+ (?:\*/)?[%>]}})

testdata/shortcodes/test.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ Shortcodes are non-standard markup that appears within normal Markdown.
6060
Shortcodes can be used {{< myshortcode src="/media/spf13.jpg" title="Steve Francia" >}} inside a paragraph.
6161

6262
Shortcodes are non-standard markup that appears within normal Markdown.
63+
64+
To escape shortcodes, use the Hugo comment syntax.
65+
For example:
66+
67+
- {{</* commentedoutshortcode */>}}
68+
- {{</* /closecommentedoutshortcode */>}}
69+
- {{%/* commentedoutshortcodemd */%}}
70+
- {{%/* /closecommentedoutshortcodemd */%}}

testdata/test.ct

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$ cdf ${ROOTDIR}/shortcodes
2-
$ vale --output=line --sort --normalize --relative --no-exit test.md
2+
$ vale --config .vale.ini --output=line --sort --normalize --relative --no-exit test.md
33
test.md:1:3:Vale.Spelling:Did you really mean 'Shortcodes'?
44
test.md:3:3:Vale.Spelling:Did you really mean 'Shortcodes'?
55
test.md:8:1:Vale.Spelling:Did you really mean 'Shortcodes'?
@@ -15,3 +15,4 @@ test.md:54:1:Vale.Spelling:Did you really mean 'Shortcodes'?
1515
test.md:58:1:Vale.Spelling:Did you really mean 'Shortcodes'?
1616
test.md:60:1:Vale.Spelling:Did you really mean 'Shortcodes'?
1717
test.md:62:1:Vale.Spelling:Did you really mean 'Shortcodes'?
18+
test.md:64:11:Vale.Spelling:Did you really mean 'shortcodes'?

0 commit comments

Comments
 (0)