-
Notifications
You must be signed in to change notification settings - Fork 3
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
content.mermaid_image
plugin
#48
Comments
This is a low-priority plugin since it depends on external tools and supplements an existing way of using Mermaid diagrams. |
I think this plugin is duplicate of content text {
format_as = "code"
code_language = "mermaid"
text = <<-EOT
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
EOT
} And leave image rendering for markdown viewer. Since this will produce: '''mermaid
graph TD;
A-->A;
A-->C;
B-->D;
C-->D;
''' Resulting in viewers that support mermaid code blocks rendering image instead (e.g: Github): graph TD;
A-->A;
A-->C;
B-->D;
C-->D;
|
@dobarx indeed, it provides similar functionality, but, as noted in the "Background", it might be beneficial to have a static image generator. See also "Important" block with a couple of notes. I suggest we leave this issue in |
Hmm, then there could be two approaches:
|
Background
Users can add Mermaid diagrams to the documents using
content.text
withformat_as
set tocode
andcode_language
set tomermaid
, but in the case user's Markdown renderer does not support Mermaid diagrams,fabric
should support static rendering.Design
The plugin draws Mermaid diagrams as static images.
Specification
code
-- a required string attribute that contains a Mermaid code.alt_text
-- an optional string attribute with alt text for the image tagoutput_file
-- a required string attribute that contains a path for the output fileBehaviour
The plugin renders mermaid diagram code into a static image and returns a Markdown image tag (similar to
content.image
).The
code
value is treated as Go template string (query_result
object from the local context)For example,
renders image
into
/tmp/diagram.png
and returnsImportant
Things to consider:
mmdc
)mermaid.go
)fabric
runsmermaid-cli
provides a convenient way of converting allmermaid
code tags into images during post-processing of the Markdown file -- https://github.com/mermaid-js/mermaid-cli?tab=readme-ov-file#transform-a-markdown-file-with-mermaid-diagrams -- which lowers the need for this Fabric plugin.Deliverables
content.mermaid_image
pluginThe text was updated successfully, but these errors were encountered: