Skip to content

Commit

Permalink
[#67371] output the input markdown on links surround
Browse files Browse the repository at this point in the history
  • Loading branch information
Trzcin committed Oct 16, 2024
1 parent 5370d9a commit 36a8720
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/hooks/useText.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ function checkLinks(/** @type {markdownIt} */ md) {
const defaultRule = md.renderer.rules.link_open;
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const href = tokens[idx].attrs?.find((a) => a[0] == "href")?.[1];
if (href?.startsWith("(")) return href;
if (href?.startsWith("(")) {
const linkLabel = tokens[idx + 1];
const linkClose = tokens[idx + 2];
linkLabel.content = `[${linkLabel.content}]`;
linkClose.type = "text";
linkClose.content = `(${href})`;
return "";
}

return defaultRule(tokens, idx, options, env, self);
};
Expand Down

0 comments on commit 36a8720

Please sign in to comment.