asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104 stars 101 forks source link

Add PlantUML extension #52

Closed bbucko closed 2 years ago

bbucko commented 9 years ago

This extension uses PlantUML Server to transform [plantuml] blocks into diagrams. It's not meant to replace asciidoctor-diagram but allow PlantUML diagrams to be used in asciidoctor.js without need for local installation of Graphviz.

deflate.js and encode.js files are provided by PlantUML team and I decided to use them to ensure compatibility. Deflate.js originally is in this repo: https://github.com/johan/js-deflate. encode.js is a custom implementation of base64-like encoder.

Also, I'm aware that DocInfoProcessor is missing and both js files are not included but this extension is meant to be used in AsciiDoctor.js Preview Chrome extension.

mojavelinux commented 9 years ago

It's not meant to replace asciidoctor-diagram

I think in the long run this should be merged with Asciidoctor Diagram. I'd like to see Asciidoctor Diagram be able to work in an Asciidoctor.js mode where it uses image servers to generate when access to system commands is not available. (In fact, it already has a pretty nice abstraction to the underlying commands so it shouldn't be a huge challenge). For now, of course, we can explore the use of this more minimal implementation.

mojavelinux commented 9 years ago

In fact, there is an example of an Asciidoctor Diagram extension that uses an external service to render images. See https://github.com/hnakamur/asciidoctor-diagram-cacoo

bbucko commented 9 years ago

I moved content from src attr to title and alt. This way we'll have a tooltip and some sort of accessibility.

mojavelinux commented 9 years ago

I think you still need to escape the content though or else it could lead to broken HTML, especially since a source diagram can have any character. The content may already be partially escaped, but I know that double quotes aren't replaced with "

bbucko commented 9 years ago

Yep, you're right. Could you recommend something? I'm not really a Ruby Dev :) I found htmlentities but I don't how to add a gem.

bbucko commented 9 years ago

As a quick fix I escaped only " and ' chars. It seems like it's working (more or less). I'll do it properly once I figure out how to add gems or generate a class that contains all XML entities that should be escaped.

bbucko commented 9 years ago

@mojavelinux could you check now?

eshepelyuk commented 6 years ago

@mojavelinux as far as I understand this PR will open the path for Antora to render PlantUML diagrams ?

Maybe it worth create an issue in Antora repo with links to this PR ?

mojavelinux commented 5 years ago

Now that asciidoctor-plantuml and asciidoctor-plantuml.js both exist (and both use the PlantUML server), is this extension still needed? Or is it covered by one or both of those extensions?