Skip to content
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

Add image class option #75

Merged
merged 1 commit into from
Jan 22, 2022
Merged

Conversation

fkurz
Copy link
Contributor

@fkurz fkurz commented Jan 6, 2022

Summary

This change adds an image class option to the rendered HTML IMG tag so that it can be styled more easily with CSS.

Image class can be added in two ways

  1. by specifying the option in the options block of fenced code blocks
      ```{.mermaid imageClass="my-image-class"}
      ...
  2. or by setting the environment variable MERMAID_FILTER_IMAGE_CLASS
    export MERMAID_FILTER_IMAGE_CLASS=mermaid-diagram

Example

gh repo clone raghur/mermaid-filter
cd mermaid-filter
git checkout add-image-class-option
npm install
npm link 
pandoc --filter mermaid-filter --from markdown --to html /tmp/mermaid-image-class-option.md > /tmp/mermaid-image-class-option.html && open /tmp/mermaid-image-class-option.html

where /tmp/mermaid-image-class-option.md has the following content

<style scoped>
.mermaid-diagram {
  border: 1px red solid;
  width: 100%;
}
</style>

```{.mermaid imageClass=mermaid-diagram format=svg theme=forest #fig-1}
flowchart LR
    Start --> Stop
```

will render a page where the rendered Mermaid flowchart has a red border and 100% width.

mermaid-image-class-option

@raghur raghur merged commit 3d70296 into raghur:master Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants