gmunguia / markdown-it-plantuml

:herb: :book: plantuml diagrams in your markdown
MIT License
98 stars 21 forks source link

Handling multi-line closeMarker #34

Open fxfan opened 3 years ago

fxfan commented 3 years ago

What I want to do is like following:

const MarkdownIt = require('markdown-it')
const md = new MarkdownIt()
md.use(require('markdown-it-plantuml'), {
  openMarker: '```puml\n@startuml',
  closeMarker: '@enduml\n```'
})

md.render(`\`\`\`puml
@startuml
Bob -> Alice : hello
@enduml
\`\`\``)

Because Previewing markdown on vscode needs the plantuml description to be enclosed with ```puml and ```.

When running the above sample, markdown-it-plantuml can find openMarker and closeMarker, but fails in moving the cursor after closing.

The simple solution is to rewrite index.js as follows, which will work as expected for me, but I'm not sure if it's the proper way.

135c135
< state.line = nextLine + (autoClosed ? 1 : 0);
---
> state.line = nextLine + (autoClosed ? 1 + closeMarker.match(/\n/g).length : 0);
dacodekid commented 9 months ago

This would come in handy while using this plugin with Vuepress or similar.