All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
Fixed: don't attempt to derive bounding box for elements (including root
<svg>
) where size / position attributes have units or %age values - e.g.x="5%" width="10cm"
etc. Previously this prevented processing many SVG examples using units or percentages. -
svgdx-editor: Added 'Copy PNG' button which copies high-resolution PNG to clipboard.
-
Fixed (regression in 0.9.0): overriding compound attribute derived positions caused position deltas (dx/dy/dw/dh) to stop working correctly in some cases.
-
Change (minor):
text-dx
/text-dy
/text-dxy
are now applied after any text insetting, rather than instead of insetting. This meanstext-dxy="0"
is now a no-op. -
Added: Support a
text-inset
attribute for varying the inset value (i.e. how much non-centered text is 'pulled in' from a corner or edge). Previously this was hard-coded to 1.
-
Added: support for vertical text; add the
d-text-vertical
class to an element to cause text to be rendered vertically. The same integration with basic shapes and use of thetext-loc
attribute if available for vertical text. -
Added: improve loop ergonomics with support for
loop-var
,start
andstep
attributes oncount
loops. By default the variable assigned byloop-var
will take the values0
..count-1
, incrementing each iteration.start
andstep
allow overriding the initial value and increment. Previously using a loop counter as a variable value required a combination of two<var>
elements (for initialisation and increment) and awhile
loop. -
Fixed: attributes derived from compound attribute expansion are lower priority than equivalent target attributes, i.e. an
xy
attribute should not overwrite an existingy
attribute. -
Fixed: various error handling improvements
-
Added: support for
<loop>
element, withcount
,while
anduntil
attributes defining multiple iterations of the contained elements. See the loop element docs for more information. -
Added: element
id
attributes are now evaluated as with other attributes, allowing id value to include variable values; useful to keepid
unique inside loop bodies. -
Added: Check for circular references in expressions to avoid stack overflow.
-
Fixed: positioning relative to a connector (
<line>
withstart
/end
attributes). -
Fixed:
dx
/dy
attributes were being incorrectly stripped fromfeOffset
elements. -
svgdx-editor enhancements: Increased number of tabs from 5 to 10; added 'text output' view with toggle button; minor styling improvements.
-
Changed: various auto-styles relating to text, including the ability to specify text colour, size, style, and a change to prevent
d-softshadow
/d-hardshadow
being applied to rendered text. A newd-thick
style has been added as a complement tod-thin
. See auto_styles.md for more information. -
Changed: attribute-based variable lookup now starts at the parent (rather than the current) element. Note that when
reuse
is in effect, the sourcereuse
element itself is considered the immediate parent of target element. -
Added:
<reuse>
element now supports<g>
targets allowing more complex shapes to be reused. Note that (currently) there are still limitations around positioning;<g>
doesn't yet have it's own bounding box, and elements within a reused group element do not support the multiple passes required for forward references. -
minor svgdx-editor enhancements including timestamp in download filenames
- svgdx-editor enhancements, including both horizontal and vertical editor layouts, copy as data URI, highlight source lines on element hover, and various bug fixes.
-
Changed: Split out features for
cli
andserver
(support for the newsvgdx-server
). Both these are default features, but if only the library is needed a no-default-features build will be smaller / faster to compile. -
Added: 'svgdx-server' - a simple web-based frontend for editing and viewing svgdx documents. Run with
cargo run --bin svgdx-server
. I'm not sure what direction this will go in - for me it's a workflow improvement over the--watch
+ Gapplin (or similar) I'd been using previously. -
Added: Support
wh
andxy
attributes for<use>
,<image>
,<svg>
and<foreignObject>
elements. -
Changed / Added:
text-pre
attribute which if present (with any value) converts spaces in text to non-breaking spaces, to defeat the XML whitespace processing and allow space-preserving text to be displayed. Previously leading spaces were converted in this way, but not internal space.
-
Changed: relspec positioning modified to be more consistent: the referenced element must now be given explicitly as
^
or#id
, rather than the previous implicit 'previous element' default. Direction-based relative positioning ('dirspec') now always requires a ':' separator. See layout.md for details of the new relspec definition. -
Changed:
margin
now takes up to 4 entries, analogous with CSS margin and padding values. Previously it took either one or two entries, and with two entries the first was an 'x' margin and the second a 'y' margin. Now the CSS approach is used with support for separate TRBL margins. -
Added:
inside
attribute, analogous tosurround
but as the intersection of bounding boxes rather than their union. -
Added: support for providing text content for graphical elements using XML text or CData in addition to the
text
attribute. This makes pre-formatted text much easier to include. -
Changed: leading whitespace in text content of elements is now replaced with non-breaking spaces, to allow arbitrary indenting.
-
Added: Relational and logical functions. Function notation (e.g.
lt(a,b)
rather thana < b
) is chosen to avoid the need to use XML entities ('<
' etc). It also avoids the need for more levels of precedence, though that's not a good reason on its own. Note logical values adhere to C-language values; non-zero evaluates to true, and true/false will be indicated by the numeric values 1.0 & 0.0 respectively.
-
Changed: Removed the custom elements
<tbox>
,<person>
and<pipeline>
, since these are now better implemented with<specs>
and<reuse>
. Theperson
andpipeline
examples have been updated to use the new<reuse>
templating approach. -
Added: Support for
<specs>
and<reuse>
custom elements to allow templating of elements in the rendered document. -
Changed: Variable lookups now first reference attributes of the input element (provided this is not a
<vars>
element) before checking the global namespace. This is particularly useful in conjunction with the<reuse>
element to provide 'custom element'-like behaviour. -
Added: a bunch of builtin functions for expressions, including basics such as min, max, and abs, trigonometric functions, and random number generation. See the function documentation for a full list.
-
Added: a
--seed
command-line argument (and<config seed="...">
setting) to initialise the random number generation for therandom()
andrandint()
functions.
-
Added: initial support for
<path>
bounding boxes. Note this currently ignores any curves (cubic, quadratic, arcs) and considers only visited endpoints of these shapes. -
Changed approach to indentation so this now works consistently with elements processed out-of-order (e.g. geometry defined in terms of elements occurring later in the document)
-
Added a
<config>
element which can define config options within an input document. See the element docs for more info. This allows the examples/refresh.sh script to be run cleanly over all the examples.
-
Improved error handling, with fewer panics caused by invalid input.
-
Added a check that the output won't override the input file (after being bitten by exactly this...)
-
Updated examples to use
.xml
/.svg
for input and output filenames respectively, rather than-in.svg
/-out.svg
. While the auto-completion for input files which.svg
might provide in some editors is useful, the extension lies about it being a valid SVG file which can be confusing, e.g. when viewing input source for examples in GitHub. -
Update shlex to address RUSTSEC-2024-0006 (no relevant parts of the affected API are used in svgdx.)
-
Changed: auto-styles are no-longer suppressed when user-defined styles / defs are present. Note this may require changing user-styles to increase priority over auto-styles.
-
Added: Additional values for scalar specs, including
cx
,cy
,rx
,ry
. Existing scalar values can now be referenced by alternate names, e.g.width
in addition tow
ory
in addition tot
. The intent here is that SVG attribute names (e.g.y
orheight
for a rectangle) are used as scalar names. -
Added: support for out-of-order references in
surround
and other contexts.Since
surround
is intended to support 'background' fills around shapes, it needs to be painted before the shapes in contains - and therefore reference elements occurring later in the document (which may in turn reference other elements later in the document to establish placement).A more general approach to these 'recursive' references is implemented, though it may be slow in the general case with large documents. The previous
populate()
stage followed by 'simple' / 'not-simple' calls toexpand_attributes()
have been replaced by repeated 'process remaining elements which couldn't be handled' stages until success (no further elements) or stall (couldn't reduce the number of remaining elements).NOTE: one (temporary) limitation of the approach here is the generated indentation/newline placement is less consistent, as output elements are no longer processed in document order.
-
Internal: Made fields of
TransformerContext
private with appropriate access methods, e.g.elem_map.get()
->get_element()
. Evaluation functions now take a&TransformerContext
where previously they took&HashMap
s etc corresponding to the internal types. -
Internal:
pop_idx
/insert_idx
functions onSvgElement
, to allow an attribute to be removed and replaced 'in sequence' with multiple other attributes without having to iterate through all existing attributes and rebuild a newAttrList
. NOTE: This isn't a nice API and may change. -
Internal: switch to using
lazy_regex
for performance.
- Fixed: expressions including a variable as e.g. "20 24" would become "2024" with whitespace collapsed. When used in numeric contexts this would create problems. It now remains as the text value "20 24" as intended.
- Fixed: panic resolving element size with
dwh
(etc) whenwh
referred to a variable or other expression.
- Changed: more consistent public API;
get_config()
andrun()
are still top-level functions, but the varioustransform_*
functions allow a range of input/output options for processing documents. - Changed: split
svgdx::TransformConfig
out ofsvgdx::Config
to handle per-transform settings, leaving top-levelConfig
for 'front-end' options from thesvgdx
command-line program. - Changed: default styles now use
fill: white
for shapes to improve appearance of overlapping shapes. Shapes usingsurround
still have no fill via ad-surround
class. - Added: additional command-line options to tweak transformation:
--debug
to include more debugging info in the generated document--scale
to allow scales other than 1 user-unit == 1mm--border
to specify width of border around entire image--no-auto-style
to prevent svgdx automatically adding style/defs entries--background
to specify background colour (default none)
- Fixed: Blank lines in multi-line text are now rendered correctly.
- Fixed: Move
dwh
handling to ensure it works withcxy
.
- Added: Initial support for
<path>
elements, though currently very limited. - Changed: single value refspec is now #abc.x to avoid #abc.h (height of #abc) conflicting with #abc:h (position horizontally on the right of #abc). Mnemonic: '.' has a single dot and returns a single numeric value...
- Add support for locspecs in
points
attribute for polyline and polygon. - Add
dx
/dy
/dxy
support forpoints
values, translating each point in turn. - Added
d-thin
andd-biarrow
auto-style classes. - Add support for dirspec (h/H/v/V) relative positioning from a referenced element,
e.g.
xy="#abc:h"
- Add various auto-style classes:
d-{colour}
&d-fill-{colour}
for various colours,d-dot
/d-dash
for stroke styling,d-arrow
for arrowhead marker, etc. - Added
surround
attribute for rect / circle / ellipse which takes a list of element references and creates a shape surrounding them; amargin
attribute can provide x & y margins expanding the surrounding shape from the minimal bounding box enclosed.
- Initial public release. Happy Christmas!