Use serif font for Typst specification export

This commit is contained in:
Ruslan Bakiev
2026-05-04 10:38:35 +07:00
parent bbd9dcfb5a
commit 234f46c082

View File

@@ -45,7 +45,13 @@ function escapeTypstString(value) {
}
function escapeContentBlock(value) {
return value.replaceAll('[', '\\[').replaceAll(']', '\\]');
return value
.replaceAll('\\', '\\\\')
.replaceAll('[', '\\[')
.replaceAll(']', '\\]')
.replaceAll('*', '\\*')
.replaceAll('#', '\\#')
.replaceAll('@', '\\@');
}
function inlineTypst(value) {
@@ -54,7 +60,10 @@ function inlineTypst(value) {
text = text.replaceAll('<br>', ' ');
text = text.replaceAll('<br/>', ' ');
text = text.replaceAll('&nbsp;', ' ');
text = text.replace(/\*\*([^*]+)\*\*/g, '*$1*');
text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
text = text.replace(/`([^`]+)`/g, '$1');
text = text.replaceAll('*', '\\*');
text = text.replaceAll('@', '\\@');
text = text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, label, href) => {
if (href.startsWith('http://') || href.startsWith('https://')) {
return `#link("${escapeTypstString(href)}")[${escapeContentBlock(label)}]`;
@@ -243,13 +252,14 @@ function typstDocument(body) {
header: align(right)[#text(size: 8pt, fill: rgb("#667085"))[Личный кабинет Фрегат]],
footer: align(center)[#text(size: 8pt, fill: rgb("#667085"))[#context counter(page).display("1")]],
)
#set text(font: "Arial", size: 10pt, lang: "ru")
#set text(font: "Times New Roman", size: 10.5pt, lang: "ru")
#set par(justify: true, leading: 0.58em, first-line-indent: 0pt)
#set list(indent: 13pt, body-indent: 5pt)
#show link: underline
#show heading.where(level: 1): set text(size: 15pt, weight: "bold")
#show heading.where(level: 2): set text(size: 12pt, weight: "bold")
#show heading.where(level: 3): set text(size: 10.5pt, weight: "bold")
#show raw: set text(font: "Times New Roman")
#show heading.where(level: 1): set text(size: 16pt, weight: "bold")
#show heading.where(level: 2): set text(size: 13pt, weight: "bold")
#show heading.where(level: 3): set text(size: 11.5pt, weight: "bold")
#show heading: it => block(above: 1.15em, below: 0.55em, it)
#align(center)[