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

feat(util): add markdown format functions to util #2314

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

HTGAzureX1212
Copy link
Contributor

Closes #2279.

This draft PR explores a potential implementation for markdown formatting functions. It is expected that the implementation would be iterated on for a bit before this is actually merged into main.

@HTGAzureX1212 HTGAzureX1212 added w-do-not-merge PR is blocked or deferred w-unapproved Proposal for change has *not* been approved by @twilight-rs/core. w-needs-more-docs Needs more documentation before being worked on. labels Feb 14, 2024
@HTGAzureX1212 HTGAzureX1212 self-assigned this Feb 14, 2024
@github-actions github-actions bot added c-util Affects the util crate t-feature Addition of a new feature labels Feb 14, 2024
Copy link
Member

@Gelbpunkt Gelbpunkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing spoilers and code blocks (perhaps even more that I didn't think of).

twilight-util/src/format.rs Outdated Show resolved Hide resolved
@HTGAzureX1212 HTGAzureX1212 requested a review from Gelbpunkt May 6, 2024 00:36
@HTGAzureX1212
Copy link
Contributor Author

Do you think we need to add the H1, H2, H3, ... formatting?

@laralove143
Copy link
Member

Do you think we need to add the H1, H2, H3, ... formatting?

yes, i think this should support all of discord's supported markdown, including named links and timestamps

@HTGAzureX1212
Copy link
Contributor Author

Do you think we need to add the H1, H2, H3, ... formatting?

yes, i think this should support all of discord's supported markdown, including named links and timestamps

Promptly added.

twilight-util/src/format.rs Outdated Show resolved Hide resolved
twilight-util/src/format.rs Outdated Show resolved Hide resolved
twilight-util/src/lib.rs Outdated Show resolved Hide resolved
@Gelbpunkt
Copy link
Member

I don't think this implementation suffices. It currently has two major issues:

  1. It doesn't escape properly, which IMO is the main reason to even use these helpers instead of simply wrapping the text yourself
  2. It doesn't handle multi-line text properly for some cases like block quotes, where each line needs to be prepended individually

@HTGAzureX1212
Copy link
Contributor Author

I'll look into those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-util Affects the util crate t-feature Addition of a new feature w-do-not-merge PR is blocked or deferred w-needs-more-docs Needs more documentation before being worked on. w-unapproved Proposal for change has *not* been approved by @twilight-rs/core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter macros
4 participants