1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-01-17 13:28:29 +01:00

Merge pull request #3443 from t-fritsch/allow-markdown-default-options-override

adds ability to override markdown plugin default options
This commit is contained in:
Hakim El Hattab 2023-08-06 13:50:11 +02:00 committed by GitHub
commit f4e1a8ef50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@
import { marked } from 'marked';
const DEFAULT_SLIDE_SEPARATOR = '\r?\n---\r?\n',
DEFAULT_VERTICAL_SEPARATOR = null,
DEFAULT_NOTES_SEPARATOR = 'notes?:',
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
@ -94,10 +95,12 @@ const Plugin = () => {
* values for what's not defined.
*/
function getSlidifyOptions( options ) {
const userDefaultOptions = deck.getConfig().markdown?.defaultOptions;
options = options || {};
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.separator = options.separator || userDefaultOptions?.separator || DEFAULT_SLIDE_SEPARATOR;
options.verticalSeparator = options.verticalSeparator || userDefaultOptions?.verticalSeparator || DEFAULT_VERTICAL_SEPARATOR;
options.notesSeparator = options.notesSeparator || userDefaultOptions?.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.attributes = options.attributes || '';
return options;
@ -423,7 +426,7 @@ const Plugin = () => {
deck = reveal;
let { renderer, animateLists, ...markedOptions } = deck.getConfig().markdown || {};
let { renderer, animateLists, defaultOptions, ...markedOptions } = deck.getConfig().markdown || {};
if( !renderer ) {
renderer = new marked.Renderer();