svg2md2draw


svg2md2draw


SVG2MD2DRAW turns a box-and-arrow diagram in SVG into a group of md2slides: a .md2draw file that any deck can use with > use. The diagram can come from draw.io, Inkscape or md2slides' own "Export SVG". Once it is a group, d's editor can do with it what it does with any drawing: move and resize the boxes, join them with arrows, change their text, align and stack them.

rexx svg2md2draw flow.svg           -- writes flow.md2draw, group #flow

and in the deck:

> drawing ratio=2 width=47%
> use flow.md2draw at=0,0,100,100
> end drawing

An SVG that is not a diagram of boxes and arrows (a logo, a chart, a picture) does not need this: it goes on a slide as it is (> pic logo.svg), or through svg2jdor.

Usage

[rexx] svg2md2draw [options] drawing.svg [group.md2draw | -]

The file goes beside the SVG, with the extension .md2draw, unless another file is given; - writes it to the standard output. svg2md2draw then lists what it left out (see What Is Left Out).

When called without arguments, svg2md2draw displays help information and exits.

Options


-h, --help Display help and exit
-q, --quiet Do not list what was left out
--name NAME The group's name (by default, the file's)
--skin No colours: the deck's skin gives them


What It Writes

In the SVG In the group
a rectangle, also with rounded corners, also drawn as a path a box: > box
an ellipse or a circle a round box: > box round
a text inside a rectangle or an ellipse the text of that box (its lines, as in the SVG)
any other text a text block of its own: > box bare
a line, a polyline or a path that is not closed an arrow: > arrow #a -> #b
a text on a line, about its middle the arrow's label=
  • Each block goes where it is, in per cent of the picture (> at=10,13.3,23.3,20), and gets the element's id as its name when it can be one, or b1, b2... (boxes) and t1, t2... (texts).
  • An arrow joins the blocks its ends are on, or near (an arrow stops a little short of what it points at). md2slides chooses where it leaves and lands, as for any arrow between two blocks. An end that is on no block is a place of the group (#flow:10,95). A copy of the group (> use) has its own places.
  • An arrow's heads come from its markers, or from a small closed shape at one of its ends, as draw.io draws them. A line with neither has no head (--). A line with one bend, across and then up or down, is an elbow (route=elbow).
  • Colours, stroke widths and dashes go in each block's style=, and in the arrows' color=, width= and line=dashed. With --skin there are no colours, and the deck's skin decides.
  • Text keeps its lines, bold and italics. What would be Markdown is escaped (\*, \#...), so the text says only what it said. Its size is in em, for the drawing at the width the file's header says.

The header of the file says how to use it:

<!-- svg2md2draw: flow.svg (600 x 300px).
     Its text is sized for a drawing 47% wide (of the slide's contents), as in
       > drawing ratio=2 width=47%
       > use flow.md2draw#flow at=0,0,100,100
       > end drawing
     -->

The width keeps the text as big as it was in the SVG next to its boxes. A picture wider than the 1280px stage is shown at the stage's width, and its text is made smaller to match.

What Is Left Out

A drawing of md2slides holds upright boxes, text and straight arrows. The rest is left out, and listed when svg2md2draw ends:

  • polygons and closed curves, other than rectangles (only rectangles, ellipses and circles make boxes);
  • turned or slanted boxes and texts;
  • curves and bends of a line: it is drawn straight, from end to end (one elbow is kept);
  • gradients: drawn with their first colour;
  • what svg2jdor leaves out too: masks, filters, patterns, pictures, textPath, foreignObject, animation.

How It Reads SVG

With svg2jdor's reader, the same one: the presentation attributes, the style attribute and the simple rules of a <style> sheet, the transforms, the viewBox, use and nested svg elements, and text with its tspans.