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
2021-03-24 10:44:31 +01:00
2022-11-09 04:12:57 +01:00
2016-02-20 22:53:20 +01:00
2022-11-10 19:09:54 +01:00
2017-12-03 23:26:40 -08:00
2017-07-27 22:30:27 +02:00
2016-02-25 00:17:01 +01:00
2017-07-27 22:30:27 +02:00
2022-11-05 22:57:58 +01:00
2022-11-14 08:33:24 +01:00
2022-11-15 03:57:18 +01:00
2021-11-23 00:15:31 +01:00
2020-04-27 17:19:53 +02:00
2018-06-26 20:34:12 +02:00
2016-02-20 22:53:20 +01:00
2022-11-27 20:41:39 +01:00

Mastodon Glitch Edition

Now with automated deploys!

Build Status Code Climate

So here's the deal: we all work on this code, and anyone who uses that does so absolutely at their own risk. can you dig it?

Description
No description provided
Readme AGPL-3.0 244 MiB
Languages
JavaScript 73.5%
SCSS 22.2%
TypeScript 4.2%