glitchier-soc/app
kibigo! 2cabc5d188
Use a tree‐based approach for advanced text formatting (#1907)
* 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.

* 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.

* Minor cleanup to AdvancedTextFormatter

* Change AdvancedTextFormatter to rewrite entities in one pass and sanitize at the end

Also, minor refactoring to better match how other formatters are organized.

* Add some tests

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2022-12-02 10:29:42 +01:00
..
chewy Change algorithm of tootctl search deploy to improve performance (#18463) 2022-05-22 22:16:43 +02:00
controllers Merge branch 'main' into glitch-soc/merge-upstream 2022-12-01 11:08:52 +01:00
helpers Merge branch 'main' into glitch-soc/merge-upstream 2022-11-12 13:28:03 +01:00
javascript Port navigation bar from upstream (#1986) 2022-12-01 20:06:08 +01:00
lib Use a tree‐based approach for advanced text formatting (#1907) 2022-12-02 10:29:42 +01:00
mailers Add support for language preferences for trending statuses and links (#18288) 2022-10-08 16:45:40 +02:00
models Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
policies Merge branch 'main' into glitch-soc/merge-upstream 2022-11-17 12:01:37 +01:00
presenters Change sign-in banner to reflect disabled or moved account status (#19773) 2022-11-05 18:28:13 +01:00
serializers Merge branch 'main' into glitch-soc/merge-upstream 2022-11-17 12:01:37 +01:00
services Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
validators Fix various issues with domain block import (#1944) 2022-11-17 11:42:20 +01:00
views Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
workers Merge branch 'main' into glitch-soc/merge-upstream 2022-11-12 13:28:03 +01:00