add basic hide formatted version body

This commit is contained in:
Shea Duma committed 2026-04-24 07:51:36 +03:00
1 parent c2f7a6ca87
commit 33bbec404a
2 files changed
+15 -1

No files matched your search

@@ -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);
+11 -1
View File
@@ -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 `<a data-md href="${g2}">${parse(g1)}</a>`;
},
};
const HIDDEN_LINK_URL = `&lt;(https?:\\/\\/.+?)&gt;`;
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}`;