Coder Social home page Coder Social logo

gitbook-plugin-local-plantuml's People

Contributors

donbowman avatar vliejo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gitbook-plugin-local-plantuml's Issues

Allow Handling of Separate Files containing PlantUml

Ideally, inaddition to this style of plantUML

{% plantuml %} 
Class MyStage
Class Timeout {
    +constructor:function(cfg)
        +timeout:function(ctx)
        +overdue:function(ctx)
        +stage: Sage 
        +other_thing: Other Thing
}
Stage <|-- Timespent
{% endplantuml %}

You would be able to include this style

{% plantuml src='sage.puml' %}
{% endplantuml %}

File sage.puml:

@startuml
Class MyStage
Class Timeout {
    +constructor:function(cfg)
        +timeout:function(ctx)
        +overdue:function(ctx)
        +stage: Sage 
        +other_thing: Other Thing
}
Stage <|-- Timespent
@enduml

This would allow for the use of Plant Uml editor tools that can auto-render PNGs while writing the pum l (I am looking at you, Intellij Plugins)

PlantUML is HTML escaped/encoded, so many UML diagrams fail to render

Issue Description

The text in a PlantUML "block" seems to be HTML escaped/encoded, so when the text is extracted from the block in the plugin, it is passed on to PlantUML changed from what was originally written.

It looks like the Gitbook framework automatically encodes the "block" text. This may not have happened for an ealier version of gitbook.

Steps to Reproduce

$ gitbook version
CLI version: 2.3.0
GitBook version: 3.2.0

If I write this in my .md document:

{% plantuml %} 
Class MyStage
Class Timeout {
    +constructor:function(cfg)
        +timeout:function(ctx)
        +overdue:function(ctx)
        +stage: Sage 
        +other_thing: Other Thing
}
Stage <|-- Timespent
{% endplantuml %}

This plugin tries to render this text:

Class MyStage
Class Timeout {
    +constructor:function\(cfg\)
        +timeout:function\(ctx\)
        +overdue:function\(ctx\)
        +stage: Sage 
        +other\_thing: Other Thing
}
Stage &lt;\|-- Timespent

That then generates this file
bad-puml-render

The cause of issue is that for this text:

    +constructor:function(cfg)

The block object encodes the text (escaping parentheses, for example), and gives the plantuml.jar
this:

    +constructor:function\(cfg\)

Similarly this Stage &lt;\|-- Timespent gets an html escape of the < character to a &lt; and becomes Stage &lt;\|-- Timespent

Details

Here is the problematic section of code (from gitbook-plugin-local-plantuml/index.js, lines 17-25):

module.exports = {
  blocks: {
    plantuml: {
      process: function (block) {

        var imageName = hashedImageName(block.body) + ".png";
        this.log.debug("using tempDir ", os.tmpdir());
        var imagePath = path.join(os.tmpdir(), imageName);
        var umlText = block.body;

The line

var umlText = block.body;

gets text that is already escaped. As far as I can tell, the block object does not contain any reference to the un-encoded text. It also does not contain any line-numbers, or any other way determine the text which generated the initial block.

The alternate Gitbook PlantUML plugin uses regexes to extract the text, which seems cumbersome, but might be the only way to get ahold of the unchanged text.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.