Skip to content

Commit

Permalink
Merge pull request #72 from empress/use-showdown-config
Browse files Browse the repository at this point in the history
allow you to pass showdownConfig for internal toc builder
  • Loading branch information
mansona authored Jun 30, 2023
2 parents 0b236d2 + ca207f0 commit f406905
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/markdown-to-jsonapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MarkDownToJsonApi extends PersistentFilter {
throw new Error(`Unknown content type: ${unsupportedContentTypes[0]}`);
}

this.converter = new showdown.Converter();
this.converter = new showdown.Converter(this.options.showdownConfig);

const referenceAttributes = this.options.references.map((ref) => {
if (typeof ref === 'object') return ref.name;
Expand Down
18 changes: 18 additions & 0 deletions test/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,22 @@ This is the first part
{ text: 'Hello world', depth: '1', id: 'helloworld' },
]);
});

it('can provide config for showdown when building toc', async function () {
const result = await buildSingleFile(`# Hello world
This is the only part
`, {
contentTypes: ['toc'],
showdownConfig: {
ghCompatibleHeaderId: true,
prefixHeaderId: 'toc_',
},
});

expect(result.attributes.toc).to.deep.equal([
{ text: 'Hello world', depth: '1', id: 'toc_hello-world' },
]);
});
});

0 comments on commit f406905

Please sign in to comment.