Skip to content

Commit d80e343

Browse files
committed
Support for inline enhanced markdown component
1 parent b703a59 commit d80e343

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

web/src/components/EnhancedMarkdown.astro

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { marked } from 'marked';
44
55
interface Props {
66
content: string;
7+
inline?: boolean;
78
}
89
9-
const { content } = Astro.props;
10+
const { content, inline = false } = Astro.props;
1011
1112
1213
// We shouldn't this as we're now organizing pages in folders
@@ -23,14 +24,19 @@ function convertMediaWikiLinks(text: string): string {
2324
}
2425
2526
const processedContent = convertMediaWikiLinks(content);
26-
const tokens = marked.lexer(processedContent);
27+
const tokens = inline ? marked.Lexer.lexInline(processedContent) : marked.lexer(processedContent);
2728
---
2829

2930
{
3031
tokens.map((token) => {
3132
if (token.type === 'code') {
3233
return <Code code={token.text} lang={token.lang || 'text'} />;
3334
}
35+
36+
if (inline) {
37+
return <Fragment set:html={marked.parseInline(token.raw ?? token.text ?? '')} />;
38+
}
39+
3440
return <Fragment set:html={marked.parser([token])} />;
3541
})
3642
}

web/src/pages/reference/[func].astro

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
142142
const showUpdated = !!updatedVersion && isVersionLE(CURRENT, updatedVersion);
143143
const showRemoved = !!removedVersionRaw;
144144

145-
// Jeśli nie ma nic do pokazania
146145
if (!showRemoved && !showAdded && !showUpdated) {
147146
return (
148147
<ItemDescription
@@ -261,9 +260,10 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
261260
{syntax.parameters
262261
.filter((param: any) => !param.default)
263262
.map((param: any) => (
264-
<li
265-
set:html={`<strong>${param.name}</strong>: ${renderInlineMarkdown(param.description)}`}
266-
/>
263+
<li>
264+
<strong>{param.name}</strong>:
265+
<EnhancedMarkdown content={param.description} inline={true}/>
266+
</li>
267267
))}
268268
</ul>
269269
</>
@@ -273,15 +273,14 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
273273
<>
274274
<h5>Optional Arguments</h5>
275275
<p><strong>NOTE</strong>: When using <a href="/reference/Optional_Arguments">optional arguments</a>, you might need to supply all arguments before the one you wish to use.</p>
276-
<ul>
276+
<ul style="margin-top: 0;">
277277
{syntax.parameters
278278
.filter((param: any) => param.default)
279279
.map((param: any) => (
280-
<li
281-
set:html={
282-
`<strong>${param.name}</strong> (default: <em>${param.default}</em>): ${renderInlineMarkdown(param.description)}`
283-
}
284-
/>
280+
<li>
281+
<strong>{param.name}</strong> (default: <em>{param.default}</em>):
282+
<EnhancedMarkdown content={param.description} inline={true}/>
283+
</li>
285284
))}
286285
</ul>
287286
</>

web/src/utils/general.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ export function extractVersion(versionString: string): string | null {
243243
}
244244

245245
export function isVersionLE(v: string, ref: string): boolean {
246-
console.log(v, ref);
247246
const toNums = (str: string) => str.split('.').map(n => parseInt(n, 10));
248247
const [a1, a2, a3] = toNums(v);
249248
const [b1, b2, b3] = toNums(ref);

0 commit comments

Comments
 (0)