Browse Source

Added `zero` preset. Related to #12

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
958308a3b0
  1. 9
      README.md
  2. 1
      lib/index.js
  3. 53
      lib/presets/zero.js
  4. 12
      test/misc.js

9
README.md

@ -62,6 +62,12 @@ var md = window.markdownit();
console.log(md.render('# markdown-it rulezz!'));
```
Single lines rendering, without paragraph wrap:
```js
var md = require('markdown-it')();
console.log(md.renderInline('__markdown-it__ rulezz!'));
```
### Configuring
@ -82,6 +88,9 @@ active syntax rules and options for common use cases.
all rules enabled, but still without html, typographer & autolinker.
- [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
when no preset name given.
- [zero](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
all rules disabled (useful to quickly setup your config via `.enable()`).
```js

1
lib/index.js

@ -15,6 +15,7 @@ var Ruler = require('./ruler');
var config = {
'default': require('./presets/default'),
zero: require('./presets/zero'),
full: require('./presets/full'),
commonmark: require('./presets/commonmark')
};

53
lib/presets/zero.js

@ -0,0 +1,53 @@
// "Zero" preset, with nothing enabled. Useful for manual configuring of simple
// modes. For example, to parse bold/italic only.
'use strict';
module.exports = {
options: {
html: false, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags (<br />)
breaks: false, // Convert '\n' in paragraphs into <br>
langPrefix: 'language-', // CSS language prefix for fenced blocks
linkify: false, // autoconvert URL-like texts to links
// Enable some language-neutral replacements + quotes beautification
typographer: false,
// Double + single quotes replacement pairs, when typographer enabled,
// and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
quotes: '\u201c\u201d\u2018\u2019' /* “”‘’ */,
// Highlighter function. Should return escaped HTML,
// or '' if input not changed
//
// function (/*str, lang*/) { return ''; }
//
highlight: null,
maxNesting: 20 // Internal protection, recursion limit
},
components: {
core: {
rules: [
'block',
'inline'
]
},
block: {
rules: [
'paragraph'
]
},
inline: {
rules: [
'text'
]
}
}
};

12
test/misc.js

@ -200,6 +200,18 @@ describe('Misc', function () {
assert.strictEqual(md.render('*b*'), '<par><it>b</it></par>');
});
it('zero preset should disable everything', function () {
var md = markdownit('zero');
assert.strictEqual(md.render('___foo___'), '<p>___foo___</p>\n');
assert.strictEqual(md.renderInline('___foo___'), '___foo___');
md.enable('emphasis');
assert.strictEqual(md.render('___foo___'), '<p><strong><em>foo</em></strong></p>\n');
assert.strictEqual(md.renderInline('___foo___'), '<strong><em>foo</em></strong>');
});
});

Loading…
Cancel
Save