dbankier / vscode-instant-markdown

vscode extension for instant markdown previews
53 stars 23 forks source link

Allow markdown-it-plantuml options override and cursor follow disable #58

Open adamwtow opened 3 years ago

adamwtow commented 3 years ago

Added support to enable overriding the default options of markdown-it-plantuml as per: https://github.com/gmunguia/markdown-it-plantuml#advanced-usage. The reason for this is that the built-in VS Code Markdown Preview expects PlantUML to be defined inside a code block:

```plantuml @startuml

@enduml ```

Whereas markdown-it-plantuml expects @startuml and @enduml not to be within a code block like this:

@startuml

@enduml

Using the changes proposed in this PR, if I configure instantmarkdown as follows I get nice plant UML support in both VS Code Markdown Preview and this plugin.

Also added support to disable cursor following as the current implementation interferes with PlantUML rendering (does not render if cursor inside plantuml drawing due to insertion of '<span id="instant-markdown-cursor"></span>\n').

{
  "instantmarkdown.cursor": false,
  "instantmarkdown.scroll": false,
  "instantmarkdown.plantUMLOptions": {
    "openMarker": "```plantuml",
    "closeMarker": "```"
  }
}
adamwtow commented 3 years ago

This is the first time I've ever tried working with JS/TS/VSCode Extensions. On my machine I get an error when trying to debug the extension complaining about vscode.window.onDidChangeTextEditorVisibleRanges not existing. I just commented out the lines using it on my side when testing these changes.