mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
feat(ghCodeBlocks): add option to disable GH codeblocks
GFM support fenced codeblocks. Showdown, since very early, adopted this too. It is now possible to disable GFM codeblocks with the option "ghCodeBlocks" set to false. It is enabled by default
This commit is contained in:
parent
5ec75c459b
commit
c33f98884b
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -16,7 +16,8 @@ var showdown = {},
|
|||
literalMidWordUnderscores: false,
|
||||
strikethrough: false,
|
||||
tables: false,
|
||||
tablesHeaderId: false
|
||||
tablesHeaderId: false,
|
||||
ghCodeBlocks: true // true due to historical reasons
|
||||
},
|
||||
globalOptions = JSON.parse(JSON.stringify(defaultOptions)); //clone default options out of laziness =P
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
showdown.subParser('githubCodeBlocks', function (text, options, globals) {
|
||||
'use strict';
|
||||
|
||||
// early exit if option is not enabled
|
||||
if (!options.ghCodeBlocks) {
|
||||
return text;
|
||||
}
|
||||
|
||||
text += '~0';
|
||||
|
||||
text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, m1, m2) {
|
||||
|
|
9
test/features/disable_gh_codeblocks.html
Normal file
9
test/features/disable_gh_codeblocks.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<p>this is some text</p>
|
||||
|
||||
<p><code>php
|
||||
function thisThing() {
|
||||
echo "some weird formatted code!";
|
||||
}
|
||||
</code></p>
|
||||
|
||||
<p>some other text</p>
|
9
test/features/disable_gh_codeblocks.md
Normal file
9
test/features/disable_gh_codeblocks.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
this is some text
|
||||
|
||||
```php
|
||||
function thisThing() {
|
||||
echo "some weird formatted code!";
|
||||
}
|
||||
```
|
||||
|
||||
some other text
|
|
@ -27,7 +27,8 @@ describe('showdown.options', function () {
|
|||
literalMidWordUnderscores: false,
|
||||
strikethrough: false,
|
||||
tables: false,
|
||||
tablesHeaderId: false
|
||||
tablesHeaderId: false,
|
||||
ghCodeBlocks: true
|
||||
};
|
||||
expect(showdown.getDefaultOptions()).to.be.eql(opts);
|
||||
});
|
||||
|
|
|
@ -21,6 +21,8 @@ describe('makeHtml() features testsuite', function () {
|
|||
converter = new showdown.Converter({literalMidWordUnderscores: true});
|
||||
} else if (testsuite[i].name === '#164.3.strikethrough') {
|
||||
converter = new showdown.Converter({strikethrough: true});
|
||||
} else if (testsuite[i].name === 'disable_gh_codeblocks') {
|
||||
converter = new showdown.Converter({ghCodeBlocks: false});
|
||||
} else {
|
||||
converter = new showdown.Converter();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user