Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8ae68c

Browse files
committed
docs: udpate API generator
1 parent68a6c8c commita8ae68c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎packages/docs/build/api.mjs‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,28 @@ const TEXT_REPLACEMENTS = {
9595
*@param {string} text - The text to escape.
9696
*@returns {string} - The escaped text.
9797
*/
98+
constescInsideCode=(s)=>
99+
s
100+
.replaceAll(/\\/g,'\\\\')
101+
.replaceAll(/`/g,'\\`')
102+
.replaceAll(/\$\{/g,'\\${')
103+
.replaceAll(/[{}]/g,(m)=>'\\'+m)
104+
98105
constescapeMarkdown=(text)=>{
99106
if(typeoftext!=='string')returntext
100-
returntext
101-
.replaceAll(/(<)/g,String.raw`\$1`)
102-
.replaceAll('\n','<br/>')
103-
.replaceAll(/`([^`]+)`/g,'<code>{`$1`}</code>')
107+
108+
letout=text
109+
110+
// 1) przypadek template literal: `... `...``
111+
out=out.replace(/`([\s\S]*?)``/g,(_,raw)=>{
112+
constsafe=escInsideCode(raw)
113+
return`<code>{\`${safe}\`}</code>`
114+
})
115+
116+
// 2) przypadek listowych wartości: `...` przed przecinkiem albo końcem
117+
out=out.replace(/`([^`]+?)`(?=\s*,|\s*$)/g,'<code>{`$1`}</code>')
118+
119+
returnout
104120
}
105121

106122
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp