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

feature: Add client-side parsing of inline markdown #4725

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

xyzshantaram
Copy link

@xyzshantaram xyzshantaram commented Apr 23, 2023

This PR introduces a client-side feature to parse inline markdown in messages and render it. I've added a settings toggle for it (Render inline markdown in messages), and the feature is off by default to avoid breaking anyone's workflow.

Settings toggle

It DOES NOT insert IRC control characters or otherwise modify the message being sent out, it is purely cosmetic.

Markdown is quite widely used and there's is some amount of support for adding it to The Lounge as far as I can tell from previous GitHub discussion here (#1830). People also seem to use things like asterisks and backticks a lot on various channels for emphasis and code. Additionally, unlike the IRC control characters to turn text italic, bold, etc, Markdown gracefully degrades to plain text for people on clients which don't support those features, which imo is more sensible than losing the meaning entirely on a client that doesn't support that kind of formatting.

The parsing code is definitely inefficient in my opinion but does not introduce any noticeable delay in using the app even in large buffers.

Here's a screenshot of the normal behaviour, with the setting turned off:

Parsing disabled

Here's a screenshot with parsing turned on:

Screenshot of the feature enabled and working

@xyzshantaram
Copy link
Author

I may also add support for quotes (i.e. messages that start with a > sign). They could be styled similarly to Discord or Slack's quoting.

@xyzshantaram
Copy link
Author

Quick update: added a settings toggle for showing the raw markdown characters in the rendered output. I think this should make both camps (i.e. "show exactly what was sent" vs "parse the markdown") happy.

Settings toggle

Feature screenshot

@brunnre8
Copy link
Member

why are you rebasing master onto your topic branch?
You don't have to merge back unrelated changes in any way. It's not helpful, especially not for reviewing

@xyzshantaram
Copy link
Author

@brunnre8 The contributing guidelines mentioned to rebase on the master branch, so that's what I've been doing. Sorry if I've misunderstood in some way.

@brunnre8
Copy link
Member

When asked to, if that disclaimer isn't there we need to update the docs.

But you didn't do that, you rewrote the commits frommerge_base..master onto your topic branch rather than reparenting your topic branch.

Look at the graph to see what I mean, git log --oneline --graph --all

@xyzshantaram
Copy link
Author

xyzshantaram commented Apr 26, 2023 via email

@brunnre8
Copy link
Member

fix it up and force push, yes.
And no worries, happens

@xyzshantaram
Copy link
Author

Okay! I think it's fixed now, apologies again for the mixup.

@xyzshantaram
Copy link
Author

Hi, sorry to ping a dead thread - Is there anything else that's needed from my end to move this PR closer to merging?

@brunnre8
Copy link
Member

Frankly, I'm not sure I like the functionality much. So I'm unsure if the added complexity would be worth it.
As said though, that's a personal opinion.

What I can say though is that the code is slightly crazy... Why are you doing that "rehydrate" dance and such?
Just hook into an actual parser, where we still are string based and omit html elements, rather than taking the output of parse as input.

Your parser is also broken... tests might have helped you.

// strips ** when it's not valid markdown
> parseMd('**testytest', false)
"<span class='irc-italic'></span>testytest"
// manages for * though
> parseMd('*testytest', false)
'*testytest'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: needs-review PR not yet reviewed by enough maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants