Command line
One SVG in, one .drawio out, with every note on standard error and a non-zero exit when there was nothing to draw. Made for scripts and for converting a corpus in bulk.
accent-draw
accent-draw <input.svg> [output.drawio]
The command is the only code in the project that touches files. The library
converts text to text; this reads the SVG, writes the .drawio, and reports
what the library says.
$ accent-draw board.svg board.svg: miro: read as a Miro board, widget by widget wrote board.drawio
Where the output goes
With no second argument, beside the input with its extension replaced by
.drawio. A file with no extension gains one.
One exception: draw.io's own editable export is named diagram.drawio.svg, and
the diagram inside it belongs in diagram.drawio, not
diagram.drawio.drawio - so that name loses the .svg rather than gaining
anything.
What it prints
| Stream | What |
|---|---|
| standard output | wrote <path>, once, on success |
| standard error | one line per note, as <input>: <code>: <message>, in document order |
| standard error | error: <input>: <reason> when the SVG could not be converted |
Each note's code is short and stable - picture, gradient-as-colour,
miro-skipped, unaccounted - so a script can match on it without reading
English. The message is for a person.
Exit codes
| Code | When |
|---|---|
0 | The diagram was written. Notes do not change this: an approximated diagram is still a diagram |
1 | The input could not be read, could not be converted, or the output could not be written. No file is written for a failed conversion |
2 | The arguments were wrong. The usage is printed to standard error |
The conversion failures are worth naming, because each one is a sentence the command prints verbatim:
not well-formed XML: …- the file is not XML at all;not an SVG: the root element is <html>- it is XML, but not this;nothing recognised: no shape, text or connector to draw- it was read, and held nothing that becomes a diagram. This is an error on purpose. An empty.drawiothat exits successfully is the failure mode this project was started to avoid;the SVG carries a draw.io diagram that does not read…- thecontentattribute is there but corrupt, and the picture held nothing to fall back to.
In a script
Because a note is not a failure and a failure writes no file, the useful shape is the plain one:
for svg in drawings/*.svg; do accent-draw "$svg" || echo "skipped $svg" >&2 done
To fail on a particular kind of note rather than on an error, match the code on standard error - they are stable for exactly that.
accent-draw-miro
accent-draw-miro <input.svg|folder> [output.drawio|folder]
A second command, for converting Miro exports in bulk: given a folder, it
converts every .svg directly inside it and writes each .drawio beside its
board. The reading itself is no different - it is the same Miro
profile in the same library - so
this exists for the folder handling, not for the conversion. An SVG that is no
Miro board is converted as any other picture.
Building it
There is no published release yet. From a checkout:
cargo run --release -p accent-draw-cli -- in.svg out.drawio
The same library also compiles to WebAssembly, and the browser and the command line are held to producing identical output: the corpus is converted through both on every change and compared byte for byte.