improve renderer option handling

Don't waste time constructing a renderer then override it if one is
passed into the options object.
edit
Ujjwal Sharma 2021-05-13 19:58:45 +05:30
parent cf8e64bd85
commit 6884741b94
No known key found for this signature in database
GPG Key ID: 460B292812C67D9F
1 changed files with 24 additions and 20 deletions

View File

@ -424,6 +424,9 @@ const Plugin = () => {
deck = reveal; deck = reveal;
let { renderer, ...markedOptions } = deck.getConfig().markdown;
if (!renderer) {
let renderer = new marked.Renderer(); let renderer = new marked.Renderer();
renderer.code = ( code, language ) => { renderer.code = ( code, language ) => {
@ -448,10 +451,11 @@ const Plugin = () => {
return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`; return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`;
}; };
}
marked.setOptions( { marked.setOptions( {
renderer, renderer,
...deck.getConfig().markdown ...markedOptions
} ); } );
return processSlides( deck.getRevealElement() ).then( convertSlides ); return processSlides( deck.getRevealElement() ).then( convertSlides );