Skip to content

Support the hast "comment" node type, and support header comments that contain <tags> - #15

Open
AndrewDicks wants to merge 1 commit into
Rich-Harris:masterfrom
AndrewDicks:master
Open

AndrewDicks wants to merge 1 commit into
Rich-Harris:masterfrom
AndrewDicks:master

Conversation

@AndrewDicks

Copy link
Copy Markdown

Hi

Thanks for this useful tool. I'm submitting this PR for two reasons:

  1. hast comment node-type support
  2. A bug when parsing pre-root-tag comments that contain -style text

Support the hast comment node-type

I noticed that comments were being stripped from SVGs - for a variety of reasons I needed to keep them, so I forked your repo and implemented the hast comment node type.

Bug in parsing header/metadata comments that contain

If a comment in the header section contains a , the parser fails to parse the file. e.g. this SVG would fail to parse due to the tag in the comment. Tags are legal in HTML comments, and should not be escaped to < / >.

<?xml version="1.0" standalone="yes"?>
<!-- pre-root-element comment with <some tag/> in it -->
<svg xmlns="http://www.w3.org/2000/svg"></svg>

I've also written tests for this extra functionality, and updated the expected output from your original comment test.

Kind regards

Andy

Improved parsing header/metadata to support SVGs with leading comments that (legally) contain <tags>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant