Skip to content

Releases: edemaine/svgtiler

v3.1.0

31 Dec 19:02
Compare
Choose a tag to compare
  • Render gains forEach helper that iterates over all cells with a Context
  • Render gains context helper to make new Context instances at arbitrary locations
  • Context gains startsWith/endsWith shortcut helpers (to query the key even when it might be undefined)
  • Empty fragments returned from mapping now treated like empty symbols (just like empty-string SVG content); previously crashed (#104)
  • Empty content returned from mapping always treated as having width/height 0 instead of warning
  • Not-first symbols in an array stack no longer warn about missing width/height (#105)
  • Documentation improvements:
    • Render class
    • key is undefined, not null, when out of bounds
    • How to upgrade with NPM

Full Changelog: v3.0.0...v3.1.0

v3.0.0

25 Dec 13:54
Compare
Choose a tag to compare
  • Major rewrite to improve usage and add a ton of features, including Maketiles, stacked symbols in a single tile, automatically dynamic map functions, arbitrary pre/postprocessing, global underlays/overlays, <def>s support, better SVG cropping, improved performance, and smaller SVG outputs.
  • New "Maketile" feature for setting default svgtiler command-line arguments (replacing the need for Makefiles and make). (#84, #99)
    • Maketile.args can specify default command-line arguments, as if they were in a shell. In particular, you can use glob patterns like **/*.asc, quotes and backslash escapes, and comments via #. Unlike shells, you can freely use multiple lines.
    • Maketile.js or Maketile.coffee can export make (or export default) with a function that runs svgtiler with computed arguments.
      • svgtiler(...args) is like running svgtiler on the command line with the specified arguments. String arguments are parsed as in .args, while Array arguments are treated as is without further processing. You can also pass in already loaded Drawing, Mapping, or Style objects.
      • You can write multiple make rules (chosen on the command line) by wrapping functions in an object or Map (similar to mapping files), or write a generic function that takes the rule name as an argument.
      • You can loop over files matching a glob pattern via svgtiler.glob, and check for additional glob pattern matches via svgtiler.match.
    • If you specify an actual file (mapping and/or drawing), default Maketiles get ignored.
    • You can still specify additional arguments to add to what's run by the Maketile, e.g. svgtiler -v.
    • You can specify a differently named Maketile via --maketile.
  • Other command-line changes: (#84, #99)
    • Specifying a directory name on the command line recurses into that directory, running the Maketile within.
    • -O lets you override the generated output filename stem (sans extension), including specifying patterns like prefix_*_suffix (#84)
    • -s key=value sets share.key to the string "value", as shorthand for creating a mapping file that sets share.
    • ( ... ) contains mapping files, -s share settings, and other command-line options to within the parentheses.
    • --bg color for specifying background color. (#57)
    • --use-data adds data-{key,i,j,k} attributes to <use> tags. (#48)
    • --use-href uses href attributes instead of xlink:href
    • --clean for deleting files that would be generated.
    • Support multiple single-dash arguments like -pP as shorthand for -p -P.
    • -v/--verbose option to help debug e.g. Babel processing.
  • Generalized mappings (#13)
    • All function mappings are now automatically dynamic; no need to wrap in a second layer of function.
    • For efficiency, you can force a function (or any mapping) to be treated as static (dependent only on key, not e.g. neighbors) via svgtiler.static wrapper.
    • Function mappings get context as a second argument (after key) in addition to this, which is helpful for passing context around or when using => arrow functions (which can't receive this). Current context can also be found via getContext().
    • Mapping can defined by Map or WeakMap as alternative to raw object.
    • Sequential composition mapping via new Mappings map1, map2 applies both maps and takes the first match, as if two maps were specified on the command line. (#89)
    • Can nest functions, objects, Maps, Mappings, or Arrays (see below) arbitrarily deep.
  • Tiles can stack multiple <symbol>s on top of each other, by returning an array of SVG content from a mapping function (#33). The first non-null symbol defines defines the tile size.
    • Each <symbol> can have its own z-index, for proper component stacking.
    • Deduplication of the individual <symbol>s makes for smaller SVG output.
    • Parallel composition mapping via [map1, map2] applies both maps and stacks one on top of the other (depending on z-index). (#83)
  • <symbol>s in mappings no longer need viewBox; you can simply specify width and height and the viewBox will default to 0 0 width height. You can also specify both and it behaves as in SVG. (#44)
  • boundingBox is the new name for the overflowBox attribute (though the old name is still supported). The box can now be smaller than the layout box (specified via width/height or viewBox), which trims the overall bounding box when possible (#86). Technically this is a BREAKING CHANGE if your overflowBox is smaller than the layout box, but this is what it ought to happen then.
  • .js/.coffee mapping files can now have many new exports:
    • init is useful for applying side effects to the shared object; it runs once per "load" of the mapping file, with mapping files always initing in command-line order (but sometimes more than once to restore an old state).
    • preprocess lets you scan and/or modify the tile keys in a drawing (#79)
    • postprocess lets you draw global content after tiles have been rendered (#81)
    • The mapping object can be exported as map, as a more descriptive name than default.
    • For the final expression to be implicitly exported as the default, it must be an object expression (literal) or function expression; in particular, it cannot be an assignment or function call. Potentially BREAKING CHANGE, but fixes the behavior in many other files.
  • You can specify a background fill (drawn via a big backing rectangle) via the --bg command-line option, or via svgtiler.background(color). (#57) This is a helpful special case of postprocessing.
  • Tiles causing errors in your .js/.coffee code now render as a warning symbol, and will no longer prevent the rest of the drawing from rendering. This makes it easier to see where your mapping code is crashing, and helps you write mappings incrementally. (#49)
  • Drawing file behavior tweaks (BREAKING CHANGES)
    • Lines in ASCII art and CSV/TSV/SSV files are automatically normalized to have the same length, by appending blank strings ('') to short lines (same as XLSX files were). You can get the old behavior via --uneven. (#85)
    • A blank sheet name in a spreadsheet file no longer has _ in the generated filename.
    • If a spreadsheet file has only one sheet and it has a nonblank name, it will be in the generated filename.
  • Examples
    • New grid-graph example, including <marker> demonstration
    • Chess examples with attack graph via postprocess
    • Tilt example modernized to use Preact
    • Improve mario example to use tile arrays to reduce duplication and demonstrate background feature.
    • Modernize to new generalized mappings, e.g. avoiding excess function wrappers and using svgtiler.static
  • API changes:
    • renderDOM (and other render methods) now take mappings and styles as part of general settings object, instead of as separate arguments. These mappings and styles are now automatically cast into Mapping and Style objects if needed. But mappings can no longer be a map object; it needs to be of the form {map: ...} (or {default: ...}), just like what would be import *ed from a mapping file. BREAKING CHANGES
    • svgtiler.def lets you build markers, gradients, clip masks, etc. with automatically generated IDs, with automatic deduplication and removal of unused defs, and makes it easy to reference them. (#38)
    • svgtiler.id lets you build unique IDs, e.g. to re-use a graphical object (#38). (svgtiler.def also uses this internally.)
    • svgtiler.add(svg) to add SVG content to the current rendering, e.g., in a preprocess or postprocess function. This also enables adding metadata like <title> (#94).
    • svgtiler.require(filename) loads a file (including drawings like ASCII art or spreadsheets, mappings, etc.) as if it were on the command line, producing a Mapping, Drawing, Drawings, Style, Args, or SVGFile object.
    • svgtiler.needVersion for specifying version constraints on SVG Tiler, e.g. svgtiler.needVersion('3.x') in your Maketile.coffee. (#99)
    • svgtiler.getContext() to find the current Context for a tile rendering, so you don't need to pass it through to auxiliary functions. svgtiler.runWithContext() allows you to override the result of svgtiler.getContext().
    • Context has new at method for absolute indexing (#78) and set method for modifying keys (#69)
    • Context no longer has symbols or symbol attributes (as cells are now rendered one at a time, instead of all ahead of time).
    • Context object now shared throughout each drawing, so you could store extra drawing-specific data there.
    • Context has render attribute pointing to current Render instance, in addition to drawing attribute pointer to current Drawing instance.
    • Drawing keys are now allowed to be objects other than Strings, e.g., via preprocessing or when creating manually via new Drawing.
    • Drawing has new at, get, and set methods.
    • Drawing's main attribute renamed from data to keys, and Mapping's main attribute renamed from data to map. (#88)
    • Drawing has new margins and unevenLengths attributes for understanding what happened during margin trimming and uneven length fixing.
    • Mapping's module attribute renamed to exports.
    • New Render class represents a rendering task for one Drawing, including all render parameters (e.g. drawing, mappings, and styles).
      • xMin, xMax, yMin, yMax, width, height, and layers attributes which are useful in preprocess and postprocess.
      • id method for generating unique IDs; svgtiler.id calls this.
      • def method for including <defs> content; svgtiler.def calls this.
      • add method for adding SVG content; svgtiler.add calls this.
      • makeDOM, makeSVG, makeTeX re...
Read more

v2.4.1

10 Aug 22:42
Compare
Choose a tag to compare
  • Fix svgtiler CLI on Windows, broken in v2.3.0 when fixing Linux, by wrapping CLI in another NodeJS layer
  • Revise Mario example to use new share feature
  • Improve documentation, e.g., what "SKIPPED" and "UNCHANGED" mean.
  • Minor code cleanup

Full Changelog: v2.4.0...v2.4.1

v2.4.0

28 Jul 19:35
Compare
Choose a tag to compare
  • Selective building (#70): svgtiler no longer builds everything; it now acts like make and selectively builds what it detects needs rebuilding. .svg/.tex files will be recomputed only when they are older than the drawing file, any mapping file (or one of their required dependencies), or any style file; otherwise, you will see the message (SKIPPED). These files only get rewritten (and their date stamp changed) if their contents have actually changed; otherwise, you will see the message (UNCHANGED). This pairs well with the PDF/PNG conversion of v2.3.0, which only does Inkscape conversion when the SVG file is newer: if the SVG doesn't change, it will no longer trigger PDF/PNG conversion.
    • Use -f/--force to override and force all builds, like the old behavior.
  • Support require/importing raster images and SVG files from JavaScript/CoffeeScript mapping files (#73). Returns the SVG content as Preact Virtual DOM, making it easy to modify (e.g., strip off <svg> wrapper or add a child). Raw SVG string also available via require(...).svg.
  • New Chess example illustrating new require feature for loading and manipulating .svg files, dynamic symbol computation, and JSX notation for creating and composing symbols.
  • Provide new share global variable for sharing state between mapping files (#77). For example, this lets you define one mapping file whose behavior is controlled by options specified by one or more other mapping files. (See revised Mario example.)
  • Add match method to Context for simpler RegExp matching (previously documented by not implemented)
  • Omit SVG Tiler version number from generated .tex files, for consistent builds and version control across multiple users
  • Warn instead of crash when mapping returns string
  • Fix multiple xmlns:xlink attributes arising when embedding using .svg files directly inside tiles.
  • Fix removal of SVG/XML comment headers in .svg source files (when require/importing and for namespace mangling)
  • Remove examples directory from NPM package, reducing package size from 1.1 MB (135.6 kB compressed) to 184.9 kB (55.8 kB compressed), for faster installation.
  • Document -i/--inkscape option
  • Documentation now has table of contents for easier navigation

Full Changelog: v2.3.0...v2.4.0

v2.3.0

22 Jul 03:14
Compare
Choose a tag to compare
  • More efficient conversion of SVG files to PDF/PNG via a new spin-off project svgink. (#75)
  • You can now specify an .svg file (drawn with another tool) directly on the command line to just convert it to PDF/PNG. (Alternatively, you can run svgink directly.) (#75)
  • New command-line options -f/--force to force conversion.
  • Bug fix for Linux which prevented v2.2.0 from running.
  • API change: renamed SVGTilerException to SVGTilerError.

Full Changelog: v2.2.0...v2.3.0

v2.2.0

12 May 00:59
Compare
Choose a tag to compare
  • .js and .coffee mapping files are now loaded as NodeJS modules. (Previously, they were run as special functions.)
    • Makes these files more interoperable when using them as mappings vs. via require or import.
    • Reveals additional Node features (e.g. module global)
    • Enables a lot of other exciting features:
  • New support for import syntax as an alternative to require.
  • New ways to specify the mapping from a mapping file: export default mapping or exports.default = mapping. You can still just write the mapping at the end of the file.
  • required and imported modules can use JSX syntax, so you can share JSX code between mapping files. (#65)
  • Source maps are now fully supported, which means errors from your CoffeeScript mapping files will now have correct line numbers. (#56)
  • Command-line interface has new options for setting the output directory, helping you keep organized. (#58)
    • -o/--output sets an overall default output directory
    • -os/--output-svg, -op/--output-pdf, -oP/--output-png, -ot/--output-tex control output directory by file type
  • API changes to support a settings object instead of overriding class static attributes. (#47)
    • All settings can now be overridden in renderDOM via data-* attributes.
    • New defaultSettings exported object to modify defaults.
    • Replaces old undocumented renderDOMDefaults object.
    • Replaces old undocumented overrides: Drawing.inlineImages, Drawing.keepMargins, Drawing.useHref, Drawings.keepHidden, Symbol.svgEncoding, Symbol.forceWidth, Symbol.forceHeight, Symbol.texText, Symbol.overflowDefault
  • xmldom upgrade means that > is now escaped as &gt;. This can affect CSS output, but should make the resulting SVG easier to parse.

Full Changelog: v2.1.1...v2.2.0

v2.1.1

02 Apr 16:19
Compare
Choose a tag to compare
  • Fix support for DOS-formatted (\r\n newlines) and old Mac-formatted (\r newlines) .txt files

Full Changelog: v2.1.0...v2.1.1

v2.1.0

24 Aug 04:01
Compare
Choose a tag to compare
  • New renderDOM API feature for rendering DOM elements that contain drawings (e.g. ASCII art) directly into SVG (#64). See these slides for an example of usage.
  • Mapping API now supports direct construction of a mapping via new Mapping(data) where data is an object or function. (Previously, you had to create a new Mapping and then call the load method.)
  • Document above subset of API as stable

v2.0.1

20 Aug 14:57
Compare
Choose a tag to compare
  • Update xmldom, improving SVG output in edge cases, in particular addressing a security vulnerability
  • Update Babel and xlsx

v2.0.0

07 Aug 17:14
Compare
Choose a tag to compare
  • BREAKING CHANGE: Switch from preserveAspectRatio="xMinYMin meet" to default preserveAspectRatio="xMidyMid meet" (centering), which seems more useful especially in the context of slides. See preserveAspectRatio.
  • Fix href attribute in case of image embedding (broken in v1.17.0 when adding Drawing.href feature)