Closed oddhack closed 4 years ago
I added an initial experimental version indeed. It’s not something I use myself and I didn’t get much feedback from the person who requested it, so I’m reluctant to consider this 100% done.
You’re correct that this is a small wrapper around LaTeX. I’m not aware of any other system we could use to interpret and render the tikz code.
Thanks. Some feedback: if I just say [tikz] for the image block in asciidoctor markup, it does process the block content and generate a PDF, but then it tries to incorporate the PDF in HTML5 output using an \ directive, which does not work. It's necc. to add something like [tikz,"image1",svg] and then it invokes pdf2svg and the output includes the SVG. I will probably have a few more comments as I work with the existing images - would you want those here, or in separate issues?
I have all of my TikZ images working through asciidoctor-diagram now. No issues to report aside from the one just above, which is minor. Feel free to close this if you don't think that issue calls for any action (ISTM is more of a documentation issue than anything else). Thanks!
For the TikZ processor PDF is indeed the default format and that's indeed not well documented (in general for all block types). You can switch that globally by setting the tikz-format
document attribute to svg
.
@pepijnve Thanks for all of your work on getting tikz
images to work in asciidoctor-diagram
. I was wondering if there is a complete example of this anywhere? The original request referenced the link https://github.com/asciidoctor/asciidoctor-diagram/blob/master/spec/tikz_spec.rb , but that seems like the ruby code. If it is not too much trouble, could you pass along say a link to the .adoc
document you used for testing or something.
I was hoping to get tikz
documents working for PDF export as well as HTML5 export to put into a Hugo blog. I was trying it out, but am getting messages like unknown environment tikzpicture
.
I was trying to embed a block like.
[tikz,"image1",svg]
++++
\usepackage{tikz}
\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\filldraw [gray] (0,0) circle (2pt);
\draw (-2,-2) .. controls (0,0) .. (2,-2);
\draw (-2,2) .. controls (-1,0) and (1,0) .. (2,2);
\end{tikzpicture}
++++
@00krishna in your little example you're using a passthrough block. The diagram plugin is not going to kick in on those, it only registers itself for literal and open blocks.
Something like this should work though provided you have pdflatex and pdf2svg installed.
[tikz,"image1",svg]
----
\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\filldraw [gray] (0,0) circle (2pt);
\draw (-2,-2) .. controls (0,0) .. (2,-2);
\draw (-2,2) .. controls (-1,0) and (1,0) .. (2,2);
\end{tikzpicture}
----
Ahh yes, so I had the wrong type of block. Thanks so much for pointing that out, I probably would not have realized that this was the source of the error unless you told me. Thanks again.
189 suggests this has been done, but it is not mentioned as a supported format on https://asciidoctor.org/docs/asciidoctor-diagram/ or in the repo README. Could you clarify where this stands?
Also, do I understand correctly from #189 that the integration is accomplished simply by running the diagram source through LaTeX and then converting to SVG?