turndown 4.0.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -2
- package/dist/turndown.js +792 -800
- package/lib/turndown.browser.cjs.js +41 -49
- package/lib/turndown.browser.es.js +41 -49
- package/lib/turndown.browser.umd.js +794 -802
- package/lib/turndown.cjs.js +41 -49
- package/lib/turndown.es.js +41 -49
- package/lib/turndown.umd.js +770 -778
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -40,7 +40,11 @@ var markdown = turndownService.turndown(document.getElementById('content'))
|
|
|
40
40
|
|
|
41
41
|
## Options
|
|
42
42
|
|
|
43
|
-
Options can be passed in to the constructor on instantiation.
|
|
43
|
+
Options can be passed in to the constructor on instantiation. For example:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
var turndownService = new TurndownService({ option: 'value' })
|
|
47
|
+
```
|
|
44
48
|
|
|
45
49
|
| Option | Valid values | Default |
|
|
46
50
|
| :-------------------- | :------------ | :------ |
|
|
@@ -195,7 +199,7 @@ rules.emphasis = {
|
|
|
195
199
|
|
|
196
200
|
### Rule Precedence
|
|
197
201
|
|
|
198
|
-
Turndown iterates over the set of rules, and picks the first one that matches
|
|
202
|
+
Turndown iterates over the set of rules, and picks the first one that matches the `filter`. The following list describes the order of precedence:
|
|
199
203
|
|
|
200
204
|
1. Blank rule
|
|
201
205
|
2. Added rules (optional)
|
|
@@ -208,6 +212,18 @@ Turndown iterates over the set of rules, and picks the first one that matches sa
|
|
|
208
212
|
|
|
209
213
|
The plugin API provides a convenient way for developers to apply multiple extensions. A plugin is just a function that is called with the `TurndownService` instance.
|
|
210
214
|
|
|
215
|
+
## Escaping Markdown Characters
|
|
216
|
+
|
|
217
|
+
Turndown uses backslashes (`\`) to escape Markdown characters in the HTML input. This ensures that these characters are not interpreted as Markdown when the output is compiled back to HTML. For example, the contents of `<h1>1. Hello world</h1>` needs to be escaped to `1\. Hello world`, otherwise it will be interpreted as a list item rather than a heading.
|
|
218
|
+
|
|
219
|
+
To avoid the complexity and the performance implications of parsing the content of every HTML element as Markdown, Turndown uses a group of regular expressions to escape potential Markdown syntax. As a result, the escaping rules can be quite aggressive.
|
|
220
|
+
|
|
221
|
+
### Overriding `TurndownService.prototype.escape`
|
|
222
|
+
|
|
223
|
+
If you are confident in doing so, you may want to customise the escaping behaviour to suit your needs. This can be done by overriding `TurndownService.prototype.escape`. `escape` takes the text of each HTML element and should return a version with the Markdown characters escaped.
|
|
224
|
+
|
|
225
|
+
Note: text in code elements is never passed to`escape`.
|
|
226
|
+
|
|
211
227
|
## License
|
|
212
228
|
|
|
213
229
|
turndown is copyright © 2017+ Dom Christie and released under the MIT license.
|