Improvements to #530 styling
This commit is contained in:
@@ -7,10 +7,18 @@ export type Tag = {
|
||||
} | string;
|
||||
|
||||
function htmlEscape(s: string): string {
|
||||
return s.replace(/&/g, "&")
|
||||
s = s.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
.replace(/"/g, """)
|
||||
.replace(/\n/g, "<br>");
|
||||
|
||||
let oldS = s;
|
||||
do {
|
||||
oldS = s;
|
||||
s = s.replace(/ /g, " ");
|
||||
} while (s !== oldS);
|
||||
return s;
|
||||
}
|
||||
|
||||
export function renderHtml(t: Tag | null): string {
|
||||
@@ -33,9 +41,9 @@ export function renderHtml(t: Tag | null): string {
|
||||
if (t.name === Fragment) {
|
||||
return body;
|
||||
}
|
||||
if (t.body) {
|
||||
return `<${t.name}${attrs}>${body}</${t.name}>`;
|
||||
} else {
|
||||
return `<${t.name}${attrs}/>`;
|
||||
}
|
||||
// if (t.body) {
|
||||
return `<${t.name}${attrs}>${body}</${t.name}>`;
|
||||
// } else {
|
||||
// return `<${t.name}${attrs}/>`;
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user