Skip to content

Feat: Add preventing urlPreviewing by surrounding a link in angle brackets#552

Closed
nushea wants to merge 6 commits intoSableClient:devfrom
nushea:censor-link
Closed

Feat: Add preventing urlPreviewing by surrounding a link in angle brackets#552
nushea wants to merge 6 commits intoSableClient:devfrom
nushea:censor-link

Conversation

@nushea
Copy link
Copy Markdown
Contributor

@nushea nushea commented Mar 26, 2026

Description

This is an implementation with the main purpose to serve as a proposal.

Currently there is no way to tell the client to not display a urlPreview if they are enabled, this PR proposes adding it by surrounding the link in angle brackets such as <https://app.sable.moe>, [Sable!](<https://app.sable.moe>), or <[Sable!](https://app.sable.moe)>
The message saves the angle brackets outside of the link tag regardless to not break the links on any other client that does not have the regular hide preview mode (so regardless of whether you type [foo](<https://bar>) or <[foo](https://bar)> it will save it as <<a data-md href='https://bar'>foo</a>> as formatted text and <(foo)[https://bar]> as regular text)

I am not sure if this would count as proper markdown but it is a very useful feature on discord and order platforms that have urlPreviews in order to prevent irrelevant previews intruding in the timeline.

Additionally, the implementation is working for me in all the cases i have tested but i am not a regex person by any means so if anyone could doublecheck my work it would be greatly appreciated.

Lastly, in this implementation the angle brackets get hidden regardless of whether it is rendering the formatted_body or the body, but i am not 100% sure if the regular body should get this type of formatting.

(normal look)
image

(new look)
image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

A demon whispered the implementation in my ears.

@nushea nushea requested review from 7w1 and hazre as code owners March 26, 2026 21:37
@nushea nushea marked this pull request as draft March 26, 2026 21:40
@hazre
Copy link
Copy Markdown
Member

hazre commented Mar 27, 2026

Good stuff, my only feedback would be to lower the scope a bit and only allow <> around urls, not markdown itself. That should simply the code a lot more and should be more inline with something like discord.

So in case you want to use it in a link markdown, it can be used like this (as you already suggested):

[Sable](<https://app.sable.moe>)

Instead of this

<[Sable](https://app.sable.moe)>

@nushea nushea closed this Apr 27, 2026
@nushea nushea deleted the censor-link branch April 27, 2026 06:17
@nushea nushea restored the censor-link branch April 27, 2026 06:17
@nushea nushea deleted the censor-link branch April 27, 2026 06:17
nushea pushed a commit to Septicity/Sable that referenced this pull request May 1, 2026
…ets (SableClient#717)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->
This PR implements preventing previews by surrounding a link in angle
brackets, it hides the angle brackets in both the formatted_body and the
regular body, and instead adds the links as skeletons to the bundled
previews.

This PR also serves as scaffolding for implementing the actual bundled
previews.

(example of the 4 usages)
<img width="935" height="861" alt="image"
src="https://github.com/user-attachments/assets/6abe5b6a-28ad-4a16-92a1-3c1483c565af"
/>
<img width="999" height="837" alt="image"
src="https://github.com/user-attachments/assets/b4198734-4a3c-4320-ad2c-a1782b40d375"
/>

This PR matches the features SableClient#552 but uses the new standard way instead
of an ad hoc solution

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)

### Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
My will be sin eater will clear me of the sin of having implemented
this.
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.

2 participants