Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to detect fancy formatting using Unicode math characters #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fasiha
Copy link
Collaborator

@fasiha fasiha commented Apr 25, 2023

Fixes #9.

Tested and seems to be working:

  • got a reply from the bot to my toot containing fancy formatting
    Toot and reply, works as expected
  • boosted a toot with fancy formatting and got a reply from the bot
    Boost and reply, works as expected
  • I'd love someone to edit the copy in fancyFormattingGrammar.json, are my messages any good? Happy to accept any and all feedback on how to make this approachable and encouraging and useful.
    • Note that we have two separate grammars for (a) posting images without captions and (b) reblogging/boosting images without captions. Rather than have separate grammars for post-vs-reblog fancy formatting, I decided to have just a single grammar that tries to address both cases. If this doesn't work, let me know and I'll happily break this into two separate grammars, one for folks who post fancy formatting and another for boosts.

Small code changes:

  1. instead of sendPrivateStatus making the random string, it's caller processDeleteEvent does that instead. The motivation for this is that the latter has the information about whether this is about captions or about fancy formatting.
  2. Streamline the three separate grammars we have and expose all three. This makes processDeleteEvent easy to understand I hope.
  3. Big new module is the fancyFormatting.js that's basically a wrapper around a single regexp. It has a built-in mini-test (if you run node js/fancyFormatting.js it'll run the mini-test)—happy to move this into a proper unit test in a tests/ directory and add it to package.json. The comment at the top of the file describes some technical shortcuts that I took, happy to answer questions about that.

Tested and seems to be working.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle the case where people post or boost Unicode mathematical symbols for formatting
1 participant