toolbox-team / reddit-moderator-toolbox

Moderator toolbox for reddit extension development.
https://www.reddit.com/r/toolbox
Apache License 2.0
114 stars 37 forks source link

Replace RR HTML parsing with replaced tokens #118

Open eritbh opened 5 years ago

eritbh commented 5 years ago

Instead of using stuff like <textarea>, <select>, <input> inside removal reason bodies to get custom text input, we should have tokens that are replaced with the appropriate elements without having to parse HTML. For example:

part of #93

things we'll have to do

blocked on #119

Venefilyn commented 5 years ago

I would suggest to use | as delimiter as it's seldom used in comments/posts.

And for templating, I'd suggest to mix two chars for start and finish, or use them twice.

{$ thing here $}
{% thing here %}
{{ thing here }} <-- I prefer this one

This is so you can use the characters in the comments without running into issues so easily. And we can make sure people can fix it if they want by escaping

{{select
|I am an \| option 
|I'm \{\{ enclosed }}
}}

If we ever introduce parameters for types, we can do something like

{{switch;name:fancyname|Switch label here}}
{{select;typeahead;hidden-by:fancyname|foo|bar|baz}}

Edit: Some more options

{{start-select;option;option2}}
{{start-item}}
I am an | option 
{{end-item}}
{{start-item}}
I'm \{\{ enclosed }}
{{end-item}}
{{end-select}}
@start-select(option, option2)
@start-item
I am an | option 
@end-item 
@start-item 
I'm {{ enclosed }}
@end-item
@end-select
creesch commented 4 years ago

Just going over issues at the moment and wanted to note that:

I would suggest to use | as delimiter as it's seldom used in comments/posts.

Probably isn't true as I have seen it used in footers a bunch to put in a bunch of links to stuff like rules, wikis, etc.

Not sure what the best approach here is except possibly building in escape functionality for whatever delimiter character we decide on.

Venefilyn commented 4 years ago

So, instead of doing tokens. Another option would be to keep HTML parsing but utilize web-components (if that's possible).

This means we can

Or will there still be an issue with escaping and whatnot?