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
{{ message }}
Repository navigation
Commit 6167d14
Browse filesBrowse the repository at this point in the historyBrowse files
The `annotate` plugin parses fenced code blocks whose info string includes `annotate`. It splits the rendered output into `.annotate-row` elements, with code in `.annotate-code` and rendered notes in `.annotate-note`.
6
+
7
+
Authoring rules:
8
+
9
+
- Include `annotate` in the info string.
10
+
- Include a language on the opening code fence.
11
+
- Start notes with the single-line comment marker for the fenced language: `#`, `//`, `<!--`, `%%`, or `--`.
12
+
- Match the comment marker style to the code fence language.
13
+
- Use single-line comments only. Multiline comment syntax is not supported.
14
+
- Put a space between the comment marker and annotation text.
15
+
- Leave text after the comment marker blank to create a blank annotation.
16
+
- Do not create a blank code block.
17
+
- Put Markdown after the comment marker. Inline Markdown is supported. Avoid block Markdown such as headings, blockquotes, horizontal rules, tables, lists, or code fences.
18
+
- Consecutive lines with the comment marker become one annotation.
19
+
- Empty lines and lines that contain only spaces are discarded.
20
+
- Start the code section with a single-line comment, or rendering throws.
21
+
- For HTML fences, add a line such as `<!-- -->` after the annotations to keep syntax highlighting.
22
+
23
+
`parse-info-string.ts` must run before `remark-rehype`, and `annotate` must run before `highlight`.
Copy file name to clipboardExpand all lines: src/content-render/unified/annotate.ts
+5-49Lines changed: 5 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,4 @@
1
-
/*
2
-
Parses fenced code blocks with `annotate` in info string.
3
-
Results in single line comments split out, output format is:
4
-
5
-
.annotate
6
-
.annotate-row (n)
7
-
.annotate-code
8
-
.annotate-note
9
-
10
-
Contributing rules:
11
-
- You must include `annotate` in the info string
12
-
- You must include a language on the starting ` ``` ` tag.
13
-
- Notes must start with one of: `#`, `//`, `<!--`, `%%`. (comment tag)
14
-
- The comment tag style must match the language on the code fence.
15
-
- Multiline-style comments, such as `/*` are not supported.
16
-
- You can include any number of spaces before the comment tag starts.
17
-
- You can include any number of spaces after the comment tag ends.
18
-
- You can leave after the comment tag blank to create a blank annotation.
19
-
- You cannot create a blank code block however.
20
-
- Anything after the comment tag will be parsed with Markdown.
21
-
- You can use any inline Markdown tag in the comment; recommend against using block tags such as headings, blockquote, horizontal rules, tables, lists, or code fences.
22
-
- Multiple lines in row with the comment tag will result in a single annotation.
23
-
- Empty lines, or lines that contain only space characters, will be discarded.
24
-
- You must start the code section with a single line comment, otherwise the two will be flipped.
25
-
- For HTML style, you can include a line after your annotations such as `<!-- -->` to maintain syntax highlighting; this will not impact what renders.
26
-
27
-
`parse-info-string.ts` plugin is required for this to work, and must come before `remark-rehype`.
28
-
`annotate` must come before the `highlight` plugin.
0 commit comments