markdown-it-plantuml icon indicating copy to clipboard operation
markdown-it-plantuml copied to clipboard

Handling multi-line closeMarker

Open fxfan opened this issue 3 years ago • 1 comments

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);

fxfan avatar May 14 '21 13:05 fxfan

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

dacodekid avatar Sep 19 '23 19:09 dacodekid