SVG Stroke Dasharray Number Parser

Parse the unitless finite-number SVG stroke-dasharray branch or none; lengths with units and percentages require a separate context.

Description

Parse the unitless finite-number SVG stroke-dasharray branch or none; lengths with units and percentages require a separate context.

A stroke dash-array value may be none or a list of nonnegative numbers. This parser handles the number-only branch.

When to use this tool

Parse the unitless finite-number SVG stroke-dasharray branch or none; lengths with units and percentages require a separate context.

  • Prepare the supplied value fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter value. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.none, result.dashArray. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Trim the value; exact none returns none true and an empty list. Otherwise parse finite SVG numeric tokens with the supported whitespace/comma separators, require a nonempty nonnegative list and return none false.1

Input fieldMeaning and representationAccepted input
valuevalue.Text; at most 8,192 UTF-16 code units, subject to the grammar above
Output fieldInterpretation
resultObject containing the named outputs below.
result.noneFlag for none under the exact condition described above.
result.dashArrayThe dash array list in the ordering and representation described above.
json
{
  "input": {
    "value": "2,1 3"
  },
  "output": {
    "result": {
      "none": false,
      "dashArray": [
        2,
        1,
        3
      ]
    }
  }
}

Limitations and assumptions

  • Percentages, CSS units and other computed-style syntax are unsupported. Odd counts are not duplicated by this parser.
  • Point pairs use [x,y], rectangles and viewBox use [x,y,width,height], and all coordinate units must be consistent. This tool does not read, render or modify an SVG document.
  • Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
  • String lists have at most 128 entries of at most 128 code units; matrices have at most 128 rows and columns. Larger numeric lists and parsed JSON have separate bounded budgets. Nonfinite results and excessively large serialized outputs are rejected.
  • Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.

Alternative or Complementary methods

Use a full SVG parser or rendering engine when the task includes commands and CSS values outside the documented branch. Compare coordinates and transforms under the same units and viewport convention.

References

  1. Tool behavior and example: SVG Stroke Dasharray Number Parser — tool.io

Similar or alternative tools

  • SVG Stroke Dasharray Cycle Normalizer

    Normalize an odd SVG dash list by duplication and retain an all-zero solid-stroke condition; not an automatic dash renderer.

  • SVG ViewBox Number Parser

    Parse an SVG viewBox with explicit nonnegative width/height; zero dimensions are retained as nonrenderable, not a valid aspect-ratio divisor.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies