-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for mermaid directives and themeVariables #192
base: master
Are you sure you want to change the base?
Conversation
markdownPreview/index.ts
Outdated
@@ -6,17 +6,27 @@ function init() { | |||
const darkModeTheme = configSpan?.dataset.darkModeTheme; | |||
const lightModeTheme = configSpan?.dataset.lightModeTheme; | |||
|
|||
const directives = JSON.parse(configSpan?.dataset.directives ?? ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be wrapped in a try catch in case it fails
Example (add to `setttings.json`): | ||
```json | ||
{ | ||
"markdown-mermaid.directives": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new setting should also be documented in the package.json
markdownPreview/index.ts
Outdated
@@ -6,17 +6,27 @@ function init() { | |||
const darkModeTheme = configSpan?.dataset.darkModeTheme; | |||
const lightModeTheme = configSpan?.dataset.lightModeTheme; | |||
|
|||
const directives = JSON.parse(configSpan?.dataset.directives ?? ''); | |||
const directivesDebug = 'debug' in directives ? directives.debug : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would users need the debug option?
src/index.ts
Outdated
const lightModeTheme = "themeVariables" in directives ? | ||
'base' : sanitizeMermaidTheme(config.get('lightModeTheme')); | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It this comment useful?
src/index.ts
Outdated
|
||
// Note: single quotes needed for directives | ||
// JSON.stringify will contain double quotes | ||
// encodeURIcomponent could be used to be safer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the json itself still contain single quotes, such as inside strings?
src/index.ts
Outdated
// Setting themeVariables will override | ||
// darkModeTheme and lightModeTheme | ||
// both will be set to "base" | ||
const darkModeTheme = "themeVariables" in directives ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why themeVariables need to reset the theme?
@mjbvz If I submit a pr adding a try/catch around |
Pushed fix for merge conflicts and using try catch. Still not convinced on merging this yet because:
|
User can modify setttings.json to set mermaid directives and themeVariables.