vscode-markdown-pdf icon indicating copy to clipboard operation
vscode-markdown-pdf copied to clipboard

PDF doesn't consider plantuml within a markdown code block with three back-ticks```

Open SebastianBaeumler opened this issue 5 years ago • 20 comments

plantuml will be ignored if it is written in a CodeBlock.

if I use this image

I'll see the rendered plantuml in the Preview.

But if I export the document I got image

If I remove the code block, the export works fine, but the Preview doesn't show the rendered plantuml anymore.

Do I make something wrong?

best regards, Sebastian

SebastianBaeumler avatar Nov 22 '19 09:11 SebastianBaeumler

Hello! The problem with a single diagram within a file could be solved with overriding extension parameters "plantumlOpenMarker" and "plantumlCloseMarker" in settings.json. E.g.

    "markdown-pdf.plantumlOpenMarker": "```plantuml\n@startuml",
    "markdown-pdf.plantumlCloseMarker": "@enduml\n```"

But it doesn't work correctly with several plantuml diagrams within a single MD-file - it just draws the first diagram, but rest of them stay as code blocks. E.g.(three ` via space are made for escaping)

# TOC

- [TOC](#toc)
- [Common1](#common1)
- [Diagrams](#diagrams)
  - [D1](#d1)
  - [D2](#d2)

# Common1

some text here

# Diagrams

## D1

```plantuml
@startuml
participant P1 order 1 #red
participant P2 order 2
database D1 order 3

activate P1

P1 -> P2
activate P2
    loop For each item
        P2 -> P2 
        activate P2 #Gray
            alt 
                P2 -> D1
                activate D1
                return 
            end
            P2 -> P2
        return
    end
return

@enduml
` ` `

## D2

```plantuml
@startuml
participant P1 order 1 #red
participant P2 order 2
database D1 order 3

activate P1

P1 -> P2
activate P2
    loop For each item
        P2 -> P2 
        activate P2 #Gray
            alt 
                P2 -> D1
                activate D1
                return 
            end
            P2 -> P2
        return
    end
return

@enduml
` ` `

Btw, removing code blocks also helps with default settings, all the diagrams are drawn, but it makes MD-file unreadable.

Enywhere avatar Dec 24 '19 09:12 Enywhere

Yeah, it would be really nice, if multiple plantUML diagrams in a markdown file would be rendered correctly in the PDF file :+1:. I would be very happy about such a feature :)

LostInDarkMath avatar Jul 24 '20 07:07 LostInDarkMath

With the following settings, it seems to work well with many diagrams in the same MD file:

"markdown-pdf.plantumlOpenMarker": "```plantuml",
"markdown-pdf.plantumlCloseMarker": "```",

This should probably be the defaults...

frederickjeanguerin avatar Aug 20 '20 19:08 frederickjeanguerin

@frederickjeanguerin I tried your approach but it did not work for me. My diagrams have are things like that:

# some header
Text in markdown file here.

```plantuml
@startuml
skinparam nodesep 100
class Component
class Leaf
class Composite

Component : {abstract} operation()

Leaf : operation()

Composite : operation()
Composite : add(Component)
Composite : remove(Component)
Composite : getChild(int)

Component <|– Leaf
Component <|– Composite
Component “0..*” <–o “1” Composite
@enduml
[ignore this]```

Some more text here.

I also tried using

"markdown-pdf.plantumlOpenMarker": "```plantuml\n@startuml",
"markdown-pdf.plantumlCloseMarker": "@enduml\n```",

and

"markdown-pdf.plantumlOpenMarker": "```plantuml\\n@startuml",
"markdown-pdf.plantumlCloseMarker": "@enduml\\n```",

but they didn't work too.

Any other ideas?

LostInDarkMath avatar Aug 21 '20 07:08 LostInDarkMath

@LostInDarkMath

I just used the proposed configuration yesterday and it works perfectly for me, so I am a bit surprised it does not for you...

@enduml [ignore this]```

Is your final triple backquote on their own line alone?

frederickjeanguerin avatar Aug 21 '20 12:08 frederickjeanguerin

@frederickjeanguerin Yes, they are alone on one line: plantuml

If I use your line, the PDF is not build. Error message: TimeoutError: Navigation timeout of 30000 ms exceeded. ERROR: exportPdf().

LostInDarkMath avatar Aug 21 '20 12:08 LostInDarkMath

@LostInDarkMath

Maybe your PlantUML server is not working properly with the pdf generator. My actuel full settings (PlantUML + MarkDown PDF) are as follow:

image

frederickjeanguerin avatar Aug 21 '20 13:08 frederickjeanguerin

@frederickjeanguerin I have the same server. I also tried your "Letter" format, but it still does not work.

    "plantuml.commandArgs": [
    
    ],
    "plantuml.server": "https://www.plantuml.com/plantuml",
    "markdown-pdf.plantumlOpenMarker": "```plantuml",
    "markdown-pdf.plantumlCloseMarker": "```",
    "markdown.extension.toc.omittedFromToc": {

    
    }

Maybe this is related to https://github.com/yzane/vscode-markdown-pdf/issues/189 I mean the error message is really inexpressive.

LostInDarkMath avatar Aug 21 '20 14:08 LostInDarkMath

@LostInDarkMath

Indeed, could be related to #189

My versions are:

Vscode: 1.46.0 (system setup) OS: Windows 10.0.18363 markdown-pdf: 1.4.4 Chrome: 78.0.3904.130

frederickjeanguerin avatar Aug 21 '20 14:08 frederickjeanguerin

My versions: VS Code: 1.48.1 OS: Windows 7 x64 (6.1.7601) Makrdown PDF 1.4.4 Chrome: 78.0.3904.130

LostInDarkMath avatar Aug 21 '20 14:08 LostInDarkMath

@LostInDarkMath Maybe using a Windows 10 computer could help about it...

frederickjeanguerin avatar Aug 21 '20 14:08 frederickjeanguerin

Maybe but I think it should also work on Windows 7. There is no good reason not to.

LostInDarkMath avatar Aug 21 '20 14:08 LostInDarkMath

@LostInDarkMath You are right. It should be working on Windows 7. But maybe it's not because bugs happen :(

frederickjeanguerin avatar Aug 21 '20 15:08 frederickjeanguerin

it can be fixed quickly ? i meet too, and i modify the setting but not valid

lazycece avatar Aug 25 '20 05:08 lazycece

Hi, I'm having the same issue on MacOS.

Using the following config gives me the timeout error from above:

    "plantuml.render": "PlantUMLServer",
    "plantuml.server": "https://www.plantuml.com/plantuml",
    "markdown-pdf.plantumlOpenMarker": "```plantuml",
    "markdown-pdf.plantumlCloseMarker": "```",

Using the default config for open and close Marker works, but no diagram in PDF.

Removing the code block markers around the diagram and using default config works and has diagrams in PDF, but breaks the markdown syntax and other tools. So this is not an option.

How can we enable solve this? Why are code blocks skipped while parsing for PlantUML code?

marcpopp avatar Oct 27 '20 09:10 marcpopp

Windows 10, here. With

Version: 1.54.1 Commit: f30a9b73e8ffc278e71575118b6bf568f04587c8 Date: 2021-03-04T22:38:31.419Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Windows_NT x64 10.0.18363

Same problems. I've tried with

  • ```puml\r\n@startuml
  • ```puml\r\n
  • ```puml\n@startuml
  • ```puml\n
  • ```puml

(I'm using puml because I can see the PlantUML preview in IntelliJ, but I need to export the result to a person that does not have it.

Alternative solutions?

marcoXbresciani avatar Mar 05 '21 11:03 marcoXbresciani

Environment

Version: 1.55.1 (user setup)
Commit: 08a217c4d27a02a5bcde898fd7981bda5b49391b
Date: 2021-04-07T15:06:02.360Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.18363

With the markdown-pdf settings:

{
    "plantuml.render": "PlantUMLServer",
    "plantuml.server": "http://www.plantuml.com/plantuml",
    "markdown-pdf.plantumlCloseMarker": "```",
    "markdown-pdf.plantumlOpenMarker": "```plantuml"
}

it worked perfectly. Both markdown previewer and generated pdf show correctly.

Both w/ @startuml+@enduml and w/o @startuml+@enduml in the MD file work.

Thanks @frederickjeanguerin

tjroamer avatar Jun 05 '21 07:06 tjroamer

With the following settings, it seems to work well with many diagrams in the same MD file:

"markdown-pdf.plantumlOpenMarker": "```plantuml",
"markdown-pdf.plantumlCloseMarker": "```",

This should probably be the defaults...

Just tried it and it works fine with multiple diagrams at one md. It is worth to check the space where these options applied to, in my case I had: User (local windows machine), Remote [WSL: Ubuntu] (wslv2 with ubuntu on windows) and Workspace. I set that at all of it and it worked perfectly image

wvolkov avatar Jun 08 '21 16:06 wvolkov

Nice! it works as follow:

"markdown-pdf.plantumlOpenMarker": "```plantuml",
"markdown-pdf.plantumlCloseMarker": "```",

socay1 avatar Jan 27 '22 02:01 socay1

With the following settings, it seems to work well with many diagrams in the same MD file:

"markdown-pdf.plantumlOpenMarker": "```plantuml",
"markdown-pdf.plantumlCloseMarker": "```",

This should probably be the defaults...

I can confirm it works for multiple diagrams. Thanks!

TheRealJoci avatar Aug 29 '22 14:08 TheRealJoci