Command line
One SVG file in, one .drawio file out. Each note goes to standard error. The exit code is not zero when the file has nothing to show. Use it in scripts, and to convert many files at one time.
accent-draw
accent-draw <input.svg> [output.drawio]
The command is the only code in the project that uses files. The library changes
text into text. The command reads the SVG file, writes the .drawio file, and
prints the notes from the library.
$ accent-draw board.svg board.svg: miro: read as a Miro board, widget by widget wrote board.drawio
Where the output goes
If you do not give a second argument, the output goes next to the input. Its
name is the name of the input, with the extension .drawio. A file without an
extension gets one.
There is one exception. draw.io exports a file that you can edit as
diagram.drawio.svg. The diagram in that file goes to diagram.drawio, not to
diagram.drawio.drawio. Thus the command removes .svg from that name and
adds nothing.
What it prints
| Stream | What |
|---|---|
| standard output | wrote <path>, one time, when the command writes the diagram |
| standard error | one line for each note, as <input>: <code>: <message>, in the order of the document |
| standard error | error: <input>: <reason> when the command cannot convert the SVG file |
The code of each note is short and does not change, for example picture,
gradient-as-colour, miro-skipped or unaccounted. Thus a script can find a
note by its code and does not have to read English. The message is for a person.
Exit codes
| Code | When |
|---|---|
0 | The command wrote the diagram. Notes do not change this: a diagram with approximations is a diagram |
1 | The command cannot read the input, cannot convert it, or cannot write the output. For a failed conversion, it writes no file |
2 | The arguments are not correct. The command prints the usage to standard error |
The command prints each conversion error with these words:
not well-formed XML: …- the file is not XML.not an SVG: the root element is <html>- the file is XML, but it is not SVG.nothing recognised: no shape, text or connector to draw- the command read the file, and the file contains nothing that becomes a diagram. This error is intentional. An empty.drawiofile with a zero exit code tells you that the conversion was correct when it was not. This project must not do that.the SVG carries a draw.io diagram that does not read…- thecontentattribute is in the file, but accent-draw cannot read its data. The image also contains nothing to convert.
In a script
A note is not an error, and an error writes no file. Thus a simple loop is sufficient:
for svg in drawings/*.svg; do accent-draw "$svg" || echo "skipped $svg" >&2 done
To stop on a type of note, find its code in standard error. The codes do not change, so you can use them for this.
accent-draw-miro
accent-draw-miro <input.svg|folder> [output.drawio|folder]
This second command converts many Miro exports at one time. When you give it a
folder, it converts each .svg file in that folder. It writes each .drawio
file next to its board. The command uses the same Miro
profile in the same library. Thus
the conversion is the same, and the command adds only the work with folders. An
SVG file that is not a Miro board gets the same conversion as all other files.
Build it
There is no published release yet. In a copy of the repository, run this command:
cargo run --release -p accent-draw-cli -- in.svg out.drawio
The same library also compiles to WebAssembly. The browser and the command line must give the same output. For each change, a test converts the corpus with both and compares the bytes.