docs(component-index): escape description

This commit is contained in:
Eric Liu 2020-10-16 14:30:53 -07:00
commit 0472c1ad23
2 changed files with 1014 additions and 1012 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,8 @@ const toMdLink = (text) => `[${text}](#${toLink(text)})`;
const formatType = (type) => `<code>${type.replace(/\|/g, "&#124;")}</code>`; const formatType = (type) => `<code>${type.replace(/\|/g, "&#124;")}</code>`;
const escapeHtml = (text) => text.replace(/\</g, "&lt;").replace(/\>/g, "&gt;");
const HEADER_PROPS = const HEADER_PROPS =
"| Prop name | Type | Default value | Description |\n| :- | :- | :- | :- |\n"; "| Prop name | Type | Default value | Description |\n| :- | :- | :- | :- |\n";
@ -64,8 +66,8 @@ export function generateIndex(components, groups, pkg) {
code += `| ${name}${ code += `| ${name}${
prop.kind === "const" ? " (`constant`)" : "" prop.kind === "const" ? " (`constant`)" : ""
} | ${formatType(prop.type)} | ${ } | ${formatType(prop.type)} | ${
prop.value || "--" prop.value ? "`" + prop.value + "`" : "--"
} | ${prop.description.replace(/\n/g, ". ")} |\n`; } | ${escapeHtml(prop.description).replace(/\n/g, ". ")}. |\n`;
}); });
} else { } else {
code += "No exported props.\n\n"; code += "No exported props.\n\n";