Skip to content

contributing Typst snippets #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@
"language": "shelldoc",
"path": "./snippets/shell/shelldoc.json"
},
{
"language": ["typst"],
"path": "./snippets/typst/layout.json"
},
{
"language": ["typst"],
"path": "./snippets/typst/visualize.json"
},
{
"language": ["typst"],
"path": "./snippets/typst/markup.json"
},
{
"language": ["typst"],
"path": "./snippets/typst/maths.json"
},
{
"language": ["markdown", "rmd"],
"path": "./snippets/markdown.json"
Expand Down
67 changes: 67 additions & 0 deletions snippets/typst/layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"align center": {
"prefix": "align.c",
"body": [
"#align(center)[",
" ${0:para}",
"]"
],
"description": "Align contents center."
},
"align right bottom": {
"prefix": "align.r.b",
"body": [
"#align(right + bottom)[",
" ${0:para}",
"]"
],
"description": "Align contents towards right bottom."
},
"block": {
"prefix": "block",
"body": [
"#block(",
" fill: luma(230),",
" inset: 8pt,",
" radius: 4pt,",
")[${0:text}]"
],
"description": "A block-level container."
},
"box": {
"prefix": "box",
"body": [
"#box(",
" inset: 4pt,",
")[${0:text}]"
],
"description": "An inline-level container that sizes content."
},
"pagebreak": {
"prefix": "pagebreak",
"body": [
"#pagebreak(",
" weak: false,",
" to: \"${0:odd}\",",
")"
],
"description": [
"A manual page break.",
" ",
"Must not be used inside any containers.",
" ",
"PARAMETERS:",
" ",
"weak: bool",
" ",
"If true, the page break is skipped if the current page is already empty.",
" ",
"Default: false",
" ",
"to: none or str",
" ",
"If given, ensures that the next page will be an even/odd page, with an empty page in between if necessary.",
" "
]
}
}
168 changes: 168 additions & 0 deletions snippets/typst/markup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"header 1": {
"prefix": "h1",
"body": ["= ${0}"],
"description": "Add header level 1"
},
"header 2": {
"prefix": "h2",
"body": ["== ${0}"],
"description": "Add header level 2"
},
"header 3": {
"prefix": "h3",
"body": ["=== ${0}"],
"description": "Add header level 3"
},
"header 4": {
"prefix": "h4",
"body": ["==== ${0}"],
"description": "Add header level 4"
},
"header 5": {
"prefix": "h5",
"body": ["===== ${0}"],
"description": "Add header level 5"
},
"header 6": {
"prefix": "h6",
"body": ["====== ${0}"],
"description": "Add header level 6"
},
"Strong emphasis": {
"prefix": "emp",
"body": ["*${0}*"],
"description": "Strong emphasis"
},
"Emphasis": {
"prefix": "emp",
"body": ["_${0}_"],
"description": "emphasis"
},
"Raw text": {
"prefix": "raw",
"body": ["`${0}`"],
"description": "Raw text"
},
"Label": {
"prefix": "lable",
"body": ["<${0}>"],
"description": "Label"
},
"Reference": {
"prefix": "reference",
"body": ["@${0}"],
"description": "Reference"
},
"Links": {
"prefix": ["l", "link"],
"body": ["#link(${1:url})[${2:test}] ${0}"],
"description": "Add links\n\nexample:\n\n#link(\"https://example.com\")[repo link]\n\nsnippet:\n"
},
"Internal Links": {
"prefix": ["l", "link_internal"],
"body": ["#link((${1:page: 1, x: 0pt, y: 0pt}))[${2:test}] ${0}"],
"description": "add internal links"
},
"Lable Links": {
"prefix": ["l", "link_label"],
"body": ["#link(<${1:intro}>)[${2:Go to intro}] ${0}"],
"description": "add lable links"
},
"Bullet list": {
"prefix": ["list.b"],
"body": [
"- ${0: item}"
],
"description": "add Bullet list"
},
"2 Bullet list": {
"prefix": ["list.b.2"],
"body": [
"- ${0: item}",
"- ${1: item}"
],
"description": "add 2 Bullet list"
},
"3 Bullet list": {
"prefix": ["list.b.3"],
"body": [
"- ${0: item}",
"- ${1: item}",
"- ${2: item}"
],
"description": "add 3 Bullet list"
},
"4 Bullet list": {
"prefix": ["list.b.4"],
"body": [
"- ${0: item}",
"- ${1: item}",
"- ${2: item}",
"- ${3: item}"
],
"description": "add 4 Bullet list"
},
"Numbered list": {
"prefix": ["list.n"],
"body": [
"+ ${0: item}"
],
"description": "add Numbered list"
},
"2 Numbered list": {
"prefix": ["list.n.2"],
"body": [
"+ ${0: item}",
"+ ${1: item}"
],
"description": "add 2 Numbered list"
},
"3 Numbered list": {
"prefix": ["list.n.3"],
"body": [
"+ ${0: item}",
"+ ${1: item}",
"+ ${2: item}"
],
"description": "add 3 Numbered list"
},
"4 Numbered list": {
"prefix": ["list.n.4"],
"body": [
"+ ${0: item}",
"+ ${1: item}",
"+ ${2: item}",
"+ ${3: item}"
],
"description": "add 4 Numbered list"
},
"Term list": {
"prefix": ["term.list", "list.term"],
"body": [
"/ Term: ${0: description}"
],
"description": "add Term list"
},
"Math": {
"prefix": ["maths"],
"body": [
"$${0:x^2}$"
],
"description": "maths block"
},
"Comment block": {
"prefix": ["comment.b"],
"body": [
"/* ${0:comment} */"
],
"description": "Comment block"
},
"Comment line": {
"prefix": ["comment.l"],
"body": [
"// ${0:comment}"
],
"description": "Comment line"
}
}
34 changes: 34 additions & 0 deletions snippets/typst/maths.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cases": {
"prefix": ["cases", "maths.cases"],
"body": [
"$ f(x, y) := cases(",
" 1 \"if\" (x dot y)/2 <= 0,",
" 2 \"if\" x \"is even\",",
" 3 \"if\" x in NN,",
" 4 \"else\",",
") $"
],
"description": [
"A case distinction.",
" ",
"Content across different branches can be aligned with the & symbol."
]
},
"equation": {
"prefix": ["equation", "maths.equation"],
"body": [
"$ sum_(k=1)^n k = (n(n+1)) / 2 $"
],
"description": [
"A mathematical equation.",
" ",
"Can be displayed inline with text or as a separate block."
]
},
"frac": {
"prefix": ["frac", "maths.frac"],
"body": ["$ ((${0:x}+1)) / 2 = frac(a, b) $"],
"description": "A mathematical fraction."
}
}
44 changes: 44 additions & 0 deletions snippets/typst/visualize.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"Images": {
"prefix": "img",
"body": [
"#image(\"${1:img.png}\", ${2:width: 80%})"
],
"description": "Add images"
},
"Figure Images": {
"prefix": ["img_figure", "figure_img"],
"body": [
"#figure(",
" image(\"${1:img.png}\", ${2:width: 80%}),",
" cation: [",
" ${0: cation}",
" ],",
")"
],
"description": "Add images with figure"
},
"highlight": {
"prefix": "highlight",
"body": ["#highlight[${0: important}]"],
"description": "Add highlight"
},
"highlight full": {
"prefix": "highlight.full",
"body": [
"#highlight(",
" fill: blue,",
" stroke: fuchsia,",
" extent: 4pt,",
" radius: 5pt,",
" top-edge: \"ascender\",",
" bottom-edge: \"descender\",",
")[${0: important}]"],
"description": "Add highlight with full options"
},
"lorem": {
"prefix": "lorem",
"body": ["#lorem(${0: num})"],
"description": "This function yields a Latin-like Lorem Ipsum blind text with the given number of words."
}
}