Last active
March 26, 2025 16:49
-
-
Save hongjr03/3f2a318b2ffb9d005f5932ce98dfae45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#let typ(body) = html.elem( | |
"typ", | |
{ | |
// distinguish parbreak from <p> tag | |
show parbreak: it => html.elem("typParbreak", "") | |
show linebreak: it => html.elem("typLinebreak", "") | |
show strong: it => html.elem("typStrong", it.body) | |
show emph: it => html.elem("typEmph", it.body) | |
show highlight: it => html.elem("typHighlight", it.body) | |
show strike: it => html.elem("typStrike", it.body) | |
show raw.where(block: false): it => html.elem("typRawInline", "`" + it.text + "`") | |
show raw.where(block: true): it => html.elem("typRawBlock", attrs: (lang: it.lang), it) | |
show link: it => html.elem("typLink", attrs: (target: it.dest), it.body) | |
// show label: it => html.elem("typLabel", it) | |
show ref: it => html.elem("typRef", it) | |
show heading: it => html.elem("typHeading", attrs: (level: str(it.level)), it) | |
show outline: it => html.elem( | |
"typOutline", | |
it, | |
) | |
show outline.entry: it => html.elem( | |
"typOutlineEntry", | |
attrs: (level: str(it.level)), | |
it.element, | |
) | |
// list | |
// enum | |
// term | |
show quote: it => html.elem( | |
"typQuote", | |
attrs: ( | |
attribution: it.attribution, | |
), | |
it.body, | |
) | |
show table: it => html.elem( | |
"typTable", | |
attrs: ( | |
columns: { | |
let columns = it.columns | |
if type(columns) == array { | |
str(columns.len()) | |
} else if type(columns) == int { | |
str(columns) | |
} else { | |
error("Invalid columns type") | |
} | |
}, | |
), | |
{ | |
it | |
.children | |
.map(cell => html.elem( | |
"typTableCell", | |
attrs: ( | |
colspan: str(cell.fields().at("colspan", default: 1)), | |
rowspan: str(cell.fields().at("rowspan", default: 1)), | |
), | |
cell, | |
)) | |
.join() | |
}, | |
) | |
show grid: it => html.elem( | |
"typGrid", | |
attrs: ( | |
columns: { | |
let columns = it.columns | |
if type(columns) == array { | |
str(columns.len()) | |
} else if type(columns) == int { | |
str(columns) | |
} else { | |
error("Invalid columns type") | |
} | |
}, | |
), | |
{ | |
it | |
.children | |
.map(cell => html.elem( | |
"typGridCell", | |
attrs: ( | |
colspan: str(cell.fields().at("colspan", default: 1)), | |
rowspan: str(cell.fields().at("rowspan", default: 1)), | |
), | |
cell, | |
)) | |
.join() | |
}, | |
) | |
// show math.equation.where(block: false): it => html.elem("typEquationInline", html.frame(it)) | |
// show math.equation.where(block: true): it => html.elem("typEquationBlock", html.frame(it)) | |
body | |
}, | |
) | |
#show: typ | |
#outline() | |
== Heading 1 | |
=== Heading 2 | |
#link("https://example.com")[ | |
This is a link to example.com | |
] | |
Inline `code` has `back-ticks around` it. | |
```cs | |
using System.IO.Compression; | |
#pragma warning disable 414, 3021 | |
namespace MyApplication | |
{ | |
[Obsolete("...")] | |
class Program : IInterface | |
{ | |
public static List<int> JustDoIt(int count) | |
{ | |
Console.WriteLine($"Hello {Name}!"); | |
return new List<int>(new int[] { 1, 2, 3 }) | |
} | |
} | |
} | |
``` | |
Math inline: $E = m c^2$ and block: | |
$ | |
E = m c^2 | |
$ | |
- First item | |
- Second item | |
+ First sub-item | |
+ Second sub-item | |
- First sub-sub-item | |
/ First term: First definition | |
#table( | |
columns: (1em,) * 20, | |
..range(20).map(x => [#x]), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment