markdown-confluence icon indicating copy to clipboard operation
markdown-confluence copied to clipboard

Support for plantuml/graphviz or general preprocessing of file

Open avengerpenguin opened this issue 2 years ago • 2 comments

Hi,

This has worked really well for me on first use but I've got some issues with where I've been using https://github.com/joethei/obsidian-plantuml and https://github.com/QAMichaelPeng/obsidian-graphviz extensively in my documents.

I've preferred these to Mermaid for various reasons so it would be good to think about how to support these other plugins or indeed a more general approach for it to publish processed Markdown after other plugins have added stuff (e.g. as would be the case for plugins like https://github.com/obsidian-tasks-group/obsidian-tasks that generate content).

I'm happy to have a try of this myself this week in my own fork but I thought I'd raise an issue first to see if this has been thought of and if there's opinions on how to approach things.

I'm thinking either:

  1. There's a way to configure a preprocesser command that takes the raw Markdown and replaces various codeblocks with images. Then that Markdown is sent for Confluence conversion, not the original. I already publish one vault as HTML via https://docs.getpelican.com/en/4.8.0/index.html so I've done this approach before to preprocess Markdown. The bit that I'd need is a clear hook to get markdown-confluence to call out to first.
  2. I can literally copy-paste the Mermaid plugin in this repo and make a sibling version for PlantUML.
  3. I'm not experienced with writing Obsidian plugins but maybe there's a way for this one to feed off the output of the others I use?

I don't think my company has PlantUML or Graphviz support set up on Confluence so a path of least resistance for me would be to flatten to images before this plugin runs and leverage the fact it supports image uploads.

Would love to hear some thoughts/input and I'll have a try at what I can get working.

avengerpenguin avatar May 31 '23 16:05 avengerpenguin

Hey,

I have had PlantUML support requested from a friend. I extracted the logic so it should be "easy" to copy the Mermaid to support a PlantUML one. https://github.com/markdown-confluence/markdown-confluence/blob/main/packages/lib/src/ADFProcessingPlugins/MermaidRendererPlugin.ts The current plan in my head was to offer a PlantUML plugin that called out to the PlantUML website by default to render to images with a configuration option that would allow the user to define their own for privacy reasons.

I hadn't considered graphvis but am open to adding a Plugin for that. It would need to have a way to detect if graphvis is installed and if not the bypass the rendering.

I haven't looked at how to hook into the rendered Markdown in Obsidian. Currently the logic calls vault.cachedRead https://github.com/markdown-confluence/markdown-confluence/blob/main/packages/obsidian/src/adaptors/obsidian.ts#L67 I am not aware of a method in the current API surface to get additional MD from other plugins. If there is a way happy to have a look at updating the code to use that path.

Long term I want to make it possible for users to dynamically load their own Plugins from outside my codebase but that hasn't been a priority yet.

Nothing you have described sounds very complex it will take a bit of testing and adding some new options that need to be explored for the various usages of the code.

Happy to accept contributions :) If you want to chat though the code as you are working on it feel free to join Discord and we can continue the conversation there.

andymac4182 avatar May 31 '23 20:05 andymac4182

I look forward to having it as well. Unfortunately, I'm not knowledgeable in JS/TS to contribute.

igor-yampolskyi avatar Jul 18 '23 12:07 igor-yampolskyi