drawio-textconv [FLAGS] [FILE | -]
This tool extracts diagram source code from .drawio
files
(compressed and uncompressed) and from .drawio.svg
files (where
the diagram source is embedded).
Usually, you don’t run this tool directly but use it in combination
with Git’s textconv
facility. This gives you meaningful diff
output, especially if you regularly check draw.io diagrams into Git
with sources embedded.
See gitattributes(5) for details on the textconv
feature.
The following flags are supported:
Extract the mxfile
source from a compressed .drawio
XML file.
Extract the mxfile
source from an uncompressed .drawio
XML file.
Extract the mxfile
source from a .drawio.svg
file.
To integrate drawio-textconv with Git on your system, open a terminal and run the following command lines:
git config --global \
diff.drawio-compressed.textconv \
'drawio-textconv --compressed'
git config --global \
diff.drawio-uncompressed.textconv \
'drawio-textconv --uncompressed'
git config --global \
diff.drawio-svg.textconv \
'drawio-textconv --svg'
git config --global \
diff.drawio-compressed.cachetextconv false
git config --global \
diff.drawio-uncompressed.cachetextconv false
git config --global \
diff.drawio-svg.cachetextconv false
To enable drawio-textconv for all .drawio.svg
files in your Git
repository, add the following line to your .gitattributes
file:
*.drawio.svg text diff=drawio-svg
Confirm that it works:
$ git cat-file --textconv HEAD:path/to/my.drawio.svg
<?xml version="1.0"?>
<mxGraphModel grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fo
ld="1" page="1" pageScale="1" pageWidth="413" pageHeight="291" math="0" shadow="0">
<root>
[…]
</root>
</mxGraphModel>
Note: You can check your .gitattributes
file into Git to share
this setting with other project members.
If your Git repository has pure .drawio
files instead of
.drawio.svg
, you may want to check if your files are compressed.
If the files are uncompressed, then add the following line to your
.gitattributes
file:
*.drawio text diff=drawio-uncompressed
If the files are compressed, then add the following line to your
.gitattributes
file:
*.drawio text diff=drawio-compressed
gitattributes(5)