Go to file
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
.circleci 3.0.5 version of cimg/ruby:3.0-node upgraded to node 18 (#21873) 2022-11-30 09:56:27 +01:00
.devcontainer Fix auto detect language for translate service (#19244) 2022-09-27 23:33:56 +02:00
.github Merge branch 'main' into glitch-soc/merge-upstream 2022-12-01 11:08:52 +01:00
app Use a tree‐based approach for advanced text formatting (#1907) 2022-12-02 10:29:42 +01:00
bin Update Mastodon to Rails 6.1 (#15910) 2021-03-24 10:44:31 +01:00
chart Fix the command to create the admin user (#19827) 2022-11-24 21:32:03 +01:00
config Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
db Merge branch 'main' into glitch-soc/merge-upstream 2022-11-06 09:50:41 +01:00
dist Fix nginx location matching (#20198) 2022-11-09 04:12:57 +01:00
lib Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
log
public Merge branch 'main' into glitch-soc/merge-upstream 2022-11-06 09:50:41 +01:00
spec Use a tree‐based approach for advanced text formatting (#1907) 2022-12-02 10:29:42 +01:00
streaming Merge branch 'main' into glitch-soc/merge-upstream 2022-11-15 02:10:37 +01:00
vendor
.browserslistrc Add ES6 compatibility to browserslist (#18519) 2022-05-26 20:29:28 +02:00
.buildpacks Remove nodejs buildpack from buildpacks (#14364) 2020-07-20 09:48:10 +02:00
.codeclimate.yml Replace from Code Climate to Super-Linter (#18587) 2022-06-01 19:22:35 +02:00
.deepsource.toml Update .deepsource.toml (#15753) 2021-02-19 09:53:25 +01:00
.dockerignore Update .dockerignore/.gitignore for #16947 etc (#17099) 2021-12-06 18:04:04 +01:00
.editorconfig
.env.production.sample Allow number of trending hashtags to be customizable (#1884) 2022-11-02 09:20:47 +01:00
.env.test Bump webpacker from 4.0.7 to 4.2.0 (#12416) 2019-11-20 17:56:11 +01:00
.env.vagrant Add a default DB_HOST to .env.vagrant for enable the streaming (#14030) 2020-06-15 01:57:06 +02:00
.eslintignore
.eslintrc.js Replace from Code Climate to Super-Linter (#18587) 2022-06-01 19:22:35 +02:00
.foreman
.gitattributes
.gitignore Helm update readme.md (#20154) 2022-11-10 19:09:54 +01:00
.gitmodules
.haml-lint.yml
.nanoignore
.nvmrc NodeJS 14 support - circleci/docker/.nvmrc (#16163) 2021-08-10 22:56:13 +02:00
.prettierignore Format JSON and YAML using Prettier (#17823) 2022-03-21 04:46:11 +01:00
.prettierrc.js Format JSON and YAML using Prettier (#17823) 2022-03-21 04:46:11 +01:00
.profile
.rspec
.rubocop.yml Remove support for Ruby 2.6 (#21477) 2022-11-27 20:41:39 +01:00
.ruby-gemset Make Mastodon use its own gemset (#17858) 2022-08-13 15:44:34 +02:00
.ruby-version Bump Ruby version from 3.0.3 to 3.0.4 (#18028) 2022-08-15 04:39:58 +02:00
.slugignore
.yarnclean Replace from scss-lint to sass-lint (#10958) 2019-06-04 17:23:18 +02:00
AUTHORS.md Update AUTHORS.md (#20630) 2022-11-14 08:33:24 +01:00
Aptfile Heroku fix (#19807) 2022-11-05 22:57:58 +01:00
CHANGELOG.md Bump version to 4.0.2 (#20725) 2022-11-15 03:57:18 +01:00
CODE_OF_CONDUCT.md Change e-mail contact for CoC enforcement 2019-06-06 17:42:07 +02:00
CONTRIBUTING.md Merge branch 'main' into glitch-soc/merge-upstream 2022-11-12 13:28:03 +01:00
Capfile
Dockerfile Add missing procps package to Dockerfile (#21028) 2022-11-22 05:52:18 +01:00
FEDERATION.md Add FEDERATION.md (#17029) 2021-11-23 00:15:31 +01:00
Gemfile Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
Gemfile.lock Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
LICENSE
Procfile fix: make Procfile compatible with herokuish (#12685) 2020-08-29 19:00:30 +02:00
Procfile.dev Set RAILS_ENV in Procfile.dev (#15502) 2021-01-07 09:30:12 +01:00
README.md Remove support for Ruby 2.6 (#21477) 2022-11-27 20:41:39 +01:00
Rakefile
SECURITY.md Change e-mail in SECURITY.md (#20384) 2022-11-11 05:26:43 +01:00
Vagrantfile Merge branch 'main' into glitch-soc/merge-upstream 2022-02-17 10:58:44 +01:00
app.json Make enable_starttls configurable by envvars (#20321) 2022-11-10 21:06:21 +01:00
babel.config.js Remove dependency for @babel/plugin-proposal-class-properties (#16155) 2021-05-04 23:13:04 +02:00
config.ru
crowdin.yml Prevent translations from accidentally becoming completely different from source strings on Crowdin without translators noticing. (#17085) 2021-12-01 19:03:35 +01:00
docker-compose.yml Update docker-compose.yml (#19063) 2022-08-27 17:40:46 +02:00
ide-helper.js Add JS IDE helper (#13012) 2020-04-27 17:19:53 +02:00
jest.config.js Merge branch 'main' into glitch-soc/merge-upstream 2022-05-04 19:15:50 +02:00
jsconfig.json Replace `CancelToken` to `AbortSignal` (#19352) 2022-10-14 03:16:37 +02:00
package.json Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
postcss.config.js
priv-config
scalingo.json Make enable_starttls configurable by envvars (#20321) 2022-11-10 21:06:21 +01:00
stylelint.config.js Replace from Code Climate to Super-Linter (#18587) 2022-06-01 19:22:35 +02:00
yarn.lock Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00

README.md

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?