Skip to content

Commit

Permalink
Merge pull request #129 from curbengh/lang-prefix
Browse files Browse the repository at this point in the history
test: 'langPrefix' option
  • Loading branch information
curbengh committed Sep 28, 2020
2 parents 7730fd5 + 9ed38b9 commit 45538c5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -29,6 +29,7 @@ markdown:
render:
html: true
xhtmlOut: false
langPrefix: 'language-'
breaks: true
linkify: true
typographer: true
Expand Down
42 changes: 27 additions & 15 deletions test/index.js
Expand Up @@ -78,23 +78,35 @@ describe('Hexo Renderer Markdown-it', () => {
result.should.equal(parsed_gfm);
});

it('should handle a custom configuration', () => {
hexo.config.markdown.render = {
html: false,
xhtmlOut: true,
breaks: true,
langPrefix: '',
linkify: true,
typographer: true,
quotes: '«»“”'
};
describe('render options', () => {
it('custom options', () => {
hexo.config.markdown.render = {
html: false,
xhtmlOut: true,
breaks: true,
langPrefix: '',
linkify: true,
typographer: true,
quotes: '«»“”'
};

const parsed_custom = fs.readFileSync('./test/fixtures/outputs/custom.html', 'utf8');
const source = fs.readFileSync('./test/fixtures/markdownit.md', 'utf8');
const result = parse({
text: source
const parsed_custom = fs.readFileSync('./test/fixtures/outputs/custom.html', 'utf8');
const source = fs.readFileSync('./test/fixtures/markdownit.md', 'utf8');
const result = parse({
text: source
});
result.should.equal(parsed_custom);
});

it('langPrefix', () => {
hexo.config.markdown.render = {
langPrefix: 'lang-'
};

const text = '```js\nexample\n```';
const result = parse({ text });
result.should.eql('<pre><code class="lang-js">example\n</code></pre>\n');
});
result.should.equal(parsed_custom);
});

describe('plugins', () => {
Expand Down

0 comments on commit 45538c5

Please sign in to comment.