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
feat(rawPrefixHeaderId): add option to prevent showdown from modifying the prefix
Setting this option to true will prevent showdown from modifying the
prefix. This might result in malformed IDs (if, for instance, the " char is
used in the prefix). Has no effect if prefixHeaderId is set to false.
Closes#409
Copy file name to clipboardExpand all lines: README.md
+35-16Lines changed: 35 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@
10
10
11
11
------
12
12
13
-
Showdown is a Javascript Markdown to HTML converter, based on the original works by John Gruber. Showdown can be used client side (in the browser) or server side (with NodeJs).
13
+
Showdown is a Javascript Markdown to HTML converter, based on the original works by John Gruber.
14
+
Showdown can be used client side (in the browser) or server side (with NodeJs).
14
15
15
16
## Live DEMO
16
17
@@ -28,7 +29,8 @@ Check a live Demo here http://showdownjs.github.io/demo/
We're currently looking to improve showdown with automated tests in all browsers and a proper domain and webpage. [If you like our work, please donate!!](https://www.paypal.me/tiviesantos) Your contribution will be greatly appreciated.
32
+
We're currently looking to improve showdown with automated tests in all browsers and a proper domain and webpage.
33
+
[If you like our work, please donate!!](https://www.paypal.me/tiviesantos) Your contribution will be greatly appreciated.
32
34
33
35
## Installation
34
36
@@ -75,7 +77,8 @@ Showdown has been tested successfully with:
75
77
* Netscape 8.1.2
76
78
* Konqueror 3.5.4
77
79
78
-
In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises.
80
+
In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5).
81
+
The converter itself might even work in things that aren't web browsers, like Acrobat. No promises.
79
82
80
83
81
84
## Node compatibility
@@ -196,19 +199,27 @@ var defaultOptions = showdown.getDefaultOptions();
196
199
<code><pre>var foo = 'bar';</pre></code>
197
200
```
198
201
199
-
* **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId**
202
+
* **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids.
203
+
Setting to true overrides **prefixHeaderId**
200
204
201
205
* **customizedHeaderId**: (boolean) [default false] Use text in curly braces as header id. **(since v1.7.0)**
202
206
Example:
203
207
```
204
208
## Sample header {real-id} will use real-id as id
205
209
```
206
210
207
-
* **ghCompatibleHeaderId**: (boolean) [default false] Generate header ids compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed) **(since v1.5.5)**
(spaces are replaced with dashes and a bunch of non alphanumeric chars are removed) **(since v1.5.5)**
208
213
209
-
* **prefixHeaderId**: (string/boolean) [default false] Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to `true` will add a generic 'section' prefix.
214
+
* **prefixHeaderId**: (string/boolean) [default false] Add a prefix to the generated header ids.
215
+
Passing a string will prefix that string to the header id. Setting to `true` will add a generic 'section' prefix.
210
216
211
-
* **rawHeaderId**: (boolean) [default false] Remove only spaces, ' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids **(since v1.7.3)**
217
+
* **rawPrefixHeaderId**: (boolean) [default false] Setting this option to true will prevent showdown from modifying the prefix.
218
+
This might result in malformed IDs (if, for instance, the " char is used in the prefix).
219
+
Has no effect if prefixHeaderId is set to false.**(since v 1.7.3)**
220
+
221
+
* **rawHeaderId**: (boolean) [default false] Remove only spaces, ' and " from generated header ids (including prefixes),
222
+
replacing them with dashes (-). WARNING: This might result in malformed ids **(since v1.7.3)**
212
223
213
224
* **parseImgDimensions**: (boolean) [default false] Enable support for setting image dimensions from within markdown syntax.
214
225
Examples:
@@ -229,7 +240,8 @@ var defaultOptions = showdown.getDefaultOptions();
229
240
<h3>foo</h3>
230
241
```
231
242
232
-
* **simplifiedAutoLink**: (boolean) [default false] Turning this option on will enable automatic linking to urls. This means that
243
+
* **simplifiedAutoLink**: (boolean) [default false] Turning this option on will enable automatic linking to urls.
244
+
This means that:
233
245
234
246
```md
235
247
some text www.google.com
@@ -302,12 +314,15 @@ var defaultOptions = showdown.getDefaultOptions();
302
314
```
303
315
* **smoothLivePreview**: (boolean) [default false] Prevents weird effects in live previews due to incomplete input
304
316
305
-
* **smartIndentationFix**: (boolean) [default false] Tries to smartly fix indentation problems related to es6 template strings in the midst of indented code.
317
+
* **smartIndentationFix**: (boolean) [default false] Tries to smartly fix indentation problems related to es6 template
318
+
strings in the midst of indented code.
306
319
307
-
* **disableForced4SpacesIndentedSublists**: (boolean) [default false] Disables the requirement of indenting sublists by 4 spaces for them to be nested,
308
-
effectively reverting to the old behavior where 2 or 3 spaces were enough. **(since v1.5.0)**
320
+
* **disableForced4SpacesIndentedSublists**: (boolean) [default false] Disables the requirement of indenting sublists
321
+
by 4 spaces for them to be nested, effectively reverting to the old behavior where 2 or 3 spaces were enough.
322
+
**(since v1.5.0)**
309
323
310
-
* **simpleLineBreaks**: (boolean) [default false] Parses line breaks as <br> like GitHub does, without needing 2 spaces at the end of the line **(since v1.5.1)**
324
+
* **simpleLineBreaks**: (boolean) [default false] Parses line breaks as <br> like GitHub does, without
325
+
needing 2 spaces at the end of the line **(since v1.5.1)**
311
326
312
327
```md
313
328
a line
@@ -325,14 +340,16 @@ var defaultOptions = showdown.getDefaultOptions();
325
340
326
341
* **ghMentions**: (boolean) [default false] Enables github @mentions, which link to the username mentioned **(since v1.6.0)**
327
342
328
-
* **ghMentionsLink**: (string) [default `https://github.com/{u}`] Changes the link generated by @mentions. Showdown will replace `{u}` with the username. Only applies if ghMentions option is enabled.
343
+
* **ghMentionsLink**: (string) [default `https://github.com/{u}`] Changes the link generated by @mentions.
344
+
Showdown will replace `{u}` with the username. Only applies if ghMentions option is enabled.
329
345
Example: `@tivie` with ghMentionsOption set to `//mysite.com/{u}/profile` will result in `<a href="//mysite.com/tivie/profile">@tivie</a>`
330
346
331
347
***encodeEmails**: (boolean) [default true] Enables e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities. (since v1.6.1)
332
348
333
349
NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding.
334
350
335
-
***openLinksInNewWindow**: (boolean) [default false] Open all links innewwindows (by adding the attribute `target="_blank"` to `<a>` tags) **(since v1.7.0)**
351
+
***openLinksInNewWindow**: (boolean) [default false] Open all links innewwindows
352
+
(by adding the attribute `target="_blank"` to `<a>` tags) **(since v1.7.0)**
336
353
337
354
***backslashEscapesHTMLTags**: (boolean) [default false] Support forHTML Tag escaping. ex:`\<div>foo\</div>`**(since v1.7.2)**
338
355
@@ -409,15 +426,17 @@ var showdown = require('showdown'),
409
426
410
427
## Tests
411
428
412
-
A suite of tests is available which require node.js. Once node is installed, run the following command from the project root to install the dependencies:
429
+
A suite of tests is available which require node.js. Once node is installed, run the following command from
430
+
the project root to install the dependencies:
413
431
414
432
npm install
415
433
416
434
Once installed the tests can be run from the project root using:
417
435
418
436
npm test
419
437
420
-
New test cases can easily be added. Create a markdown file (ending in`.md`) which contains the markdown to test. Create a `.html` file of the exact same name. It will automatically be tested when the tests are executed with`mocha`.
438
+
New test cases can easily be added. Create a markdown file (ending in`.md`) which contains the markdown to test.
439
+
Create a `.html` file of the exact same name. It will automatically be tested when the tests are executed with`mocha`.
Copy file name to clipboardExpand all lines: src/options.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,14 @@ function getDefaultOpts (simple) {
18
18
},
19
19
prefixHeaderId: {
20
20
defaultValue: false,
21
-
describe: 'Specify a prefix to generated header ids',
21
+
describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix',
22
22
type: 'string'
23
23
},
24
+
rawPrefixHeaderId: {
25
+
defaultValue: false,
26
+
describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
27
+
type: 'boolean'
28
+
},
24
29
ghCompatibleHeaderId: {
25
30
defaultValue: false,
26
31
describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
0 commit comments