Last active
December 29, 2017 13:56
-
-
Save wknapik/d4c3c662cbc79d2739725b34e088f545 to your computer and use it in GitHub Desktop.
draw.io xml to html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# USAGE: drawioxml2html.sh diagram.xml >diagram.html | |
# html encoding from https://stackoverflow.com/questions/12873682/#answer-12873723 | |
diag="$(sed 's,.*<\(diagram [^>]*\)>\(.*\)<\(/diagram\)>.*,\1FOO\2BAR\3,g' <"$1"|\ | |
sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g'|\ | |
sed 's/&/\\&/g; s/FOO/\>/; s/BAR/\</')" | |
cat <<EOF | |
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>diagram</title> | |
<meta charset="utf-8"/> | |
</head> | |
<body><div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{"highlight":"#0000ff","nav":true,"resize":true,"toolbar":"zoom layers lightbox","edit":"_blank","xml":"<mxfile userAgent=\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36\" version=\"7.3.5\" editor=\"www.draw.io\" type=\"device\"><$diag></mxfile>"}"></div> | |
<script type="text/javascript" src="https://www.draw.io/embed2.js?s=aws3;mscae/enterprise;gcp/networking;citrix&"></script> | |
</body> | |
</html> | |
EOF |
Hi @Zaijo. This was just a quick hack to get me going. I didn't even realize you could have multiple tabs, I've only ever used one.
If you need this now, you could diff what the regular export produces with what my script produces and it would probably be clear how to improve it. Otherwise, I'd suggest getting your team to give the issue a thumbs up and hope the draw.io team gets around to implementing the feature.
Sorry I wasn't more helpful, but the draw.io-related stuff has fallen so low on my list of priorities by now, I can't afford to devote time to it.
Hey @Zaijo. As @josefstr mentioned in the github issue, there's apparently a proper converter now - drawio-batch.
Is it possible to generate pdf or any other format?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, but this only works for one diagram. Is there a way to export all tabs?