Skip to content
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

gitbook-plugin-uml does not work #58

Closed
azu opened this issue Jun 27, 2020 · 6 comments · Fixed by #60
Closed

gitbook-plugin-uml does not work #58

azu opened this issue Jun 27, 2020 · 6 comments · Fixed by #60
Labels
Type: Bug Bug or Bug fixes

Comments

@azu
Copy link
Member

azu commented Jun 27, 2020

Summary

https://github.com/vowstar/gitbook-plugin-uml does not work on Honkit

  • HonKit version: 3.3.10

Step to reproduce

Expected results

Render the uml correctly.

Actual results

Rendering error.

Note

https://github.com/vowstar/gitbook-plugin-uml/blob/99ad7443d2a2c051c2327c7ebda63a0ca19f1621/index.js#L41
Dump the code variable and I noticed the differnece between GitBook and HonKit

GitBook

@startuml

    Class Stage
    Class Timeout {
        +constructor:function(cfg)
        +timeout:function(ctx)
        +overdue:function(ctx)
        +stage: Stage
    }
    Stage <|-- Timeout

@enduml

HonKit

@startuml

```
Class Stage
Class Timeout {
    +constructor:function(cfg)
    +timeout:function(ctx)
    +overdue:function(ctx)
    +stage: Stage
}
Stage <|-- Timeout
```

@enduml
@azu azu added the Type: Bug Bug or Bug fixes label Jun 27, 2020
@azu
Copy link
Member Author

azu commented Jun 27, 2020

azu added a commit that referenced this issue Jun 27, 2020
@azu
Copy link
Member Author

azu commented Jun 27, 2020

https://github.com/vowstar/gitbook-plugin-uml/blob/99ad7443d2a2c051c2327c7ebda63a0ca19f1621/index.js#L138-L203
convert to

{% uml %}
@startuml

	Class Stage
	Class Timeout {
		+constructor:function(cfg)
		+timeout:function(ctx)
		+overdue:function(ctx)
		+stage: Stage
	}
 	Stage <|-- Timeout

@enduml
{% enduml %}

@azu
Copy link
Member Author

azu commented Jun 27, 2020

return parser.preparePage(currentPage.getContent());

convert indent to backtick(codeblock)

@azu
Copy link
Member Author

azu commented Jun 27, 2020

I figure out it.
#58 (comment)

The plugin CodeBlock to Block Tags.

and then,

function preparePage(src) {
let levelRaw = 0;
const content = markdown.toContent(src, {
math: true,
template: true,
});
const textMarkdown = markdown.toText(content, {
annotate: function (state, raw, token) {
const tokenType = token.getType();
if (tokenType === MarkupIt.ENTITIES.TEMPLATE) {
const type = token.getData().get("type");
const expr = token.getAsPlainText();
if (type === "expr") {
if (expr === "raw") {
levelRaw = levelRaw + 1;
} else if (expr == "endraw") {
levelRaw = 0;
}
}
}
if ((tokenType === MarkupIt.BLOCKS.CODE || tokenType === MarkupIt.STYLES.CODE) && levelRaw === 0) {
return escape(raw);
}
return raw;
},
});
return textMarkdown;
}
convert \t to CodeBlock.

@azu
Copy link
Member Author

azu commented Jun 27, 2020

https://github.com/GitbookIO/gitbook-markdown/blob/master/package.json
GitBook use 1.3.2. But HonKit use 2.x

@azu
Copy link
Member Author

azu commented Jun 27, 2020

#60 will fix this issue.

But, still exist edge case like following.
&lt; should be parse error. We not have solution for the edge case.

{% uml %}
@startuml

	Class Stage
	Class Timeout {
		+constructor:function(cfg)
		+timeout:function(ctx)
		+overdue:function(ctx)
		+stage: Stage
	}
 	Stage &lt;|-- Timeout

@enduml
{% enduml %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant