Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse style from <style> tag and Add support to <line> tag #1719

Merged
merged 6 commits into from
Jan 27, 2022
Merged

Conversation

TonyCrane
Copy link
Collaborator

Motivation

#1717 (comment)
I solved this issue. Use tinycss2 to parse style (including <style> tag and style attributes in other tags), and use cssselect2 to choose which tag to apply to based on selector.
And in order to make cssselect2 handle selectors correctly, I replaced xml.dom.minidom with xml.etree for parsing SVG file, which also has more features.

At the same time, I also implemented the processing of the <line> tag by the way.

Proposed changes

  • M manimlib/mobject/svg/svg_mobject.py: improve style parsing and implement the <line> tag
  • M setup.cfg & requirements.txt: add dependency of cssselect2(tinycss2 will be installed along with it)

Test

Code:

class Code(Scene):
    def construct(self):
        svg = SVGMobject("beer.svg", color=BLACK, height=6)
        self.add(svg)

Result:
image

Code:

class Code(Scene):
    def construct(self):
        svg = SVGMobject("line.svg")
        self.add(svg)

line

Result:
image

@TonyCrane TonyCrane requested a review from 3b1b January 27, 2022 13:56
@3b1b 3b1b merged commit f60dc7c into master Jan 27, 2022
@TonyCrane TonyCrane deleted the parse-style branch January 28, 2022 01:54
TonyCrane added a commit that referenced this pull request Jan 30, 2022
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.

None yet

2 participants