Markdown: don't convert '[label](uri)' to embeds.
## Issue Closes 4936: Don't process markdown formatting as lbry:// url previews ## Approach Preamble: - We want to convert plain `https://lbry.tv/befreeonlbry` to an embed, but not `[blah](https://lbry.tv/befreeonlbry)`. - At the markdown/remark level, both formats resolve to the same node type, having a `link` and a `text`, with the 'text' being auto-filled with the `href` if there is no label. Fix by assuming the link is the non-labelled format if the `text` is the same as `href`. This opens up one corner-case that we can't handle, which is when the user explicitly set the label using the href, e.g. `[https://lbry.tv/befreeonlbry](https://lbry.tv/befreeonlbry)`. This will still resolve to an embed. There's not enough data at the parsed level differentiate this case -- we would need to parse the content ourself before `remark`, which I think is not worth it. ## Aside/Reminder If you see that the link doesn't resolve to an embed regardless of the format used, that's probably just due to `5636: Disable video previews in comments/posts made by channels below a certain channel staked level`
This commit is contained in:
parent
7ddace3266
commit
d91530b0c8
1 changed files with 4 additions and 1 deletions
|
@ -67,7 +67,10 @@ function MarkdownLink(props: Props) {
|
|||
const possibleLbryUrl = linkPathPlusHash ? `lbry://${linkPathPlusHash.replace(/:/g, '#')}` : undefined;
|
||||
|
||||
const lbryLinkIsValid = possibleLbryUrl && isURIValid(possibleLbryUrl);
|
||||
if (lbryLinkIsValid) {
|
||||
const isMarkdownLinkWithLabel =
|
||||
children && Array.isArray(children) && React.Children.count(children) === 1 && children.toString() !== href;
|
||||
|
||||
if (lbryLinkIsValid && !isMarkdownLinkWithLabel) {
|
||||
lbryUrlFromLink = possibleLbryUrl;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue