Skip to main content

encode_style_to_string

Function encode_style_to_string 

Source
pub fn encode_style_to_string<S: AsRef<str>>(
    text: S,
    output: &mut String,
) -> &str
Expand description

Write text used in the <style> element to a mutable String reference and return the encoded string slice.

This appends to output and returns only the new string slice.

The following substring is escaped:

  • </style> => <\/style>
  • <!-- => <\!--

</style at the end of the text is also escaped, because the text after it can end the element. Pass the whole element text in one call; separate calls do not share parsing state. This scans text without parsing CSS and may change its meaning. Existing escapes are kept, so encoding and decoding may not return the original text. Use a quoted text encoder when inserting raw text into a CSS string.