From 33bbec404a2b8308abdfecab4f35b7c8ad6e36ca Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Fri, 24 Apr 2026 07:51:36 +0300 Subject: [PATCH] add basic hide formatted version body --- src/app/plugins/markdown/inline/parser.ts | 4 ++++ src/app/plugins/markdown/inline/rules.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/plugins/markdown/inline/parser.ts b/src/app/plugins/markdown/inline/parser.ts index 19c032bbd..ade85ceed 100644 --- a/src/app/plugins/markdown/inline/parser.ts +++ b/src/app/plugins/markdown/inline/parser.ts @@ -2,6 +2,7 @@ import { BoldRule, CodeRule, EscapeRule, + HiddenLinkRule, ItalicRule1, ItalicRule2, LinkRule, @@ -13,6 +14,7 @@ import { runInlineRule, runInlineRules } from './runner'; import type { InlineMDParser } from './type'; const LeveledRules = [ + HiddenLinkRule, BoldRule, ItalicRule1, UnderlineRule, @@ -31,6 +33,8 @@ const LeveledRules = [ */ export const parseInlineMD: InlineMDParser = (text) => { if (text === '') return text; + // oxlint-disable-next-line no-console + console.log(text); let result: string | undefined; if (!result) result = runInlineRule(text, CodeRule, parseInlineMD); diff --git a/src/app/plugins/markdown/inline/rules.ts b/src/app/plugins/markdown/inline/rules.ts index 499a1a8d6..b86d139f2 100644 --- a/src/app/plugins/markdown/inline/rules.ts +++ b/src/app/plugins/markdown/inline/rules.ts @@ -108,7 +108,7 @@ export const SpoilerRule: InlineMDRule = { }; const LINK_ALT = `\\[${MIN_ANY}\\]`; -const LINK_URL = `\\((https?:\\/\\/.+?)\\)`; +const LINK_URL = `\\((<)?(https?:\\/\\/.+?)(>)?\\)`; const LINK_REG_1 = new RegExp(`${LINK_ALT}${LINK_URL}`); export const LinkRule: InlineMDRule = { match: (text) => text.match(LINK_REG_1), @@ -118,6 +118,16 @@ export const LinkRule: InlineMDRule = { return `${parse(g1)}`; }, }; +const HIDDEN_LINK_URL = `<(https?:\\/\\/.+?)>`; +const HIDDEN_LINK_REG_1 = new RegExp(HIDDEN_LINK_URL); +export const HiddenLinkRule: InlineMDRule = { + match: (text) => text.match(HIDDEN_LINK_REG_1), + html: (parse, match) => { + const [, g1] = match; + if (!g1) return ''; + return g1; + }, +}; export const INLINE_SEQUENCE_SET = '[*_~`|]'; export const CAP_INLINE_SEQ = `${URL_NEG_LB}${INLINE_SEQUENCE_SET}`;