Giter Club home page Giter Club logo

diagram's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

diagram's Issues

Feature Request: more output options

Hi,

I'd be interested in using diagram but it's a little tricky right now.

My workflow is markdown to html (just pandoc and a makefile, not quarto), so diagram doesn't really work unless one or both of embed-resources and extract-media options are active.

But those aren't good options for me - there's plenty of other things that I link to in a given document, but nothing else that I'd want embedded or extracted.

Rather, what I'd like is to be able to configure diagram to output its images to some path and then link to that. (I got halfway there by setting the cache directory, but then tripped up on the hashes being different.)

If this is out of scope for the project because it's not a use case that makes sense for other output formats, fair enough.

does this work with "pandoc --from latex"?

Hi. I can run the diagram.lua filter on input-tikz.md from your test directory. Now I want to apply it to produce html from a latex document. I am adding --from latex, but the output contains Unknown environment 'tikzpicture'.

pandoc --from latex --to slidy \
--variable "slidy-url:...my-local-installation.../Slidy2" \
--standalone \
--mathjax="...my-local-installation.../MathJax-3.2.2/es5/tex-mml-chtml.js" \
--slide-level=2 \
--lua-filter=...my-local-installation.../diagram/diagram.lua 

with

$ pandoc --version
pandoc 3.1
Features: -server +lua
Scripting engine: Lua 5.4

Error when ther if no caption and no alt

Including simple images instead of figure where there is no caption is very useful.
But when if I provide neither caption nor alt, there is an error message :

pandoc -t latex --lua-filter ~/dev/pandoc/diagram.lua -o test.pdf  test.md 

Error running filter diagram.lua:
Inline, list of Inlines, or string expected, got nil
	while retrieving function argument caption
	while retrieving arguments for function Image
stack traceback:
	diagram.lua:481: in function <diagram.lua:413>
	[C]: in ?
	[C]: in method 'walk'
	diagram.lua:497: in function 'Pandoc'
stack traceback:
	diagram.lua:497: in function 'Pandoc'

Sample file:

  Sample graph :
  
  ```{.dot}
  digraph {
    A -> B;
    B -> C;
    C -> A;
  }
  ```

If I use {.dot alt="foo"} or {.dot caption="bar"}, everything is fine.

additional packages for tikz

It seems to me that additional packages for tikz are not taken into account.
sample.md contains :

   {.tikz caption="This is an image, created by **TikZ i.e. LaTeX**."   additionalPackages="\usepackage{adjustbox}"}

but in diagram.lua :

local pkgs = opt['additional-packages'] or ''

variable pkgs remains empty (opt['additional-packages'] is nil). The package is not added, and compilation fails
(missing \trimbox).

If I add \usepackage{adjustbox} directly in local tikz_template variable, everything works fine.

I don't understand lua enough to make a PR... :)

PLantUML regression ?

This commit 97c6362 works like a charm for my use case (generation of PDF) : TikZ, mermaid, plantUML, asymptote.

But with the last commit : 8168143 plantUML does not work anymore :

java.lang.ClassNotFoundException: org.apache.batik.apps.rasterizer.SVGConverter
	at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:61)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:289)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:138)
	at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:198)
	at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:165)
	at net.sourceforge.plantuml.Pipe.generateDiagram(Pipe.java:103)
	at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:94)
	at net.sourceforge.plantuml.Run.managePipe(Run.java:361)
	at net.sourceforge.plantuml.Run.main(Run.java:187)
Exception in thread "main" java.lang.UnsupportedOperationException
	at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:80)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:289)
	at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:138)
	at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:198)
	at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:165)
	at net.sourceforge.plantuml.Pipe.generateDiagram(Pipe.java:103)
	at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:94)
	at net.sourceforge.plantuml.Run.managePipe(Run.java:361)
	at net.sourceforge.plantuml.Run.main(Run.java:187)
Lua warning: /home/signac/dev/pandoc/diagram.lua: Error running plantuml (error code 1): <no output>

The sample file used contains :

    Example usage:
    ```{.plantuml caption="This is an image, created by **PlantUML**." width=50%}
    @startuml
    Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response
    Alice -> Bob: Another authentication Request Alice <-- Bob: another Response
    @enduml
    ```

Usage with Quarto and plantuml diagram

I found this information in the readme

While it is possible to use this filter with Quarto, it is not encouraged. Quarto comes its own system for diagram generation, and that should be used instead.

I looked at the documentation, Quarto comes with native support of Mermaid and Graphviz. This affirmation is then true for those types of diagrams. But I did not see a way to extend the native support with other format like plantuml.

This extension could be a good fit to integrate plantuml support to Quarto ?

Sorry to ping you @cderv, may be you can help to answer my question ?

Thanks a lot for you help!

Problem integration with Quarto

I tested diagram.lua with the following qmd file:

---
filters:
  - diagram.lua
diagram:
  cache: true
  cache-dir: .cache/plantuml
---

# Welcome for fun

```{.plantuml}
'| label: fig-auth
@startuml
Alice -> Bob: Authentication Request Bob  super --> Alice: Authentication Response
Alice -> Bob: Another authentication Request Alice <-- Bob: another Response
@enduml
```

When I use the following command: quarto render docs/index.qmd --to docx, I get the following error:

pandoc 
  to: docx
  output-file: index.docx
  default-image-extension: png
  
metadata
  diagram:
    cache: true
    cache-dir: .cache/plantuml
  
Error running filter /opt/quarto/share/filters/main.lua:
diagram.lua:11: attempt to call a nil value (global 'warn')
stack traceback:
        /opt/quarto/share/filters/main.lua:4073: in local 'callback'
        [string "..."]:1789: in function <[string "..."]:1787>
        (...tail calls...)
        /opt/quarto/share/filters/main.lua:368: in function 'make_wrapped_user_filters'
        /opt/quarto/share/filters/main.lua:15395: in main chunk

A workaround is to comment the following line

It happens with other output format too.

Quarto version used and pandoc version embedded by quarto.
Tests was performed on WSL.

> quarto check
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.340
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

Thanks for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.