mkaczanowski / pastebin

Simple, fast, standalone pastebin service
MIT License
155 stars 27 forks source link

Render mermaid diagram in markdown #9

Closed weitanism closed 3 years ago

weitanism commented 3 years ago

Add support for mermaid in the markdown format

here is an example: https://paste.chrisyunhua.com/BSgcltfX2I5XkwGi2iuss

mkaczanowski commented 3 years ago

Hi, this looks great and thanks for the PR!

The intention of this Pastebin impl is to keep things as simple as possible. I imagine mermaid js is not going to be used by the majority, so I would rather gate the feature.

What I propose is to pluginify the current code, to accommodate custom plugins such as mermaid.js.

mkaczanowski commented 3 years ago

@Chrisyunhua I'll refactor code a bit and I'll get back to you

weitanism commented 3 years ago

Sorry for the late replay.

To accommodate custom plugins(only frontend related), how about adding a parameter --plugins to the entrypoint which accepts a list of js url and render them as <script> in the index.html, then we could run the app with:

pastebin --plugins https://url/to/plugin.js
mkaczanowski commented 3 years ago

@Chrisyunhua I did a small refactoring to accommodate plugins such as mermaid.js, please see: https://github.com/mkaczanowski/pastebin/commit/a8e8476c9c25575d5f8a29431bff3d4d5459ac0c

Now you can pass:

--plugins prism mermaid

and that should work :)

weitanism commented 3 years ago

THX, I've tried the latest docker image, it looks really cool!