Преглед на файлове

Documentation updates

main
Rocketsoup преди 1 година
родител
ревизия
df6aea636b
променени са 5 файла, в които са добавени 456 реда и са изтрити 45 реда
  1. 139
    12
      custom.md
  2. 16
    16
      js/markdown.js
  3. 1
    1
      js/markdown.min.js
  4. 299
    15
      markdown.md
  5. 1
    1
      spreadsheet.md

+ 139
- 12
custom.md Целия файл

@@ -1,25 +1,152 @@
1 1
 # Custom Syntax Modules
2 2
 
3
-Syntax falls into two categories: block syntax and inline syntax. Block syntax operates on one or more whole lines of content to form structures like paragraphs, lists, tables, etc. Inline syntax operates on stretches of text within a block, such as marking a word as bold or inserting a link.
3
+Syntax falls into two categories: block syntax and inline syntax. Block syntax
4
+operates on one or more whole lines of content to form structures like paragraphs,
5
+lists, tables, etc. Inline syntax operates on stretches of text within a block,
6
+such as marking a word as bold or inserting a link. Inline syntax cannot span multiple blocks.
4 7
 
5
-## Block Reader
8
+## Readers
6 9
 
7
-Block readers extend from `MDBlockReader`.
10
+A reader is a subclass of `MDReader` and handles the parsing of one kind of
11
+syntax. E.g. `MDUnorderedListReader` handles bulleted lists and their items,
12
+`MDStrongReader` handles bold text, etc.
8 13
 
9
-They have a priority value that determines when the reader is tried relative to other readers. Built-in readers range from 0 to 100 but any priority value is valid. Lower values are evaluated before larger values. Generally readers for more complex syntaxes should precede simpler ones. E.g. Headers have a lower priority value because they are easy to match by their leading `#` characters. Paragraphs have a priority of 100 because they are the fallback when no other format matches.
14
+A reader can parse block syntax, inline syntax, or both.
10 15
 
11
-Block readers have a `readBlock` method that must be overriden. The method is passed an `MDState` object repeatedly, allowing the reader to check if a matching block is found at the current line pointer. An array of lines of markdown text are in `MDState.lines`, and the current line pointer is in `MDState.p`. If the reader does not detect a matching block starting at that line, the method should return `null` (preferably as soon as possible for good performance). If the line pointer does point to the beginning of a matching block, the `p` pointer should be positioned to the next line following the end of that block and an `MDBlock` subclass instance should be returned.
16
+## Parsing process
12 17
 
13
-A reader can also perform post-processing after the document has been parsed. This can be done by overriding the `postProcess` method. It will be passed an array of top-level document blocks. This array can be modified with `.splice` operations to add, remove, or replace top-level blocks. Blocks can also be recursed into by calling `MDBlock.visitChildren` with a function. The function will be called with every `MDBlock` or `MDSpan` by recursing into all child nodes. This gives the ability to manipulate specific nodes easily without walking the node tree manually.
18
+Parsing occurs in three phases.
14 19
 
15
-## Inline Reader
20
+1. **Blocks:** Readers are consulted line-by-line to see if their supported
21
+block syntax is found starting at the given line pointer. If so, it returns an
22
+`MDNode` object encoding the block, otherwise it returns `null` and the next
23
+reader is checked. See `MDReader.readBlock()`.
16 24
 
17
-Inline readers work differently. They extend from `MDInlineReader`. Inline parsing is done non-linearly by progressively swapping out elements of a `MDToken` array with `MDSpan` elements as patterns of tokens are found that match inline syntax structures.
25
+2. **Tokenizing:** Readers are asked to see if a supported token is located at
26
+the beginning of a given string. If so, an `MDToken` is returned, otherwise
27
+it returns `null` and then next reader is checked. See `MDReader.readToken()`.
18 28
 
19
-Inline parsing is done in two phases: tokenization and substitution. These two phases have separate priorities specified by each reader. For the substitution phase, readers can even specify more than one priority with an array so that it can be called multiple times during that phase. As with block readers, lower priority values will be evaluated before higher values. This should be used to match more complex tokens and more complex token patterns before simpler patterns that might lead to ambiguities with syntaxes that use the same characters.
29
+3. **Substitution:** Readers are given a mixed array of `MDToken`s (from the
30
+previous step) and `MDNode`s. The goal of substitution is to eventually convert
31
+all tokens into nodes, with any left over at the end being converted to
32
+`MDTextNode`s. If a reader can make one substitution it returns `true`, otherwise
33
+`false` and the next reader is checked. See `MDReader.substituteTokens()`.
20 34
 
21
-In the tokenize phase, each inline reader is given a chance to look for a relevant token at the beginning of a line. This is done by the `readFirstToken` method. It is passed a substring of a line of markdown, and the method should see if the string begins with a recognized token. Only tokens at the beginning of the string should be looked for. If no token is found the method should return `null`. If a token is found an `MDToken` should be returned.
35
+## Parsing Blocks
22 36
 
23
-After a block of markdown content has been tokenized, the substitution phase begins. This phase repeatedly processes an array of `MDToken`s, allowing readers to swap out one or more tokens with `MDSpan` subclasses in place. E.g. an emphasis reader will look for an asterisk token, some number of intermediary tokens, and another closing asterisk token. It will swap all of those out with an `MDEmphasisSpan`. Once the substitution phase is complete, any remaining `MDToken`s in the array get converted to `MDTextSpan`.
37
+To parse a block format, override the `readBlock` method in a subclass of
38
+`MDReader`. It will be passed an `MDState` instance. The two state properties of
39
+importance here are `lines` and `p`. `lines` is an array of the lines of markdown,
40
+and `p` is the current line pointer index. The job of `readBlock` is to check
41
+if the block syntax of interest is located at line `p`. Most of the time it won't
42
+be, in which case the method should just return `null`, preferably as early as
43
+possible for good performance.
24 44
 
25
-For inline readers with inner content (such as the previous emphasis example), the inner tokens can be converted to `MDSpan`s by calling `state.tokensToSpans()`. Alternately, if an inner markdown string needs to be converted to `MDSpan`s, call `state.inlineMarkdownToSpan` or `.inlineMarkdownToSpans` (plural).
45
+If the format is detected at line `p` then the reader should look ahead and see
46
+how many subsequent lines are also part of the block, process them as necessary,
47
+and return an appropriate `MDNode` subclass with their contents. Before returning,
48
+the reader _must_ set the state's `p` to the line index just after the last line
49
+of the detected block.
50
+
51
+Most blocks will have inner content. This can be processed into one or more
52
+`MDNode`s by calling `state.inlineMarkdownToNode` or `state.inlineMarkdownToNodes`
53
+for inline content. If the content may have nested block structures, create a
54
+subarray from `state.lines` and create a sub-state with `state.copy(lines)`.
55
+This creates a child state for the sub-document within the block structure. You
56
+can then call `substate.readBlocks()` to get an array of `MDBlockNode` to use
57
+as content. Note: if your block syntax has some kind of indentation or marker
58
+at the beginning of every line, those should be stripped from the lines passed
59
+to the copied sub-state.
60
+
61
+> **A note about sub-states.** States can have parent states. You can store any
62
+> needed state info on an `MDState` instance, but you will usually want to do
63
+> so on `state.root`, not `state` itself. This ensures those properties are
64
+> accessed on the original state, not a disposable substate.
65
+
66
+## Parsing Inline Syntax
67
+
68
+Inline parsing is usually done by overriding both the `readToken` and
69
+`substituteTokens` methods.
70
+
71
+The `readToken` method is passed an `MDState` and a tail portion of a line of
72
+markdown. The method should check if the line begins with a supported token.
73
+This will generally be some punctuation symbol or sometimes a more complex
74
+sequence. For inline syntax consisting of pairs of double symbols (e.g. `**strong**`), each symbol should usually be tokenized individually rather than
75
+as pairs, just in case another syntax recognizes single symbols. If no token
76
+is found at the start of the string, return `null`. Do _not_ match tokens
77
+anywhere but at the start of the given string.
78
+
79
+Substitution is done by the `substituteTokens` method. This one is trickier.
80
+It is called with a mixed array of tokens (`MDToken`) and nodes (`MDNode`).
81
+The goal is for readers to keep doing one search-and-replace when possible.
82
+Only the first match should be performed, then return `true` if a substitution
83
+was made or `false` if not.
84
+
85
+There are helper methods for performing substitution. `MDToken` has static methods
86
+`findFirstTokens` and `findPairedTokens`. They work like crude regexes that
87
+operate on tokens instead of characters. For syntax consisting of text enclosed
88
+between symbols (e.g. `**strong**`, `_emphasis_`, `~~strike~~`), you can
89
+subclass `MDSimplePairInlineReader` and use its `attemptPair` method to make
90
+substitution easy.
91
+
92
+## Priority
93
+
94
+Many markdown syntaxes use the same characters and similar syntax. This can
95
+cause problems depending on which reader is run first. This can be resolved by
96
+prioritization. Each parsing phase has its own priority order, and each reader
97
+can dictate what readers it wants to be ahead of or behind by overriding the
98
+`compareBlockOrdering`, `compareTokenizeOrdering`, or `compareSubstituteOrdering`
99
+methods. Each is called with another reader instance, and the method should
100
+return a `-1` if it wants to be run before the given reader, `1` if it wants to
101
+be run after the given reader, or `0` as a "don't care" value. The method should
102
+only return `-1` or `1` when it's necessary to resolve a specific conflict;
103
+most of the time it should return `0`. The default implementation always returns
104
+`0`.
105
+
106
+Prioritization can be further refined for the substitution phase using multiple
107
+passes. Passes are good for especially ambiguous constructs, like `***strong** emphasis*`. In this example, a naive `MDEmphasisReader` might grab the first asterisk as the start of the sequence and the one immediately following "strong",
108
+stealing the second and third asterisk as part of the inner text and leaving the
109
+second asterisk after "strong" and the one after "emphasis" alone.
110
+
111
+> `[*]**strong[*]* emphasis*`<br>
112
+> An incorrect, naive substitution (start and end tokens shown in brackets)
113
+
114
+By using mulitiple passes, the reader can use early passes to be more
115
+conservative and hold out for a better match first, or let other readers find
116
+a better match, then on a later pass it can grab whatever's left over.
117
+
118
+> 1. `MDStrongReader` finds a match on the first pass because there are no inner
119
+> asterisks to cause ambiguities<br>
120
+> `*[**]strong[**] emphasis*`
121
+>
122
+> 2. Then, `MDEmphasisReader` finds the outer pair on a later pass<br>
123
+> `*<MDStrongNode> emphasis*`
124
+
125
+## Pre- and Post-Processing
126
+
127
+Readers have the option of performing tasks before and after the document has
128
+been parsed by overriding the `preProcess` and/or `postProcess` methods.
129
+
130
+Pre-processing is mostly useful for initializing `MDState` in some way.
131
+
132
+Post-processing can be used to manipulate the `MDNode` tree after it has been
133
+constructed by the parsing phases. For example, finding all the footnotes in a
134
+document in the order they appear for proper numbering. `postProcess` is passed
135
+an array of top-level `MDNode`s in the parsed document. This array can be
136
+altered using `.splice` operations if desired to add additional structures,
137
+such as a list of all the footnote content at the bottom of the document, to
138
+reuse the same example.
139
+
140
+One useful utility for post-processing is `MDNode.visitChildren`. This will
141
+recursively visit every node in the tree and call a callback function with each
142
+one. The node tree cannot be restructured, but each node can be inspected or
143
+altered.
144
+
145
+To perform substitution, `MDUtils.replaceNodes` can be called. It will call a
146
+replacer function with every node in the tree recursively. If the function
147
+returns `null`, no change is made. If the function returns a new `MDNode`
148
+instance it will replace that node in the tree. When a replacement is made,
149
+neither the original nor the replacement is recursed into. To replace a node
150
+with multiple other nodes, wrap those multiple nodes in a generic `MDNode` as
151
+its children. To remove a node without a replacement, return an `MDNode` with
152
+no children. It will be rendered as nothing when converted to HTML.

+ 16
- 16
js/markdown.js Целия файл

@@ -1135,16 +1135,16 @@ class MDReader {
1135 1135
 }
1136 1136
 
1137 1137
 /**
1138
- * Reads markdown blocks for headers denoted with the underline syntax.
1138
+ * Reads markdown blocks for headings denoted with the underline syntax.
1139 1139
  * 
1140 1140
  * Example:
1141 1141
  * 
1142 1142
  * > ```markdown
1143
- * > Header 1
1143
+ * > Heading 1
1144 1144
  * > ========
1145 1145
  * > ```
1146 1146
  */
1147
-class MDUnderlinedHeaderReader extends MDReader {
1147
+class MDUnderlinedHeadingReader extends MDReader {
1148 1148
 	readBlock(state) {
1149 1149
 		var p = state.p;
1150 1150
 		if (!state.hasLines(2)) return null;
@@ -1155,13 +1155,13 @@ class MDUnderlinedHeaderReader extends MDReader {
1155 1155
 		if (contentLine == '') return null;
1156 1156
 		if (/^=+$/.exec(underLine)) {
1157 1157
 			state.p = p;
1158
-			let block = new MDHeaderNode(1, state.inlineMarkdownToNodes(contentLine));
1158
+			let block = new MDHeadingNode(1, state.inlineMarkdownToNodes(contentLine));
1159 1159
 			if (modifier) modifier.applyTo(block);
1160 1160
 			return block;
1161 1161
 		}
1162 1162
 		if (/^\-+$/.exec(underLine)) {
1163 1163
 			state.p = p;
1164
-			let block = new MDHeaderNode(2, state.inlineMarkdownToNodes(contentLine));
1164
+			let block = new MDHeadingNode(2, state.inlineMarkdownToNodes(contentLine));
1165 1165
 			if (modifier) modifier.applyTo(block);
1166 1166
 			return block;
1167 1167
 		}
@@ -1170,35 +1170,35 @@ class MDUnderlinedHeaderReader extends MDReader {
1170 1170
 }
1171 1171
 
1172 1172
 /**
1173
- * Reads markdown blocks for headers denoted with hash marks. Header levels 1 to
1173
+ * Reads markdown blocks for headings denoted with hash marks. Heading levels 1 to
1174 1174
  * 6 are supported.
1175 1175
  * 
1176 1176
  * Examples:
1177 1177
  * 
1178 1178
  * > ```markdown
1179
- * > # Header 1
1179
+ * > # Heading 1
1180 1180
  * >
1181
- * > ## Header 2
1181
+ * > ## Heading 2
1182 1182
  * >
1183 1183
  * > # Enclosing Hashes Are Optional #
1184 1184
  * >
1185 1185
  * > ## Trailing Hashes Don't Have to Match in Number ####
1186 1186
  * > ```
1187 1187
  */
1188
-class MDHashHeaderReader extends MDReader {
1189
-	static #hashHeaderRegex = /^(#{1,6})\s*([^#].*?)\s*\#*\s*$/;  // 1=hashes, 2=content
1188
+class MDHashHeadingReader extends MDReader {
1189
+	static #hashHeadingRegex = /^(#{1,6})\s*([^#].*?)\s*\#*\s*$/;  // 1=hashes, 2=content
1190 1190
 
1191 1191
 	readBlock(state) {
1192 1192
 		var p = state.p;
1193 1193
 		let line = state.lines[p++];
1194 1194
 		var modifier;
1195 1195
 		[line, modifier] = MDTagModifier.fromLine(line);
1196
-		var groups = MDHashHeaderReader.#hashHeaderRegex.exec(line);
1196
+		var groups = MDHashHeadingReader.#hashHeadingRegex.exec(line);
1197 1197
 		if (groups === null) return null;
1198 1198
 		state.p = p;
1199 1199
 		const level = groups[1].length;
1200 1200
 		const content = groups[2];
1201
-		let block = new MDHeaderNode(level, state.inlineMarkdownToNodes(content));
1201
+		let block = new MDHeadingNode(level, state.inlineMarkdownToNodes(content));
1202 1202
 		if (modifier) modifier.applyTo(block);
1203 1203
 		return block;
1204 1204
 	}
@@ -2492,14 +2492,14 @@ class MDParagraphNode extends MDBlockNode {
2492 2492
 	}
2493 2493
 }
2494 2494
 
2495
-class MDHeaderNode extends MDBlockNode {
2495
+class MDHeadingNode extends MDBlockNode {
2496 2496
 	/** @type {number} */
2497 2497
 	level;
2498 2498
 
2499 2499
 	constructor(level, children) {
2500 2500
 		super(children);
2501 2501
 		if (typeof level !== 'number' || (level < 1 || level > 6)) {
2502
-			throw new Error(`${this.constructor.name} requires header level 1 to 6`);
2502
+			throw new Error(`${this.constructor.name} requires heading level 1 to 6`);
2503 2503
 		}
2504 2504
 		this.level = level;
2505 2505
 	}
@@ -3379,8 +3379,8 @@ class Markdown {
3379 3379
 	 * @type {MDReader[]}
3380 3380
 	 */
3381 3381
 	static standardReaders = [
3382
-		new MDUnderlinedHeaderReader(),
3383
-		new MDHashHeaderReader(),
3382
+		new MDUnderlinedHeadingReader(),
3383
+		new MDHashHeadingReader(),
3384 3384
 		new MDBlockQuoteReader(),
3385 3385
 		new MDHorizontalRuleReader(),
3386 3386
 		new MDUnorderedListReader(),

+ 1
- 1
js/markdown.min.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 299
- 15
markdown.md Целия файл

@@ -1,14 +1,13 @@
1 1
 # Markdown Syntax
2 2
 
3
-(todo: include class names for enabling these features)
4
-
5 3
 ## Block Formats
6 4
 
7 5
 Formats that apply to one or more lines.
8 6
 
9 7
 ### Paragraph
10 8
 
11
-Any contiguous set of lines not formatted like one of the other formats below is treated as a paragraph. Paragraphs are separated by double blank lines.
9
+Any contiguous set of lines not formatted like one of the other formats below is
10
+treated as a paragraph. Paragraphs are separated by double blank lines.
12 11
 
13 12
 ```markdown
14 13
 Lorem ipsum dolor
@@ -17,6 +16,13 @@ sit amet.
17 16
 New paragraph begins.
18 17
 ```
19 18
 
19
+> <p>Lorem ipsum dolor sit amet.</p>
20
+>
21
+> <p>New paragraph begins.</p>
22
+
23
+Class:
24
+* `MDParagraphReader`
25
+
20 26
 ### Headers
21 27
 
22 28
 Headers are marked with one or more leading hashes.
@@ -31,6 +37,14 @@ Headers are marked with one or more leading hashes.
31 37
 ## Optional Matched Hashes At The End ##
32 38
 ```
33 39
 
40
+> <h1>Header 1 has one hash</h1>
41
+>
42
+> <h2>Header 2 has two hashes</h2>
43
+>
44
+> <h6>Up to header 6</h6>
45
+>
46
+> <h2>Optional Matched Hashes At The End</h2>
47
+
34 48
 Alternately, H1 and H2 can be marked with underlines.
35 49
 
36 50
 ```markdown
@@ -41,6 +55,14 @@ Header 2 with hyphens. Number of underline chars doesn't matter
41 55
 ---
42 56
 ```
43 57
 
58
+> <h1>Header 1 underlined with equals</h1>
59
+>
60
+> <h2>Header 2 with hyphens. Number of underline chars doesn't matter</h2>
61
+
62
+Classes:
63
+* `MDUnderlinedHeadingReader`
64
+* `MDHashHeadingReader`
65
+
44 66
 ### Lists
45 67
 
46 68
 Unordered lists are bulleted with an asterisk, plus, or hyphen and space.
@@ -51,6 +73,12 @@ Unordered lists are bulleted with an asterisk, plus, or hyphen and space.
51 73
 - Work as bullets
52 74
 ```
53 75
 
76
+> <ul>
77
+> <li>Item</li>
78
+> <li>Any of these</li>
79
+> <li>Work as bullets</li>
80
+> </ul>
81
+
54 82
 Lists can be nested with one or more spaces below an item.
55 83
 
56 84
 ```markdown
@@ -60,6 +88,14 @@ Lists can be nested with one or more spaces below an item.
60 88
 * Item
61 89
 ```
62 90
 
91
+> <ul>
92
+> <li>Item<ul>
93
+> <li>Sublist</li>
94
+> <li>Sublist</li>
95
+> </ul></li>
96
+> <li>Item</li>
97
+> </ul>
98
+
63 99
 Ordered lists start with a number, period, and space.
64 100
 
65 101
 ```markdown
@@ -68,6 +104,12 @@ Ordered lists start with a number, period, and space.
68 104
 3. Item
69 105
 ```
70 106
 
107
+> <ol>
108
+> <li>Item</li>
109
+> <li>Item</li>
110
+> <li>Item</li>
111
+> </ol>
112
+
71 113
 Again, they can be nested.
72 114
 
73 115
 ```markdown
@@ -77,7 +119,16 @@ Again, they can be nested.
77 119
 2. Item
78 120
 ```
79 121
 
80
-The first number dictates where the numbering begins. The numbers on the other items are ignored and incremented by one.
122
+> <ol>
123
+> <li>Item<ol>
124
+> <li>Subitem</li>
125
+> <li>Subitem</li>
126
+> </ol></li>
127
+> <li>Item</li>
128
+> </ol>
129
+
130
+The first number dictates where the numbering begins. The numbers on the other
131
+items are ignored and incremented by one.
81 132
 
82 133
 ```markdown
83 134
 5. Rendered as a 5
@@ -85,6 +136,19 @@ The first number dictates where the numbering begins. The numbers on the other i
85 136
 1. Rendered as a 7
86 137
 ```
87 138
 
139
+> <ol start="5">
140
+> <li>Rendered as a 5</li>
141
+> <li>Rendered as a 6</li>
142
+> <li>Rendered as a 7</li>
143
+> </ol>
144
+
145
+Numbering every item with `1.` can
146
+save you the hassle of renumbering items when reordering them.
147
+
148
+Classes:
149
+* `MDUnorderedListReader`
150
+* `MDOrderedListReader`
151
+
88 152
 ### Blockquote
89 153
 
90 154
 Blockquotes enclose lengthy quoted content in an indented block.
@@ -96,6 +160,13 @@ Lorem Ipsum said:
96 160
 > adipiscing.
97 161
 ```
98 162
 
163
+> Lorem Ipsum said:
164
+>
165
+> <blockquote>Dolor sit amet adipiscing.</blockquote>
166
+
167
+Class:
168
+* `MDBlockQuoteReader`
169
+
99 170
 ### Code Blocks
100 171
 
101 172
 Blocks of preformatted code can be enclosed in triple backticks.
@@ -108,7 +179,14 @@ function foo() {
108 179
 `​``
109 180
 ```
110 181
 
111
-Alternately, lines indented by at least four spaces or a tab character will be interpreted as code blocks.
182
+> <pre><code>
183
+> function foo() {
184
+>     return 'bar';
185
+> }
186
+> </code></pre>
187
+
188
+Alternately, lines indented by at least four spaces or a tab character will be
189
+interpreted as code blocks.
112 190
 
113 191
 ```markdown
114 192
     function foo() {
@@ -116,9 +194,20 @@ Alternately, lines indented by at least four spaces or a tab character will be i
116 194
 	}
117 195
 ```
118 196
 
197
+> <pre><code>
198
+> function foo() {
199
+>     return 'bar';
200
+> }
201
+> </code></pre>
202
+
203
+Classes:
204
+* `MDFencedCodeBlockReader`
205
+* `MDIndentedCodeBlockReader`
206
+
119 207
 ### Horizontal Rule
120 208
 
121
-Horizontal divider lines are written as 3 or more hyphens or asterisks on a line by themselves, with or without interstitial whitespace.
209
+Horizontal divider lines are written as 3 or more hyphens or asterisks on a line
210
+by themselves, with or without interstitial whitespace.
122 211
 
123 212
 ```markdown
124 213
 ---
@@ -130,6 +219,17 @@ Horizontal divider lines are written as 3 or more hyphens or asterisks on a line
130 219
 * * * * * * *
131 220
 ```
132 221
 
222
+> <hr>
223
+>
224
+> <hr>
225
+>
226
+> <hr>
227
+>
228
+> <hr>
229
+
230
+Class:
231
+* `MDHorizontalRuleReader`
232
+
133 233
 ### Tables
134 234
 
135 235
 Tables consist of one header row and any number of body rows
@@ -141,9 +241,20 @@ Cell     | 123 |  xyz
141 241
 Next row | 543 |  abc
142 242
 ```
143 243
 
244
+> <table>
245
+> <thead>
246
+> <tr><th>Header</th><th>Row</th><th>Here</th></tr>
247
+> </thead>
248
+> <tbody>
249
+> <tr><td>Cell</td><td>123</td><td>xyz</td></tr>
250
+> <tr><td>Next row</td><td>543</td><td>abc</td></tr>
251
+> </tbody>
252
+> </table>
253
+
144 254
 The pipe characters do not have to line up.
145 255
 
146
-Rows can optionally have leading and/or trailing pipes. This is required for a single column table.
256
+Rows can optionally have leading and/or trailing pipes. This is required for a
257
+single column table.
147 258
 
148 259
 ```markdown
149 260
 | One column |
@@ -152,6 +263,16 @@ Rows can optionally have leading and/or trailing pipes. This is required for a s
152 263
 | 234 |
153 264
 ```
154 265
 
266
+> <table>
267
+> <thead>
268
+> <tr><th>One column</th></tr>
269
+> </thead>
270
+> <tbody>
271
+> <tr><td>123</td></tr>
272
+> <tr><td>234</td></tr>
273
+> </tbody>
274
+> </table>
275
+
155 276
 Columns can be right, center, or left aligned with colons in the divider line.
156 277
 
157 278
 ```markdown
@@ -160,7 +281,21 @@ Columns can be right, center, or left aligned with colons in the divider line.
160 281
 | 1 | 2 | 3 |
161 282
 ```
162 283
 
163
-Tables can optionally support simple [spreadsheet expressions](spreadsheet.md) by adding the spreadsheet block reader when configuring a parser.
284
+> <table>
285
+> <thead>
286
+> <tr><th style="text-align: left;">Left</th><th style="text-align: center;">Center</th><th style="text-align: right;">Right</th></tr>
287
+> </thead>
288
+> <tbody>
289
+> <tr><td style="text-align: left;">1</td><td style="text-align: center;">2</td><td style="text-align: right;">3</td></tr>
290
+> </tbody>
291
+> </table>
292
+
293
+Tables can optionally support simple [spreadsheet expressions](spreadsheet.md)
294
+by adding the spreadsheet block reader when configuring a parser.
295
+
296
+Classes:
297
+* `MDTableReader`
298
+* `MDSpreadsheetReader`
164 299
 
165 300
 ### Definition List
166 301
 
@@ -174,20 +309,41 @@ another
174 309
 : alternate definition of another
175 310
 ```
176 311
 
312
+> <dl>
313
+> <dt>term</dt>
314
+> <dd>definition of term</dd>
315
+> <dt>another</dt>
316
+> <dd>definition of another</dd>
317
+> <dd>alternate definition of another</dd>
318
+> </dl>
319
+
320
+Class:
321
+* `MDDefinitionListReader`
322
+
177 323
 ### Abbreviation Definition
178 324
 
179
-Abbreviations can be defined anywhere in the document. Anywhere that abbreviation appears in the document will have a mouseover title showing the expanded definition. The definition is plaintext only (no markdown).
325
+Abbreviations can be defined anywhere in the document. Anywhere that abbreviation
326
+appears in the document will have a mouseover title showing the expanded
327
+definition. The definition is plaintext only (no markdown).
180 328
 
181 329
 ```markdown
330
+Always remember, ABC.
331
+
182 332
 *[ABC]: Always Be Closing
183 333
 ```
184 334
 
335
+> Always remember, <abbr title="Always Be Closing">ABC</abbr>.
336
+
337
+Class:
338
+* `MDAbbreviationReader`
339
+
185 340
 ### CSS Modifiers
186 341
 
187
-Many block structures can be modified with CSS classes, IDs, or other simple HTML attributes inside curly braces.
342
+Many block structures can be modified with CSS classes, IDs, or other simple
343
+HTML attributes inside curly braces.
188 344
 
189 345
 ```markdown
190
-# Header {.mycssclass}
346
+## Header with a CSS class {.mycssclass}
191 347
 
192 348
 --- {#mydividerid}
193 349
 
@@ -195,9 +351,23 @@ Many block structures can be modified with CSS classes, IDs, or other simple HTM
195 351
 |---|
196 352
 |123|
197 353
 
198
-# Multiple Modifiers {.linkclass #linkid lang=en}
354
+## Header with multiple modifiers {.linkclass #linkid lang=en}
199 355
 ```
200 356
 
357
+> <h2 class="mycssclass">Header with a CSS class</h2>
358
+>
359
+> <hr id="mydividerid">
360
+>
361
+> <table style="color: green;">
362
+> <thead><tr><th>Table</th></tr></thead>
363
+> <tbody><tr><td>123</td></tr></tbody>
364
+> </table>
365
+>
366
+> <h2 class="linkclass" id="linkid" lang="en">Header with multiple modifiers</h2>
367
+
368
+Class:
369
+* `MDModifierReader`
370
+
201 371
 ## Inline Formats
202 372
 
203 373
 Formats that apply within a block to style runs of words or inject other content within text.
@@ -207,9 +377,14 @@ Formats that apply within a block to style runs of words or inject other content
207 377
 Text can be marked as bold by enclosing it in double asterisks.
208 378
 
209 379
 ```markdown
210
-Some **bold** text. Can also use __underscores__.
380
+Some **bold** text. Can also use __underscores__ (unless underlining is enabled).
211 381
 ```
212 382
 
383
+> Some <strong>bold</strong> text. Can also use <strong>underscores</strong> (unless underlining is enabled).
384
+
385
+Class:
386
+* `MDStrongReader`
387
+
213 388
 ### Emphasis
214 389
 
215 390
 Text can be marked as italic by enclosing it in single underscores or single asterisks.
@@ -218,14 +393,52 @@ Text can be marked as italic by enclosing it in single underscores or single ast
218 393
 Some _italic_ text. Can also use *asterisks*.
219 394
 ```
220 395
 
396
+> Some <em>italic</em> text. Can also use <em>asterisks</em>.
397
+
398
+Class:
399
+* `MDEmphasisReader`
400
+
221 401
 ### Strikethrough
222 402
 
223
-Text can be stricken out using tildes, singly or in pairs.
403
+Text can be stricken out using tildes, singly or in pairs. If subscript is
404
+enabled then only double tildes can be used.
224 405
 
225 406
 ```markdown
226 407
 Not ~~this text~~. Not ~this text~ either.
227 408
 ```
228 409
 
410
+> Not <s>this text</s>. Not <s>this text</s> either.
411
+
412
+Class:
413
+* `MDStrikethroughReader`
414
+
415
+### Underline
416
+
417
+Underline is denoted with double underscores. If this reader is in use,
418
+"strong" styling can only be done with double asterisks.
419
+
420
+```markdown
421
+Some __underlined__ text.
422
+```
423
+
424
+> Some <u>underlined</u> text.
425
+
426
+Class:
427
+* `MDUnderlineReader`
428
+
429
+### Highlighting
430
+
431
+Highlighting is done with pairs of equals around text.
432
+
433
+```markdown
434
+Some ==highlighted== text.
435
+```
436
+
437
+> Some <mark>highlighted</mark> text.
438
+
439
+Class:
440
+* `MDHighlightReader`
441
+
229 442
 ### Code
230 443
 
231 444
 Words can be rendered in monospace font using single backticks.
@@ -234,6 +447,37 @@ Words can be rendered in monospace font using single backticks.
234 447
 The name of the function is `foo()`.
235 448
 ```
236 449
 
450
+> The name of the function is <code>foo()</code>.
451
+
452
+Class:
453
+* `MDCodeSpanReader`
454
+
455
+### Subscript
456
+
457
+Subscript is denoted with single tildes around the text.
458
+
459
+```markdown
460
+The formula for water is H~2~O.
461
+```
462
+
463
+> The formula for water is H<sup>2</sup>O.
464
+
465
+Class:
466
+* `MDSubscriptReader`
467
+
468
+### Superscript
469
+
470
+Superscript is represented with caret characters around the text.
471
+
472
+```markdown
473
+Einstein's equation E=mc^2^.
474
+```
475
+
476
+> Einstein's equation is E=mc<sup>2</sup>.
477
+
478
+Class:
479
+* `MDSuperscriptReader`
480
+
237 481
 ### Link
238 482
 
239 483
 Linking to a document is done with marked text and a URL.
@@ -242,12 +486,16 @@ Linking to a document is done with marked text and a URL.
242 486
 Click [here](page.html).
243 487
 ```
244 488
 
489
+> Click <a href="page.html">here</a>.
490
+
245 491
 An optional mouseover title can be added to the link after the URL.
246 492
 
247 493
 ```markdown
248 494
 Click [here](page.html "Goes to a neat page").
249 495
 ```
250 496
 
497
+> Click <a href="page.html" title="Goes to a neat page">here</a>.
498
+
251 499
 Repetitive or lengthy URLs can be referenced out and defined elsewhere in the document.
252 500
 
253 501
 ```markdown
@@ -256,12 +504,22 @@ Click [here][foo] or [here][foo] or [even here][foo] to go to the same place.
256 504
 [foo]: page.html "Optional title"
257 505
 ```
258 506
 
507
+> Click <a href="page.html" title="Optional title">here</a> or
508
+> <a href="page.html" title="Optional title">here</a> or
509
+> <a href="page.html" title="Optional title">even here</a> to go to the same place.
510
+
259 511
 Lastly, to make a link with the URL as the link text, you can use angle brackets.
260 512
 
261 513
 ```markdown
262 514
 Go visit <page.html>.
263 515
 ```
264 516
 
517
+> Go visit <a href="page.html">page.html</a>.
518
+
519
+Classes:
520
+* `MDLinkReader`
521
+* `MDReferencedLinkReader`
522
+
265 523
 ### Image
266 524
 
267 525
 An image is similar to link syntax with an exclamation in front. Instead of clickable link text, the text is alt text for the image.
@@ -270,12 +528,16 @@ An image is similar to link syntax with an exclamation in front. Instead of clic
270 528
 ![a test image](https://picsum.photos/100/75)
271 529
 ```
272 530
 
531
+> <img src="https://picsum.photos/100/75" alt="a test image">
532
+
273 533
 Images also support title attributes.
274 534
 
275 535
 ```markdown
276 536
 ![a test image](https://picsum.photos/100/75 "title text")
277 537
 ```
278 538
 
539
+> <img src="https://picsum.photos/100/75" alt="a test image" title="title text">
540
+
279 541
 Images also support referenced URLs.
280 542
 
281 543
 ```markdown
@@ -284,12 +546,20 @@ Images also support referenced URLs.
284 546
 [foo]: https://picsum.photos/100/75
285 547
 ```
286 548
 
549
+> <img src="https://picsum.photos/100/75" alt="alt text">
550
+
287 551
 Images can be made clickable by enclosing them in a link where the link text goes.
288 552
 
289 553
 ```markdown
290
-[![alt text](image.jpg)](page.html)
554
+[![alt text](https://picsum.photos/100/75)](page.html)
291 555
 ```
292 556
 
557
+> <a href="page.html"><img src="https://picsum.photos/100/75" alt="alt text"></a>
558
+
559
+Classes:
560
+* `MDImageReader`
561
+* `MDReferencedImageReader`
562
+
293 563
 ### Footnote
294 564
 
295 565
 Footnotes can be inserted into text. The text of the footnotes is added to the bottom of the document, regardless of where they're defined.
@@ -301,6 +571,20 @@ Lorem ipsum[^1] dolor sit[^2] amet.
301 571
 [^2]: See _Interesting Book_, pg 213
302 572
 ```
303 573
 
574
+> <p>Lorem ipsum<sup><a href="#footnote1" id="footnote_ref1">1</a></sup> dolor sit<sup><a href="#footnote2" id="footnote_ref2">2</a></sup> amet.</p>
575
+>
576
+> <hr>
577
+> <ol>
578
+> <li>Further information here <a href="#footnote_ref1">↩︎</a></li>
579
+> <li>See <em>Interesting Book</em>, pg 213 <a href="#footnote_ref2">↩︎</a></li>
580
+> </ol>
581
+
582
+Class:
583
+* `MDFootnoteReader`
584
+
304 585
 ### HTML Tags
305 586
 
306 587
 Currently all HTML tags and attributes are permitted, when markdown syntax doesn't do what you want.
588
+
589
+Class:
590
+* `MDHTMLTagReader`

+ 1
- 1
spreadsheet.md Целия файл

@@ -1,6 +1,6 @@
1 1
 # Spreadsheet Expressions
2 2
 
3
-Spreadsheet expressions are an optional feature not enabled in the default parser configurations. To enable it, include `spreadsheet.js` and create a `Markdown` instance with a `MDSpreadsheetBlockReader`.
3
+Spreadsheet expressions are an optional feature not enabled in the default parser configurations. To enable it, include `spreadsheet.js` and create a `Markdown` instance with a `MDSpreadsheetReader`.
4 4
 
5 5
 ## Expressions
6 6
 

Loading…
Отказ
Запис