Commit Graph

7 Commits

Author SHA1 Message Date
Claire
6a900d4c8b Change AdvancedTextFormatter to rewrite entities in one pass and sanitize at the end
Also, minor refactoring to better match how other formatters are organized.
2022-11-30 11:05:01 +01:00
kibigo!
4a66e4daa3 Minor cleanup to AdvancedTextFormatter 2022-11-11 02:17:34 -08:00
kibigo!
ae06820428 Also disallow entities inside of <code>
I think this is generally expected behaviour, and people are annoyed
when their code gets turned into links/hashtags/mentions.
2022-11-10 19:14:52 -08:00
kibigo!
09cbd6c65e Use a tree‐based approach for adv. text formatting
Sanitizing HTML/Markdown means parsing the content into an HTML tree
under‐the‐hood anyway, and it is more accurate to do mention/hashtag
replacement on the text nodes in that tree than it is to try to hack it
in with regexes et cetera.

This undoes the overrides of `#entities` and `#rewrite` on
`AdvancedTextFormatter` but also stops using them, instead keeping
track of the parsed Nokogiri tree itself and using that in the `#to_s`
method.

Internally, this tree uses `<mastodon-entity>` nodes to keep track of
hashtags, links, and mentions. Sanitization is moved to the beginning,
so it should be known that these do not appear in the input.
2022-11-08 21:34:16 -08:00
Claire
fe65c0e44f Fix leading spaces being stripped in Markdown code blocks
Fixes #1776
2022-05-24 10:24:59 +02:00
Claire
8d6f3f8a37 Fix code blocks processing 2022-03-28 23:40:45 +02:00
Claire
61cefbebf7 Add advanced text formatting back into glitch-soc 2022-03-28 22:21:37 +02:00