Skip to content

Marker tags removed despite being used #2079

Open
@kv-bh

Description

Simple optimize command can result in markers being removed:
svgo -i input.svg -o output.svg

Input file:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <style>
.line {
  fill: none;
  stroke: #f00;
  stroke-width: 4px;
  marker-end: url(#arrow);
}
#arrow {}
  </style>
  <defs>
    <marker id="arrow" class="arrow" overflow="visible" markerHeight="1" markerWidth="1" orient="auto-start-reverse" preserveAspectRatio="xMidYMid" viewBox="0 0 1 1">
      <path d="M-3-3 0 0l-3 3"/>
    </marker>
  </defs>
  <path d="M 0 50 H 100" class="line"/>
</svg>

Output file:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M0 50h100" style="fill:none;stroke:red;stroke-width:4px;marker-end:url(#arrow)"/></svg>

Note that the arrow marker is missing in the output.

In the input file, if #arrow {} is either removed or changed to .arrow {}, the problem doesn't occur.

SVGO 3.3.2
Node 20.10.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions