Skip to content

Commit

Permalink
feat(writer-markdown): omit escape
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Nov 12, 2024
1 parent 2497b1a commit 78a97e5
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 136 deletions.
8 changes: 2 additions & 6 deletions src/writer/writer-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ function formatPropType(type?: any) {
return `<code>${type.replace(/\|/g, "&#124;")}</code>`;
}

function escapeHtml(text: string) {
return text.replace(/\</g, "&lt;").replace(/\>/g, "&gt;");
}

function formatPropValue(value: any) {
if (value === undefined) return `<code>${value}</code>`;
return `<code>${value.replace(/`/g, "\\`").replace(/\|/g, "&#124;")}</code>`;
}

function formatPropDescription(description: any) {
if (description === undefined || description.trim().length === 0) return MD_TYPE_UNDEFINED;
return escapeHtml(description).replace(/\n/g, "<br />");
return description.replace(/\n/g, "<br />");
}

function formatSlotProps(props?: string) {
Expand All @@ -34,7 +30,7 @@ function formatSlotProps(props?: string) {

function formatSlotFallback(fallback?: string) {
if (fallback === undefined) return MD_TYPE_UNDEFINED;
return formatPropType(escapeHtml(fallback).replace(/\n/g, "<br />"));
return formatPropType(fallback).replace(/\n/g, "<br />");
}

function formatEventDetail(detail?: string) {
Expand Down
Loading

0 comments on commit 78a97e5

Please sign in to comment.