jgarber / redcloth

RedCloth is a Ruby library for converting Textile into HTML.
Other
443 stars 113 forks source link

Unwanted Span Tag Addition Inside SVG Tags #76

Open Jaskaran2 opened 1 year ago

Jaskaran2 commented 1 year ago

@jgarber Are you aware of this issue? any quick-around you can suggest for this to get working?

Currently, the gem includes a behavior that automatically adds a span tag around capitalized words in the input text, which cannot be disabled. This behavior causes issues when the input includes content within svg tags, as it also adds the span tag inside the svg code.

For example, given the following input text:

* is a _shorthand syntax_ used to generate valid HTML The resulting HTML output includes the span tag:

<ul>
  <li>is a <em>shorthand syntax</em> used to generate valid <span class="caps">HTML</span></li>
</ul>

The problem arises when there is an all-capitalized color hex code inside the svg tag. The gem adds a span tag around it, causing the SVG code to break. For instance, the original SVG code:

<svg>.......st2{fill:#15467A !important} .st3{fill:#FFFFFF !important} ........</svg>

Is transformed into:

<svg>....... .st2{fill:#15467A !important} .st3{fill:#<span class="caps">FFFFFF</span> !important} ........</svg>

This unintended addition of the span tag within the SVG code causes issues with its rendering.

We need to find a solution to disable this span tag addition for content within svg tags.

Please address this issue to ensure the proper functioning of the gem with SVG content. Thank you.