forked from treehouse/mastodon
2cabc5d188
* 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> |
||
---|---|---|
.. | ||
activitypub | ||
admin | ||
connection_pool | ||
importer | ||
nodeinfo | ||
ostatus | ||
rss | ||
settings | ||
translation_service | ||
vacuum | ||
access_token_extension.rb | ||
account_reach_finder.rb | ||
activity_tracker.rb | ||
advanced_text_formatter.rb | ||
application_extension.rb | ||
ascii_folding.rb | ||
cache_buster.rb | ||
delivery_failure_tracker.rb | ||
emoji_formatter.rb | ||
entity_cache.rb | ||
extractor.rb | ||
fast_geometry_parser.rb | ||
fast_ip_map.rb | ||
feed_manager.rb | ||
hash_object.rb | ||
hashtag_normalizer.rb | ||
html_aware_formatter.rb | ||
inline_renderer.rb | ||
link_details_extractor.rb | ||
permalink_redirector.rb | ||
plain_text_formatter.rb | ||
potential_friendship_tracker.rb | ||
rate_limiter.rb | ||
redis_configuration.rb | ||
request.rb | ||
request_pool.rb | ||
response_with_limit.rb | ||
scope_parser.rb | ||
scope_transformer.rb | ||
search_query_parser.rb | ||
search_query_transformer.rb | ||
status_cache_hydrator.rb | ||
status_filter.rb | ||
status_finder.rb | ||
status_reach_finder.rb | ||
suspicious_sign_in_detector.rb | ||
tag_manager.rb | ||
text_formatter.rb | ||
themes.rb | ||
toc_generator.rb | ||
translation_service.rb | ||
user_settings_decorator.rb | ||
vacuum.rb | ||
validation_error_formatter.rb | ||
video_metadata_extractor.rb | ||
webfinger.rb | ||
webfinger_resource.rb |