mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 19:17:03 +00:00
changes
This commit is contained in:
1 parent
11df8697b1
commit
c090fb595f
61 files changed
+52534
-107
No files matched your search
+10
-4
@@ -132,17 +132,23 @@ function figure(node: JSONContent, paths: Map<string, string>): string {
|
||||
return `<figure class="placement-${attr(placement)}"${style}><img src="${attr(path)}" alt="${alt}"/>${caption}</figure>`;
|
||||
}
|
||||
|
||||
function alignStyle(align: unknown): string {
|
||||
return align === "center" || align === "right" ? ` style="text-align:${align}"` : "";
|
||||
}
|
||||
|
||||
function block(node: JSONContent, paths: Map<string, string>): string {
|
||||
switch (node.type) {
|
||||
case "paragraph": {
|
||||
const body = inlines(node.content);
|
||||
if (!body.trim()) return "<p> </p>";
|
||||
const align = node.attrs?.align;
|
||||
if (align === "center" || align === "right") return `<p${alignStyle(align)}>${body}</p>`;
|
||||
return `<p${node.attrs?.indent ? ' data-indent="true"' : ""}>${body}</p>`;
|
||||
}
|
||||
case "heading":
|
||||
return node.attrs?.level === 3
|
||||
? `<h3>${inlines(node.content)}</h3>`
|
||||
: `<h2>${inlines(node.content)}</h2>`;
|
||||
case "heading": {
|
||||
const tag = node.attrs?.level === 3 ? "h3" : "h2";
|
||||
return `<${tag}${alignStyle(node.attrs?.align)}>${inlines(node.content)}</${tag}>`;
|
||||
}
|
||||
case "blockquote":
|
||||
return `<blockquote>${(node.content ?? []).map((n) => block(n, paths)).join("")}</blockquote>`;
|
||||
case "bulletList":
|
||||
|
||||
Reference in new issue
Block a user