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

Cannot use plantuml with latex error #34

Open
giuli635 opened this issue Sep 13, 2024 · 9 comments
Open

Cannot use plantuml with latex error #34

giuli635 opened this issue Sep 13, 2024 · 9 comments

Comments

@giuli635
Copy link

giuli635 commented Sep 13, 2024

  • Configuration header:
diagram:
  engine:
    plantuml:
      mime-types:
        application/pdf: false
        image/png: true
  • Command: pandoc -L $PATH_OF_DIAGRAM -o summary.pdf summary.md
  • Content:
@startuml
class Nombre{
    Atributos
    __
    Operaciones
    --
    Responsabilidades
}
@enduml
  • Return: Cannot use plantuml with latex
  • Expected: use svg to render plantuml
@tarleb
Copy link
Member

tarleb commented Sep 16, 2024

Thanks for the report. So far I wasn't able to reproduce this. The following runs without error.

pandoc -L diagram.lua test.md -o out.pdf

where test.md is

---
title: Look at this nice and meaningless title
diagram:
  engine:
    plantuml:
      mime-types:
        application/pdf: false
        image/png: true
---

``` plantuml
@startuml
class Nombre{
    Atributos
    __
    Operaciones
    --
    Responsabilidades
}
@enduml
```

Please provide more details, ideally with a reproducible example.

@giuli635
Copy link
Author

giuli635 commented Sep 16, 2024

Sorry, it should be image/png: false. I forgot to change it, that's my "workaround".

@tarleb
Copy link
Member

tarleb commented Sep 16, 2024

Ah, I see. LaTeX doesn't work with SVG AFAIK, and these images first have to be converted to a different format first. So the filter is working as intended.

What's the reason that you'd prefer SVG for this?

@giuli635
Copy link
Author

Because I don't have plantuml support for PDF, it's really annoying to setup, and PNG most of the time renders in low resolution, and I suppose LaTeX scales it a little bit, so the result it's pretty bad

@tarleb
Copy link
Member

tarleb commented Sep 16, 2024

That makes sense. Let me check the code to see if there's an easy solution to this.

Do you have Inkscape or librsvg installed? We'll still need to convert the SVG to something that LaTeX can handle.

@giuli635
Copy link
Author

I have librsvg installed

@tarleb
Copy link
Member

tarleb commented Sep 17, 2024

I'm working on a better solution, but for the time being, you can use a little hack: It's a filter that wraps the diagram filter, pretending that the conversion is targeting HTML.

local diagram_filter = 'diagram.lua'
function Pandoc (doc)
  -- Copy the global environment, but set a different target FORMAT
  local env = {}
  for key, value in pairs(_G) do
    env[key] = value
  end
  env.FORMAT = 'html'

  -- Call the diagram filter, pretending that we're converting to HTML
  return pandoc.utils.run_lua_filter(doc, diagram_filter, env)
end

Use it instead of the plain diagram.lua filter.
I didn't test, but I suspect that the result will be the same as using PNG right away.


I'm not sure yet what the proper fix could look like. The most reasonable thing would probably be to make format options configurable, e.g.

diagram:
  format:
    latex:
      mime-types: ['image/png', 'image/svg+xml']

@giuli635
Copy link
Author

Hello! I'm going to try this as soon as possible, thank you for the fast response, you've been very helpful.

@giuli635
Copy link
Author

giuli635 commented Oct 3, 2024

Well, I've tried the workaround quite a bit later hahaha. But I get the following message:
[WARNING] Scripting warning at /home/giuliano/.local/opt/diagram/diagram.lua line 310 column 1: /home/giuliano/.local/opt/diagram/diagram_wrapper.lua: Cannot use plantuml with html

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

No branches or pull requests

2 participants