jaynewey / django-octicons-v10

Django templatetags for GitHub Octicons v10.0.0+.
https://pypi.org/project/django-octicons-v10/
MIT License
2 stars 4 forks source link

Parse SVG files and throw away root tag. #17

Closed apollo13 closed 2 years ago

apollo13 commented 2 years ago

This PR preparses the SVG files and extracts the child elements. This leads to less clutter in the HTML as there is no need to nest the and <svg> in an <svg>.

So instead of:

<svg width="100" style="vertical-align: baseline" height="100" class="octicon octicon-home-fill" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
    <path d="M12.97 2.59a1.5 1.5 0 00-1.94 0l-7.5 6.363A1.5 1.5 0 003 10.097V19.5A1.5 1.5 0 004.5 21h4.75a.75.75 0 00.75-.75V14h4v6.25c0 .414.336.75.75.75h4.75a1.5 1.5 0 001.5-1.5v-9.403a1.5 1.5 0 00-.53-1.144l-7.5-6.363z"></path>
  </svg>
</svg>

we now get:

<svg xmlns="http://www.w3.org/2000/svg" width="100" style="vertical-align: baseline" height="100" class="octicon octicon-home-fill" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
  <path d="M12.97 2.59a1.5 1.5 0 00-1.94 0l-7.5 6.363A1.5 1.5 0 003 10.097V19.5A1.5 1.5 0 004.5 21h4.75a.75.75 0 00.75-.75V14h4v6.25c0 .414.336.75.75.75h4.75a1.5 1.5 0 001.5-1.5v-9.403a1.5 1.5 0 00-.53-1.144l-7.5-6.363z"></path>
</svg>

For the resulting tag. Let me know what you think.

jaynewey commented 2 years ago

Love it!