Crates.io | svgdx-pandoc |
lib.rs | svgdx-pandoc |
version | |
source | src |
created_at | 2024-12-15 16:38:13.647544 |
updated_at | 2025-02-02 21:06:48.628763 |
description | pandoc filter for svgdx codeblocks in Markdown |
homepage | |
repository | https://github.com/codedstructure/svgdx-pandoc |
max_upload_size | |
id | 1484278 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A pandoc filter to convert svgdx fenced code blocks into inline images.
For now installation requires a working Rust toolchain, e.g. installed from rustup.rs.
Install svgdx-pandoc
as follows:
cargo install svgdx-pandoc
Basic usage of the filter is as follows; note the output format is inferred from the output file extension.
pandoc --filter svgdx-pandoc input.md -o output.html
An example Markdown file with embedded svgdx
diagrams is present in the example/ directory.
To create various other documents from this, try the following after cloning this repository. Note this assumes both pandoc and this project are installed.
svgdx-pandoc$ cd example/
svgdx-pandoc/example$ ./refresh.sh
Try opening the various generated files; note that some output formats tend to work more reliably than others,
This filter has three modes of operation, selected automatically based on the target document format (which pandoc provides as the sole argument to a filter):
html
and epub
output, the rendered SVG is included inline within the rendered document;
for example a generated HTML document will contain an SVG element at the appropriate location.PDF
, odt
, raw inline SVG elements are not supported, so temporary
image files are created with associated image links.docx
and pptx
, support for SVG images isn't great, so images are converted to PNG files
using ImageMagick
or Inkscape
if present.Since the svgdx-pandoc
filter will exit prior to the final output being rendered,
it cannot clean up after itself, and any temporary files created in order to create
e.g. a PDF file will remain, typically in the directory given by the TMPDIR
environment
variable or other system-specific location.
If necessary, the location of temporary rendered SVG images can be controlled by defining
the SVGDX_PANDOC_TMPDIR
environment variable, which should point to a directory which
already exists.
To test changes to svgdx-pandoc
, run as follows:
cargo build && pandoc --filter target/debug/svgdx-pandoc [input] -o [output]
In order to test changes to the svgdx
library itself, update the appropriate dependencies
entry of Cargo.toml of this (svgdx-pandoc) repo to point to a local clone of svgdx
,
rather than providing a version specifier:
svgdx = { path = "/path/to/svgdx", default-features = false }
svgdx-pandoc is released under the MIT license; for more information see the LICENSE file.