OmniGraffle SVG to Angular-HTML Workflow
Join the DZone community and get the full member experience.Join For Free
omnigraffle (possibly the best app on the mac) makes reasonable svg. i hope it gets better and better with each release, though. if i wanted to take its output and turn it into an interactive applications (like the previous two previous article ) with angular, i have a new problem – omnigraffle won’t round-trip preserve my inlined angular application code. you might want to increment the ‘root’ svg source, and preserve the angular bits and pieces you’ve typed into it. luckily, there’s an imperfect source-control solution that involved two branches, and merge. that’s what i’ll outline in this article.
refer my github repo to demonstrate this: https://github.com/paul-hammant/svg_merge_experiment
in omnigraffle, i exported a crude pacman image as svg, and put that into a branch
as the branch name suggests i pretty printed it (which i think
omnigraffle should do by default). i used xmllint to beutify it, and
gave it a new suffix that’s inaccurate, but helps git do a merge later.
the xmllint command:
xmllint --pretty 2 --noblanks -o pacman_pretty.html /from/wherever/you/saved/the/omnigraffle/svg/output.svg
it makes a strange format. one that, arguably makes diff and merge easier. xml is, by default, a very hard case for merge. here’s diff as github sees it
here’s what that looks like before the .html rename (svg – sorry ie 6,7,8 users):
then i made a second branch
, and morphed to the file (by hand) to include:
1. html/head/body tags as outermost.
2. angular import and a tiny model var of “blue”
3. usage of that model in a color ‘fill’ attribute.
i then ran xmllint over it again. this time, there’s a shortcoming in xmllint that required remediation – it wants to write
<script src="xxx" />
, when browsers will only accept
<script src="xxx" ></script>
. i raised a feature request, but had to manually fix it after running xmllint.
now it looks like:
now, back on the first branch,
i’ve imported from omnigraffle again (the source files for which i
should, but don’t, have under source-control). i changed the circle to a
star (still red). the
. it looks like:
i pretty printed it again, with the xmllint tool, before checking it in.
next merged that to the other branch (
), with the following command to hint git to be forgiving about whitespace changes. here’s
. the merge command:
git merge -xignore-all-space as_from_omnigraffle_but_formatted
in case you couldn’t guess, that’s now a blue star courtesy of angular:
all wasn’t so smooth. i really wanted the merge to be automatic, but i had to arbitrate over the following diff before committing it:
automatic would have been preserving the original change highlighted in red, and changing
<circle ... />
<path ... />
merge science gets better and better every year though so one day, it’ll automatically do what wanted before i started this article. hopefully.
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.