mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: bump typst to v0.14.0 (#2201)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
Co-authored-by: paran3xus <paran3xus007@gmail.com>
This commit is contained in:
parent
a6c39d4306
commit
f011022097
131 changed files with 1671 additions and 1501 deletions
1041
Cargo.lock
generated
1041
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
86
Cargo.toml
86
Cargo.toml
|
|
@ -41,7 +41,7 @@ walkdir = "2"
|
||||||
chrono = { version = "0.4", default-features = false }
|
chrono = { version = "0.4", default-features = false }
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
dirs = "6"
|
dirs = "6"
|
||||||
fontdb = "0.21"
|
fontdb = { version = "0.23", default-features = false }
|
||||||
notify = "6"
|
notify = "6"
|
||||||
path-clean = "1.0.1"
|
path-clean = "1.0.1"
|
||||||
windows-sys = "0.59"
|
windows-sys = "0.59"
|
||||||
|
|
@ -49,6 +49,7 @@ tempfile = "3.19.1"
|
||||||
same-file = "1.0.6"
|
same-file = "1.0.6"
|
||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
core-foundation = { version = "0.10.0", features = ["mac_os_10_7_support"] }
|
core-foundation = { version = "0.10.0", features = ["mac_os_10_7_support"] }
|
||||||
|
half = "=2.6.0"
|
||||||
|
|
||||||
# Web
|
# Web
|
||||||
js-sys = "^0.3"
|
js-sys = "^0.3"
|
||||||
|
|
@ -84,7 +85,7 @@ fastrand = "2.3.0"
|
||||||
|
|
||||||
# Data Structures
|
# Data Structures
|
||||||
bitvec = "1"
|
bitvec = "1"
|
||||||
comemo = "0.4"
|
comemo = "0.5.0"
|
||||||
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
||||||
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
||||||
ecow = "0.2.3"
|
ecow = "0.2.3"
|
||||||
|
|
@ -101,7 +102,7 @@ cmark-writer = { version = "0.9.0", features = [
|
||||||
"gfm",
|
"gfm",
|
||||||
], path = "crates/cmark-writer" }
|
], path = "crates/cmark-writer" }
|
||||||
docx-rs = { version = "0.4.18-rc19", git = "https://github.com/Myriad-Dreamin/docx-rs", default-features = false, rev = "db49a729f68dbdb9e8e91857fbb1c3d414209871" }
|
docx-rs = { version = "0.4.18-rc19", git = "https://github.com/Myriad-Dreamin/docx-rs", default-features = false, rev = "db49a729f68dbdb9e8e91857fbb1c3d414209871" }
|
||||||
hayagriva = "0.8"
|
hayagriva = "0.9.1"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
flate2 = "1"
|
flate2 = "1"
|
||||||
# typst can only support these formats.
|
# typst can only support these formats.
|
||||||
|
|
@ -128,7 +129,7 @@ toml = { version = "0.8", default-features = false, features = [
|
||||||
"parse",
|
"parse",
|
||||||
"display",
|
"display",
|
||||||
] }
|
] }
|
||||||
ttf-parser = "0.24.1"
|
ttf-parser = "0.25.0"
|
||||||
unicode-script = "0.5"
|
unicode-script = "0.5"
|
||||||
unscanny = "0.1"
|
unscanny = "0.1"
|
||||||
yaml-rust2 = "0.9"
|
yaml-rust2 = "0.9"
|
||||||
|
|
@ -145,17 +146,17 @@ reflexo = { version = "=0.6.1-rc4", default-features = false, features = [
|
||||||
reflexo-typst = { version = "=0.6.1-rc4", default-features = false }
|
reflexo-typst = { version = "=0.6.1-rc4", default-features = false }
|
||||||
reflexo-vec2svg = { version = "=0.6.1-rc4" }
|
reflexo-vec2svg = { version = "=0.6.1-rc4" }
|
||||||
|
|
||||||
typst = "0.13.1"
|
typst = "0.14.0"
|
||||||
typst-html = "0.13.1"
|
typst-html = "0.14.0"
|
||||||
typst-library = "0.13.1"
|
typst-library = "0.14.0"
|
||||||
typst-macros = "0.13.1"
|
typst-macros = "0.14.0"
|
||||||
typst-timing = "0.13.1"
|
typst-timing = "0.14.0"
|
||||||
typst-svg = "0.13.1"
|
typst-svg = "0.14.0"
|
||||||
typst-render = "0.13.1"
|
typst-render = "0.14.0"
|
||||||
typst-pdf = "0.13.1"
|
typst-pdf = "0.14.0"
|
||||||
typst-syntax = "0.13.1"
|
typst-syntax = "0.14.0"
|
||||||
typst-eval = "0.13.1"
|
typst-eval = "0.14.0"
|
||||||
typst-assets = "0.13.1"
|
typst-assets = "0.14.0"
|
||||||
typstfmt = { version = "0", git = "https://github.com/Myriad-Dreamin/typstfmt", tag = "v0.13.1" }
|
typstfmt = { version = "0", git = "https://github.com/Myriad-Dreamin/typstfmt", tag = "v0.13.1" }
|
||||||
typst-ansi-hl = "0.4.0"
|
typst-ansi-hl = "0.4.0"
|
||||||
typstyle-core = { version = "=0.13.17", default-features = false }
|
typstyle-core = { version = "=0.13.17", default-features = false }
|
||||||
|
|
@ -188,17 +189,17 @@ insta-cmd = "0.6.0"
|
||||||
|
|
||||||
|
|
||||||
# Our Own Crates
|
# Our Own Crates
|
||||||
tinymist-assets = { version = "=0.13.30" }
|
tinymist-assets = { version = "=0.13.29-rc1" }
|
||||||
|
|
||||||
tinymist-derive = { path = "./crates/tinymist-derive/", version = "0.13.30" }
|
tinymist-derive = { path = "./crates/tinymist-derive/", version = "0.14.0-rc1" }
|
||||||
tinymist-l10n = { path = "./crates/tinymist-l10n/", version = "0.13.30" }
|
tinymist-l10n = { path = "./crates/tinymist-l10n/", version = "0.14.0-rc1" }
|
||||||
tinymist-package = { path = "./crates/tinymist-package/", version = "0.13.30" }
|
tinymist-package = { path = "./crates/tinymist-package/", version = "0.14.0-rc1" }
|
||||||
tinymist-std = { path = "./crates/tinymist-std/", version = "0.13.30", default-features = false }
|
tinymist-std = { path = "./crates/tinymist-std/", version = "0.14.0-rc1", default-features = false }
|
||||||
tinymist-vfs = { path = "./crates/tinymist-vfs/", version = "0.13.30", default-features = false }
|
tinymist-vfs = { path = "./crates/tinymist-vfs/", version = "0.14.0-rc1", default-features = false }
|
||||||
tinymist-world = { path = "./crates/tinymist-world/", version = "0.13.30", default-features = false }
|
tinymist-world = { path = "./crates/tinymist-world/", version = "0.14.0-rc1", default-features = false }
|
||||||
tinymist-project = { path = "./crates/tinymist-project/", version = "0.13.30" }
|
tinymist-project = { path = "./crates/tinymist-project/", version = "0.14.0-rc1" }
|
||||||
tinymist-task = { path = "./crates/tinymist-task/", version = "0.13.30" }
|
tinymist-task = { path = "./crates/tinymist-task/", version = "0.14.0-rc1" }
|
||||||
typst-shim = { path = "./crates/typst-shim", version = "0.13.30" }
|
typst-shim = { path = "./crates/typst-shim", version = "0.14.0-rc1" }
|
||||||
|
|
||||||
tinymist-tests = { path = "./crates/tinymist-tests/" }
|
tinymist-tests = { path = "./crates/tinymist-tests/" }
|
||||||
|
|
||||||
|
|
@ -278,16 +279,19 @@ extend-exclude = ["/.git", "fixtures"]
|
||||||
# These patches use a different version of `typst`, which only exports some private functions and information for code analysis.
|
# These patches use a different version of `typst`, which only exports some private functions and information for code analysis.
|
||||||
#
|
#
|
||||||
# A regular build MUST use `tag` or `rev` to specify the version of the patched crate to ensure stability.
|
# A regular build MUST use `tag` or `rev` to specify the version of the patched crate to ensure stability.
|
||||||
typst = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-macros = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-macros = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-library = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-library = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-html = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-html = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-timing = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-timing = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-svg = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-svg = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-render = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-render = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-pdf = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-pdf = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-syntax = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-syntax = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
typst-eval = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinymist/v0.13.10" }
|
typst-eval = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f" }
|
||||||
|
|
||||||
|
# typst-ansi-hl = { git = "https://github.com/ParaN3xus/typst-ansi-hl.git", branch = "nightly" }
|
||||||
|
typstyle-core = { git = "https://github.com/ParaN3xus/typstyle/", branch = "nightly" }
|
||||||
|
|
||||||
# These patches use local `typst` for development.
|
# These patches use local `typst` for development.
|
||||||
# typst = { path = "../typst/crates/typst" }
|
# typst = { path = "../typst/crates/typst" }
|
||||||
|
|
@ -297,18 +301,20 @@ typst-eval = { git = "https://github.com/Myriad-Dreamin/typst.git", tag = "tinym
|
||||||
# typst-render = { path = "../typst/crates/typst-render" }
|
# typst-render = { path = "../typst/crates/typst-render" }
|
||||||
# typst-syntax = { path = "../typst/crates/typst-syntax" }
|
# typst-syntax = { path = "../typst/crates/typst-syntax" }
|
||||||
|
|
||||||
|
# These patches use local `typstyle-core` for development.
|
||||||
|
# typstyle-core = { path = "../typstyle/crates/typstyle-core" }
|
||||||
|
|
||||||
# These patches use a different version of `reflexo`.
|
# These patches use a different version of `reflexo`.
|
||||||
#
|
#
|
||||||
# A regular build MUST use `tag` or `rev` to specify the version of the patched crate to ensure stability.
|
# A regular build MUST use `tag` or `rev` to specify the version of the patched crate to ensure stability.
|
||||||
# reflexo = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "3eeb078e2a21caf8256585e4f533df1810c33a09" }
|
reflexo = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "d6f553b832e45790e85af5e2929ceeb8bb0b097b" }
|
||||||
# reflexo-typst = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "3eeb078e2a21caf8256585e4f533df1810c33a09" }
|
reflexo-typst = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "d6f553b832e45790e85af5e2929ceeb8bb0b097b" }
|
||||||
# reflexo-vec2svg = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "3eeb078e2a21caf8256585e4f533df1810c33a09" }
|
reflexo-vec2svg = { git = "https://github.com/Myriad-Dreamin/typst.ts/", rev = "d6f553b832e45790e85af5e2929ceeb8bb0b097b" }
|
||||||
|
|
||||||
# These patches use local `reflexo` for development.
|
# These patches use local `reflexo` for development.
|
||||||
# reflexo = { path = "../typst.ts/crates/reflexo/" }
|
# reflexo = { path = "../typst.ts/crates/reflexo/" }
|
||||||
# reflexo-typst = { path = "../typst.ts/crates/reflexo-typst/" }
|
# reflexo-typst = { path = "../typst.ts/crates/reflexo-typst/" }
|
||||||
# reflexo-vec2svg = { path = "../typst.ts/crates/conversion/vec2svg/" }
|
# reflexo-vec2svg = { path = "../typst.ts/crates/conversion/vec2svg/" }
|
||||||
# typstyle-core = { git = "https://github.com/ParaN3xus/typstyle/", tag = "tinymist-nightly-v0.12.21-rc1" }
|
|
||||||
|
|
||||||
typst-shim = { path = "crates/typst-shim" }
|
typst-shim = { path = "crates/typst-shim" }
|
||||||
tinymist-analysis = { path = "crates/tinymist-analysis" }
|
tinymist-analysis = { path = "crates/tinymist-analysis" }
|
||||||
|
|
@ -319,7 +325,7 @@ tinymist-project = { path = "crates/tinymist-project" }
|
||||||
tinymist-task = { path = "crates/tinymist-task" }
|
tinymist-task = { path = "crates/tinymist-task" }
|
||||||
|
|
||||||
# If reflexo use the tinymist from git, you should use the following patch.
|
# If reflexo use the tinymist from git, you should use the following patch.
|
||||||
# [patch."https://github.com/Myriad-Dreamin/tinymist.git"]
|
# [patch."https://github.com/ParaN3xus/tinymist.git"]
|
||||||
# typst-shim = { path = "crates/typst-shim" }
|
# typst-shim = { path = "crates/typst-shim" }
|
||||||
# tinymist-analysis = { path = "crates/tinymist-analysis" }
|
# tinymist-analysis = { path = "crates/tinymist-analysis" }
|
||||||
# tinymist-std = { path = "crates/tinymist-std" }
|
# tinymist-std = { path = "crates/tinymist-std" }
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ tinymist-std.workspace = true
|
||||||
tinymist-project = { workspace = true, features = ["lsp"] }
|
tinymist-project = { workspace = true, features = ["lsp"] }
|
||||||
typst.workspace = true
|
typst.workspace = true
|
||||||
typst-syntax.workspace = true
|
typst-syntax.workspace = true
|
||||||
|
half.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
insta.workspace = true
|
insta.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -43,14 +43,14 @@ pub fn to_typst_position(
|
||||||
lsp_position_encoding: PositionEncoding,
|
lsp_position_encoding: PositionEncoding,
|
||||||
typst_source: &Source,
|
typst_source: &Source,
|
||||||
) -> Option<usize> {
|
) -> Option<usize> {
|
||||||
let lines = typst_source.len_lines() as u32;
|
let lines = typst_source.lines().len_lines() as u32;
|
||||||
|
|
||||||
'bound_checking: {
|
'bound_checking: {
|
||||||
let should_warning = match lsp_position.line.cmp(&lines) {
|
let should_warning = match lsp_position.line.cmp(&lines) {
|
||||||
Ordering::Greater => true,
|
Ordering::Greater => true,
|
||||||
Ordering::Equal => lsp_position.character > 0,
|
Ordering::Equal => lsp_position.character > 0,
|
||||||
Ordering::Less if lsp_position.line + 1 == lines => {
|
Ordering::Less if lsp_position.line + 1 == lines => {
|
||||||
let last_line_offset = typst_source.line_to_byte(lines as usize - 1)?;
|
let last_line_offset = typst_source.lines().line_to_byte(lines as usize - 1)?;
|
||||||
let last_line_chars = &typst_source.text()[last_line_offset..];
|
let last_line_chars = &typst_source.text()[last_line_offset..];
|
||||||
let len = match lsp_position_encoding {
|
let len = match lsp_position_encoding {
|
||||||
PositionEncoding::Utf8 => last_line_chars.len(),
|
PositionEncoding::Utf8 => last_line_chars.len(),
|
||||||
|
|
@ -72,19 +72,23 @@ pub fn to_typst_position(
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"LSP position is out of bounds: {:?}, while only {:?} lines and {:?} characters at the end.",
|
"LSP position is out of bounds: {:?}, while only {:?} lines and {:?} characters at the end.",
|
||||||
lsp_position,
|
lsp_position,
|
||||||
typst_source.len_lines(),
|
typst_source.lines().len_lines(),
|
||||||
typst_source.line_to_range(typst_source.len_lines() - 1),
|
typst_source
|
||||||
|
.lines()
|
||||||
|
.line_to_range(typst_source.lines().len_lines() - 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(typst_source.len_bytes());
|
return Some(typst_source.lines().len_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
match lsp_position_encoding {
|
match lsp_position_encoding {
|
||||||
PositionEncoding::Utf8 => {
|
PositionEncoding::Utf8 => {
|
||||||
let line_index = lsp_position.line as usize;
|
let line_index = lsp_position.line as usize;
|
||||||
let column_index = lsp_position.character as usize;
|
let column_index = lsp_position.character as usize;
|
||||||
typst_source.line_column_to_byte(line_index, column_index)
|
typst_source
|
||||||
|
.lines()
|
||||||
|
.line_column_to_byte(line_index, column_index)
|
||||||
}
|
}
|
||||||
PositionEncoding::Utf16 => {
|
PositionEncoding::Utf16 => {
|
||||||
// We have a line number and a UTF-16 offset into that line. We want a byte
|
// We have a line number and a UTF-16 offset into that line. We want a byte
|
||||||
|
|
@ -108,11 +112,11 @@ pub fn to_typst_position(
|
||||||
let line_index = lsp_position.line as usize;
|
let line_index = lsp_position.line as usize;
|
||||||
let utf16_offset_in_line = lsp_position.character as usize;
|
let utf16_offset_in_line = lsp_position.character as usize;
|
||||||
|
|
||||||
let byte_line_offset = typst_source.line_to_byte(line_index)?;
|
let byte_line_offset = typst_source.lines().line_to_byte(line_index)?;
|
||||||
let utf16_line_offset = typst_source.byte_to_utf16(byte_line_offset)?;
|
let utf16_line_offset = typst_source.lines().byte_to_utf16(byte_line_offset)?;
|
||||||
let utf16_offset = utf16_line_offset + utf16_offset_in_line;
|
let utf16_offset = utf16_line_offset + utf16_offset_in_line;
|
||||||
|
|
||||||
typst_source.utf16_to_byte(utf16_offset)
|
typst_source.lines().utf16_to_byte(utf16_offset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,12 +127,12 @@ pub fn to_lsp_position(
|
||||||
lsp_position_encoding: PositionEncoding,
|
lsp_position_encoding: PositionEncoding,
|
||||||
typst_source: &Source,
|
typst_source: &Source,
|
||||||
) -> LspPosition {
|
) -> LspPosition {
|
||||||
if typst_offset > typst_source.len_bytes() {
|
if typst_offset > typst_source.lines().len_bytes() {
|
||||||
return LspPosition::new(typst_source.len_lines() as u32, 0);
|
return LspPosition::new(typst_source.lines().len_lines() as u32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let line_index = typst_source.byte_to_line(typst_offset).unwrap();
|
let line_index = typst_source.lines().byte_to_line(typst_offset).unwrap();
|
||||||
let column_index = typst_source.byte_to_column(typst_offset).unwrap();
|
let column_index = typst_source.lines().byte_to_column(typst_offset).unwrap();
|
||||||
|
|
||||||
let lsp_line = line_index as u32;
|
let lsp_line = line_index as u32;
|
||||||
let lsp_column = match lsp_position_encoding {
|
let lsp_column = match lsp_position_encoding {
|
||||||
|
|
@ -141,10 +145,13 @@ pub fn to_lsp_position(
|
||||||
// we need here. Submit a PR to `typst` to add it, then update
|
// we need here. Submit a PR to `typst` to add it, then update
|
||||||
// this if/when merged.
|
// this if/when merged.
|
||||||
|
|
||||||
let utf16_offset = typst_source.byte_to_utf16(typst_offset).unwrap();
|
let utf16_offset = typst_source.lines().byte_to_utf16(typst_offset).unwrap();
|
||||||
|
|
||||||
let byte_line_offset = typst_source.line_to_byte(line_index).unwrap();
|
let byte_line_offset = typst_source.lines().line_to_byte(line_index).unwrap();
|
||||||
let utf16_line_offset = typst_source.byte_to_utf16(byte_line_offset).unwrap();
|
let utf16_line_offset = typst_source
|
||||||
|
.lines()
|
||||||
|
.byte_to_utf16(byte_line_offset)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let utf16_column_offset = utf16_offset - utf16_line_offset;
|
let utf16_column_offset = utf16_offset - utf16_line_offset;
|
||||||
utf16_column_offset as u32
|
utf16_column_offset as u32
|
||||||
|
|
@ -233,7 +240,7 @@ mod test {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let res = to_typst_range(rng, PositionEncoding::Utf16, &source).unwrap();
|
let res = to_typst_range(rng, PositionEncoding::Utf16, &source).unwrap();
|
||||||
assert_eq!(res, 19..source.len_bytes());
|
assert_eq!(res, 19..source.lines().len_bytes());
|
||||||
// EOF
|
// EOF
|
||||||
let rng = LspRange {
|
let rng = LspRange {
|
||||||
start: LspPosition {
|
start: LspPosition {
|
||||||
|
|
@ -246,7 +253,7 @@ mod test {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let res = to_typst_range(rng, PositionEncoding::Utf16, &source).unwrap();
|
let res = to_typst_range(rng, PositionEncoding::Utf16, &source).unwrap();
|
||||||
assert_eq!(res, source.len_bytes()..source.len_bytes());
|
assert_eq!(res, source.lines().len_bytes()..source.lines().len_bytes());
|
||||||
|
|
||||||
for line in 0..=5 {
|
for line in 0..=5 {
|
||||||
for character in 0..2 {
|
for character in 0..2 {
|
||||||
|
|
@ -264,7 +271,7 @@ mod test {
|
||||||
fn overflow_offset_to_position() {
|
fn overflow_offset_to_position() {
|
||||||
let source = Source::detached("test");
|
let source = Source::detached("test");
|
||||||
|
|
||||||
let offset = source.len_bytes();
|
let offset = source.lines().len_bytes();
|
||||||
let position = to_lsp_position(offset, PositionEncoding::Utf16, &source);
|
let position = to_lsp_position(offset, PositionEncoding::Utf16, &source);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
position,
|
position,
|
||||||
|
|
@ -274,7 +281,7 @@ mod test {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let offset = source.len_bytes() + 1;
|
let offset = source.lines().len_bytes() + 1;
|
||||||
let position = to_lsp_position(offset, PositionEncoding::Utf16, &source);
|
let position = to_lsp_position(offset, PositionEncoding::Utf16, &source);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
position,
|
position,
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ecow::{EcoString, EcoVec, eco_format, eco_vec};
|
use ecow::{EcoString, EcoVec, eco_format, eco_vec};
|
||||||
use typst::foundations::{Closure, Func};
|
use typst::foundations::{Closure, ClosureNode, Func};
|
||||||
|
use typst::syntax::ast;
|
||||||
use typst::syntax::ast::AstNode;
|
use typst::syntax::ast::AstNode;
|
||||||
use typst::syntax::{SyntaxKind, ast};
|
|
||||||
use typst::utils::LazyHash;
|
use typst::utils::LazyHash;
|
||||||
|
|
||||||
// use super::{BoundChecker, Definition};
|
// use super::{BoundChecker, Definition};
|
||||||
|
|
@ -274,11 +274,9 @@ fn analyze_closure_signature(
|
||||||
closure: Arc<LazyHash<Closure>>,
|
closure: Arc<LazyHash<Closure>>,
|
||||||
add_param: &mut impl FnMut(Interned<ParamTy>),
|
add_param: &mut impl FnMut(Interned<ParamTy>),
|
||||||
) {
|
) {
|
||||||
log::trace!("closure signature for: {:?}", closure.node.kind());
|
|
||||||
|
|
||||||
let closure = &closure.node;
|
let closure = &closure.node;
|
||||||
let closure_ast = match closure.kind() {
|
let closure_ast = match closure {
|
||||||
SyntaxKind::Closure => closure.cast::<ast::Closure>().unwrap(),
|
ClosureNode::Closure(node) => node.cast::<ast::Closure>().unwrap(),
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ pub fn find_source_by_expr(
|
||||||
/// Casts a node to a single include expression.
|
/// Casts a node to a single include expression.
|
||||||
pub fn cast_include_expr<'a>(name: &str, node: ast::Expr<'a>) -> Option<ast::Expr<'a>> {
|
pub fn cast_include_expr<'a>(name: &str, node: ast::Expr<'a>) -> Option<ast::Expr<'a>> {
|
||||||
match node {
|
match node {
|
||||||
ast::Expr::Include(inc) => Some(inc.source()),
|
ast::Expr::ModuleInclude(inc) => Some(inc.source()),
|
||||||
ast::Expr::Code(code) => {
|
ast::Expr::CodeBlock(code) => {
|
||||||
let exprs = code.body();
|
let exprs = code.body();
|
||||||
if exprs.exprs().count() != 1 {
|
if exprs.exprs().count() != 1 {
|
||||||
eprintln!("example function must have a single inclusion: {name}");
|
eprintln!("example function must have a single inclusion: {name}");
|
||||||
|
|
|
||||||
|
|
@ -198,14 +198,14 @@ pub fn previous_decls<T>(
|
||||||
) -> Option<T> {
|
) -> Option<T> {
|
||||||
previous_items(node, |item| {
|
previous_items(node, |item| {
|
||||||
match (&item, item.node().cast::<ast::Expr>()?) {
|
match (&item, item.node().cast::<ast::Expr>()?) {
|
||||||
(PreviousItem::Sibling(..), ast::Expr::Let(lb)) => {
|
(PreviousItem::Sibling(..), ast::Expr::LetBinding(lb)) => {
|
||||||
for ident in lb.kind().bindings() {
|
for ident in lb.kind().bindings() {
|
||||||
if let Some(t) = recv(PreviousDecl::Ident(ident)) {
|
if let Some(t) = recv(PreviousDecl::Ident(ident)) {
|
||||||
return Some(t);
|
return Some(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(PreviousItem::Sibling(..), ast::Expr::Import(import)) => {
|
(PreviousItem::Sibling(..), ast::Expr::ModuleImport(import)) => {
|
||||||
// import items
|
// import items
|
||||||
match import.imports() {
|
match import.imports() {
|
||||||
Some(ast::Imports::Wildcard) => {
|
Some(ast::Imports::Wildcard) => {
|
||||||
|
|
@ -234,7 +234,7 @@ pub fn previous_decls<T>(
|
||||||
return Some(t);
|
return Some(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(PreviousItem::Parent(parent, child), ast::Expr::For(for_expr)) => {
|
(PreviousItem::Parent(parent, child), ast::Expr::ForLoop(for_expr)) => {
|
||||||
let body = parent.find(for_expr.body().span());
|
let body = parent.find(for_expr.body().span());
|
||||||
let in_body = body.is_some_and(|n| n.find(child.span()).is_some());
|
let in_body = body.is_some_and(|n| n.find(child.span()).is_some());
|
||||||
if !in_body {
|
if !in_body {
|
||||||
|
|
@ -467,9 +467,9 @@ fn classify_def_(node: LinkedNode<'_>, strict: bool) -> Option<DefClass<'_>> {
|
||||||
// todo: label, reference
|
// todo: label, reference
|
||||||
// todo: include
|
// todo: include
|
||||||
ast::Expr::FuncCall(..) => return None,
|
ast::Expr::FuncCall(..) => return None,
|
||||||
ast::Expr::Set(..) => return None,
|
ast::Expr::SetRule(..) => return None,
|
||||||
ast::Expr::Let(..) => DefClass::Let(adjusted),
|
ast::Expr::LetBinding(..) => DefClass::Let(adjusted),
|
||||||
ast::Expr::Import(..) => DefClass::Import(adjusted),
|
ast::Expr::ModuleImport(..) => DefClass::Import(adjusted),
|
||||||
// todo: parameter
|
// todo: parameter
|
||||||
ast::Expr::Ident(..)
|
ast::Expr::Ident(..)
|
||||||
| ast::Expr::MathIdent(..)
|
| ast::Expr::MathIdent(..)
|
||||||
|
|
@ -868,7 +868,7 @@ pub fn classify_syntax(node: LinkedNode<'_>, cursor: usize) -> Option<SyntaxClas
|
||||||
suffix_colon: false,
|
suffix_colon: false,
|
||||||
},
|
},
|
||||||
ast::Expr::FuncCall(call) => SyntaxClass::Callee(adjusted.find(call.callee().span())?),
|
ast::Expr::FuncCall(call) => SyntaxClass::Callee(adjusted.find(call.callee().span())?),
|
||||||
ast::Expr::Set(set) => SyntaxClass::Callee(adjusted.find(set.target().span())?),
|
ast::Expr::SetRule(set) => SyntaxClass::Callee(adjusted.find(set.target().span())?),
|
||||||
ast::Expr::Ident(..) | ast::Expr::MathIdent(..) => {
|
ast::Expr::Ident(..) | ast::Expr::MathIdent(..) => {
|
||||||
SyntaxClass::VarAccess(VarClass::Ident(adjusted))
|
SyntaxClass::VarAccess(VarClass::Ident(adjusted))
|
||||||
}
|
}
|
||||||
|
|
@ -1206,7 +1206,7 @@ pub fn classify_context_outer<'a>(
|
||||||
let parent = callee.parent()?;
|
let parent = callee.parent()?;
|
||||||
let args = match parent.cast::<ast::Expr>() {
|
let args = match parent.cast::<ast::Expr>() {
|
||||||
Some(ast::Expr::FuncCall(call)) => call.args(),
|
Some(ast::Expr::FuncCall(call)) => call.args(),
|
||||||
Some(ast::Expr::Set(set)) => set.args(),
|
Some(ast::Expr::SetRule(set)) => set.args(),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
let args = parent.find(args.span())?;
|
let args = parent.find(args.span())?;
|
||||||
|
|
@ -1276,7 +1276,7 @@ pub fn classify_context(node: LinkedNode<'_>, cursor: Option<usize>) -> Option<S
|
||||||
let callee = node_ancestors(&node_parent).find_map(|ancestor| {
|
let callee = node_ancestors(&node_parent).find_map(|ancestor| {
|
||||||
let span = match ancestor.cast::<ast::Expr>()? {
|
let span = match ancestor.cast::<ast::Expr>()? {
|
||||||
ast::Expr::FuncCall(call) => call.callee().span(),
|
ast::Expr::FuncCall(call) => call.callee().span(),
|
||||||
ast::Expr::Set(set) => set.target().span(),
|
ast::Expr::SetRule(set) => set.target().span(),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
ancestor.find(span)
|
ancestor.find(span)
|
||||||
|
|
@ -1333,7 +1333,7 @@ fn callee_context<'a>(callee: LinkedNode<'a>, node: LinkedNode<'a>) -> Option<Sy
|
||||||
let parent = callee.parent()?;
|
let parent = callee.parent()?;
|
||||||
let args = match parent.cast::<ast::Expr>() {
|
let args = match parent.cast::<ast::Expr>() {
|
||||||
Some(ast::Expr::FuncCall(call)) => call.args(),
|
Some(ast::Expr::FuncCall(call)) => call.args(),
|
||||||
Some(ast::Expr::Set(set)) => set.args(),
|
Some(ast::Expr::SetRule(set)) => set.args(),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
let args = parent.find(args.span())?;
|
let args = parent.find(args.span())?;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
title: Variants
|
title: Variants
|
||||||
category: math
|
category: math
|
||||||
path: ["math"]
|
path: ["math"]
|
||||||
filter: ["serif", "sans", "frak", "mono", "bb", "cal"]
|
filter: ["serif", "sans", "frak", "mono", "bb", "cal", "scr"]
|
||||||
details: |
|
details: |
|
||||||
Alternate typefaces within formulas.
|
Alternate typefaces within formulas.
|
||||||
|
|
||||||
|
|
@ -39,18 +39,19 @@
|
||||||
title: Under/Over
|
title: Under/Over
|
||||||
category: math
|
category: math
|
||||||
path: ["math"]
|
path: ["math"]
|
||||||
filter: [
|
filter:
|
||||||
"underline",
|
[
|
||||||
"overline",
|
"underline",
|
||||||
"underbrace",
|
"overline",
|
||||||
"overbrace",
|
"underbrace",
|
||||||
"underbracket",
|
"overbrace",
|
||||||
"overbracket",
|
"underbracket",
|
||||||
"underparen",
|
"overbracket",
|
||||||
"overparen",
|
"underparen",
|
||||||
"undershell",
|
"overparen",
|
||||||
"overshell",
|
"undershell",
|
||||||
]
|
"overshell",
|
||||||
|
]
|
||||||
details: |
|
details: |
|
||||||
Delimiters above or below parts of an equation.
|
Delimiters above or below parts of an equation.
|
||||||
|
|
||||||
|
|
@ -112,11 +113,18 @@
|
||||||
a few more functions that create delimiter pairings for absolute, ceiled,
|
a few more functions that create delimiter pairings for absolute, ceiled,
|
||||||
and floored values as well as norms.
|
and floored values as well as norms.
|
||||||
|
|
||||||
|
To prevent a delimiter from being matched by Typst, and thus auto-scaled,
|
||||||
|
escape it with a backslash. To instead disable auto-scaling completely, use
|
||||||
|
`{set math.lr(size: 1em)}`.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
```example
|
```example
|
||||||
$ [a, b/2] $
|
$ [a, b/2] $
|
||||||
$ lr(]sum_(x=1)^n], size: #50%) x $
|
$ lr(]sum_(x=1)^n], size: #50%) x $
|
||||||
$ abs((x + y) / 2) $
|
$ abs((x + y) / 2) $
|
||||||
|
$ \{ (x / y) \} $
|
||||||
|
#set math.lr(size: 1em)
|
||||||
|
$ { (a / b), a, b in (0; 1/2] } $
|
||||||
```
|
```
|
||||||
|
|
||||||
- name: calc
|
- name: calc
|
||||||
|
|
@ -130,6 +138,55 @@
|
||||||
In addition to the functions listed below, the `calc` module also defines
|
In addition to the functions listed below, the `calc` module also defines
|
||||||
the constants `pi`, `tau`, `e`, and `inf`.
|
the constants `pi`, `tau`, `e`, and `inf`.
|
||||||
|
|
||||||
|
- name: std
|
||||||
|
title: Standard library
|
||||||
|
category: foundations
|
||||||
|
path: ["std"]
|
||||||
|
details: |
|
||||||
|
A module that contains all globally accessible items.
|
||||||
|
|
||||||
|
# Using "shadowed" definitions
|
||||||
|
The `std` module is useful whenever you overrode a name from the global
|
||||||
|
scope (this is called _shadowing_). For instance, you might have used the
|
||||||
|
name `text` for a parameter. To still access the `text` element, write
|
||||||
|
`std.text`.
|
||||||
|
|
||||||
|
```example
|
||||||
|
>>> #set page(margin: (left: 3em))
|
||||||
|
#let par = [My special paragraph.]
|
||||||
|
#let special(text) = {
|
||||||
|
set std.text(style: "italic")
|
||||||
|
set std.par.line(numbering: "1")
|
||||||
|
text
|
||||||
|
}
|
||||||
|
|
||||||
|
#special(par)
|
||||||
|
|
||||||
|
#lorem(10)
|
||||||
|
```
|
||||||
|
|
||||||
|
# Conditional access
|
||||||
|
You can also use this in combination with the [dictionary
|
||||||
|
constructor]($dictionary) to conditionally access global definitions. This
|
||||||
|
can, for instance, be useful to use new or experimental functionality when
|
||||||
|
it is available, while falling back to an alternative implementation if
|
||||||
|
used on an older Typst version. In particular, this allows us to create
|
||||||
|
[polyfills](https://en.wikipedia.org/wiki/Polyfill_(programming)).
|
||||||
|
|
||||||
|
This can be as simple as creating an alias to prevent warning messages, for
|
||||||
|
example, conditionally using `pattern` in Typst version 0.12, but using
|
||||||
|
[`tiling`] in newer versions. Since the parameters accepted by the `tiling`
|
||||||
|
function match those of the older `pattern` function, using the `tiling`
|
||||||
|
function when available and falling back to `pattern` otherwise will unify
|
||||||
|
the usage across all versions. Note that, when creating a polyfill,
|
||||||
|
[`sys.version`]($category/foundations/sys) can also be very useful.
|
||||||
|
|
||||||
|
```typ
|
||||||
|
#let tiling = if "tiling" in std { tiling } else { pattern }
|
||||||
|
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
- name: sys
|
- name: sys
|
||||||
title: System
|
title: System
|
||||||
category: foundations
|
category: foundations
|
||||||
|
|
@ -149,7 +206,7 @@
|
||||||
single or double quotes.
|
single or double quotes.
|
||||||
|
|
||||||
The value is always of type [string]($str). More complex data
|
The value is always of type [string]($str). More complex data
|
||||||
may be parsed manually using functions like [`json.decode`]($json.decode).
|
may be parsed manually using functions like [`json`]($json).
|
||||||
|
|
||||||
- name: sym
|
- name: sym
|
||||||
title: General
|
title: General
|
||||||
|
|
@ -175,3 +232,31 @@
|
||||||
For example, `#emoji.face` produces the 😀 emoji. If you frequently use
|
For example, `#emoji.face` produces the 😀 emoji. If you frequently use
|
||||||
certain emojis, you can also import them from the `emoji` module (`[#import
|
certain emojis, you can also import them from the `emoji` module (`[#import
|
||||||
emoji: face]`) to use them without the `emoji.` prefix.
|
emoji: face]`) to use them without the `emoji.` prefix.
|
||||||
|
|
||||||
|
- name: typed
|
||||||
|
title: Typed HTML
|
||||||
|
category: html
|
||||||
|
path: ["html"]
|
||||||
|
details: |
|
||||||
|
A typed layer over raw HTML elements.
|
||||||
|
|
||||||
|
The `html` module provides a typed layer over the raw [`html.elem`] function
|
||||||
|
that allows you to conveniently create HTML elements. HTML attributes are
|
||||||
|
exposed as function parameters that accept Typst types and automatically
|
||||||
|
take care of converting those into the appropriate HTML.
|
||||||
|
|
||||||
|
Some parameters are common to all typed HTML functions. These are listed at
|
||||||
|
the bottom in the [Global Attributes](#global-attributes) section instead of
|
||||||
|
explicitly on each element for readability.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
```typ
|
||||||
|
#html.video(
|
||||||
|
controls: true,
|
||||||
|
width: 1280,
|
||||||
|
height: 720,
|
||||||
|
src: "sunrise.mp4",
|
||||||
|
)[
|
||||||
|
Your browser does not support the video tag.
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
//! Functions from typst-ide
|
//! Functions from typst-ide
|
||||||
|
|
||||||
|
mod tooltip;
|
||||||
|
|
||||||
|
pub use tooltip::{Tooltip, tooltip_};
|
||||||
|
|
||||||
use std::{collections::HashMap, fmt::Write, sync::LazyLock};
|
use std::{collections::HashMap, fmt::Write, sync::LazyLock};
|
||||||
|
|
||||||
use comemo::Tracked;
|
use comemo::Tracked;
|
||||||
|
|
@ -7,7 +11,7 @@ use ecow::{EcoString, eco_format};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_yaml as yaml;
|
use serde_yaml as yaml;
|
||||||
use typst::{
|
use typst::{
|
||||||
Category, Library, World,
|
Category, Feature, Features, Library, LibraryExt, World,
|
||||||
diag::{StrResult, bail},
|
diag::{StrResult, bail},
|
||||||
foundations::{Binding, Content, Func, Module, Type, Value},
|
foundations::{Binding, Content, Func, Module, Type, Value},
|
||||||
introspection::MetadataElem,
|
introspection::MetadataElem,
|
||||||
|
|
@ -15,9 +19,6 @@ use typst::{
|
||||||
text::{FontInfo, FontStyle},
|
text::{FontInfo, FontStyle},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod tooltip;
|
|
||||||
pub use tooltip::*;
|
|
||||||
|
|
||||||
/// Extract the first sentence of plain text of a piece of documentation.
|
/// Extract the first sentence of plain text of a piece of documentation.
|
||||||
///
|
///
|
||||||
/// Removes Markdown formatting.
|
/// Removes Markdown formatting.
|
||||||
|
|
@ -109,7 +110,7 @@ impl GroupData {
|
||||||
static GROUPS: LazyLock<Vec<GroupData>> = LazyLock::new(|| {
|
static GROUPS: LazyLock<Vec<GroupData>> = LazyLock::new(|| {
|
||||||
let mut groups: Vec<GroupData> = yaml::from_str(include_str!("groups.yml")).unwrap();
|
let mut groups: Vec<GroupData> = yaml::from_str(include_str!("groups.yml")).unwrap();
|
||||||
for group in &mut groups {
|
for group in &mut groups {
|
||||||
if group.filter.is_empty() {
|
if group.filter.is_empty() && group.name != "std" {
|
||||||
group.filter = group
|
group.filter = group
|
||||||
.module()
|
.module()
|
||||||
.scope()
|
.scope()
|
||||||
|
|
@ -171,7 +172,11 @@ fn resolve_known(head: &str, base: &str) -> Option<String> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static LIBRARY: LazyLock<Library> = LazyLock::new(Library::default);
|
static LIBRARY: LazyLock<Library> = LazyLock::new(|| {
|
||||||
|
Library::builder()
|
||||||
|
.with_features(Features::from_iter([Feature::Html]))
|
||||||
|
.build()
|
||||||
|
});
|
||||||
|
|
||||||
/// Extract a module from another module.
|
/// Extract a module from another module.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
|
@ -322,11 +327,13 @@ static ROUTE_MAPS: LazyLock<HashMap<CatKey, String>> = LazyLock::new(|| {
|
||||||
|
|
||||||
let route = format_route(parent_name.as_deref(), &name, &cat);
|
let route = format_route(parent_name.as_deref(), &name, &cat);
|
||||||
|
|
||||||
// Some types are defined multiple times, and the first one should take precedence.
|
// Some types are defined multiple times, and the first one should take
|
||||||
|
// precedence.
|
||||||
//
|
//
|
||||||
// For example, typst 0.13.0 renamed `pattern` to `tiling`, but keep `pattern` remains as a deprecated alias.
|
// For example, typst 0.13.0 renamed `pattern` to `tiling`, but keep
|
||||||
// Therefore, `Tiling` is first defined as `tiling`, then defined as `pattern` with deprecation again.
|
// `pattern` remains as a deprecated alias.
|
||||||
// https://typst.app/docs/changelog/0.13.0/#visualization
|
// Therefore, `Tiling` is first defined as `tiling`, then defined as
|
||||||
|
// `pattern` with deprecation again. https://typst.app/docs/changelog/0.13.0/#visualization
|
||||||
// https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L34
|
// https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L34
|
||||||
// https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L47-L49
|
// https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L47-L49
|
||||||
map.entry(CatKey::Type(*t)).or_insert(route);
|
map.entry(CatKey::Type(*t)).or_insert(route);
|
||||||
|
|
@ -502,7 +509,7 @@ mod tests {
|
||||||
let mut values = ROUTE_MAPS.values().map(access).collect::<Vec<_>>();
|
let mut values = ROUTE_MAPS.values().map(access).collect::<Vec<_>>();
|
||||||
values.sort();
|
values.sort();
|
||||||
|
|
||||||
insta::assert_snapshot!(values.as_slice().join("\n"), @r###"
|
insta::assert_snapshot!(values.as_slice().join("\n"), @r"
|
||||||
https://typst.app/docs/reference/data-loading/cbor/
|
https://typst.app/docs/reference/data-loading/cbor/
|
||||||
https://typst.app/docs/reference/data-loading/cbor/#definitions-decode
|
https://typst.app/docs/reference/data-loading/cbor/#definitions-decode
|
||||||
https://typst.app/docs/reference/data-loading/cbor/#definitions-encode
|
https://typst.app/docs/reference/data-loading/cbor/#definitions-encode
|
||||||
|
|
@ -680,6 +687,7 @@ mod tests {
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-len
|
https://typst.app/docs/reference/foundations/str/#definitions-len
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-match
|
https://typst.app/docs/reference/foundations/str/#definitions-match
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-matches
|
https://typst.app/docs/reference/foundations/str/#definitions-matches
|
||||||
|
https://typst.app/docs/reference/foundations/str/#definitions-normalize
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-position
|
https://typst.app/docs/reference/foundations/str/#definitions-position
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-replace
|
https://typst.app/docs/reference/foundations/str/#definitions-replace
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-rev
|
https://typst.app/docs/reference/foundations/str/#definitions-rev
|
||||||
|
|
@ -689,9 +697,124 @@ mod tests {
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-to-unicode
|
https://typst.app/docs/reference/foundations/str/#definitions-to-unicode
|
||||||
https://typst.app/docs/reference/foundations/str/#definitions-trim
|
https://typst.app/docs/reference/foundations/str/#definitions-trim
|
||||||
https://typst.app/docs/reference/foundations/symbol/
|
https://typst.app/docs/reference/foundations/symbol/
|
||||||
|
https://typst.app/docs/reference/foundations/target/
|
||||||
https://typst.app/docs/reference/foundations/type/
|
https://typst.app/docs/reference/foundations/type/
|
||||||
https://typst.app/docs/reference/foundations/version/
|
https://typst.app/docs/reference/foundations/version/
|
||||||
https://typst.app/docs/reference/foundations/version/#definitions-at
|
https://typst.app/docs/reference/foundations/version/#definitions-at
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-a
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-abbr
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-address
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-area
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-article
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-aside
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-audio
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-b
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-base
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-bdi
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-bdo
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-blockquote
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-body
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-br
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-button
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-canvas
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-caption
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-cite
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-code
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-col
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-colgroup
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-data
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-datalist
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-dd
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-del
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-details
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-dfn
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-dialog
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-div
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-dl
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-dt
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-elem
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-em
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-embed
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-fieldset
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-figcaption
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-figure
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-footer
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-form
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-frame
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h1
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h2
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h3
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h4
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h5
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-h6
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-head
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-header
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-hgroup
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-hr
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-html
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-i
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-iframe
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-img
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-input
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-ins
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-kbd
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-label
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-legend
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-li
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-link
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-main
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-map
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-mark
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-menu
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-meta
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-meter
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-nav
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-noscript
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-object
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-ol
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-optgroup
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-option
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-output
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-p
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-picture
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-pre
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-progress
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-q
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-rp
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-rt
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-ruby
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-s
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-samp
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-script
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-search
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-section
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-select
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-slot
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-small
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-source
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-span
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-strong
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-style
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-sub
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-summary
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-sup
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-table
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-tbody
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-td
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-template
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-textarea
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-tfoot
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-th
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-thead
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-time
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-title
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-tr
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-track
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-u
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-ul
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-var
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-video
|
||||||
|
https://typst.app/docs/reference/html/typed/#functions-wbr
|
||||||
https://typst.app/docs/reference/introspection/counter/
|
https://typst.app/docs/reference/introspection/counter/
|
||||||
https://typst.app/docs/reference/introspection/counter/#definitions-at
|
https://typst.app/docs/reference/introspection/counter/#definitions-at
|
||||||
https://typst.app/docs/reference/introspection/counter/#definitions-display
|
https://typst.app/docs/reference/introspection/counter/#definitions-display
|
||||||
|
|
@ -726,8 +849,11 @@ mod tests {
|
||||||
https://typst.app/docs/reference/layout/direction/
|
https://typst.app/docs/reference/layout/direction/
|
||||||
https://typst.app/docs/reference/layout/direction/#definitions-axis
|
https://typst.app/docs/reference/layout/direction/#definitions-axis
|
||||||
https://typst.app/docs/reference/layout/direction/#definitions-end
|
https://typst.app/docs/reference/layout/direction/#definitions-end
|
||||||
|
https://typst.app/docs/reference/layout/direction/#definitions-from
|
||||||
https://typst.app/docs/reference/layout/direction/#definitions-inv
|
https://typst.app/docs/reference/layout/direction/#definitions-inv
|
||||||
|
https://typst.app/docs/reference/layout/direction/#definitions-sign
|
||||||
https://typst.app/docs/reference/layout/direction/#definitions-start
|
https://typst.app/docs/reference/layout/direction/#definitions-start
|
||||||
|
https://typst.app/docs/reference/layout/direction/#definitions-to
|
||||||
https://typst.app/docs/reference/layout/fraction/
|
https://typst.app/docs/reference/layout/fraction/
|
||||||
https://typst.app/docs/reference/layout/grid/
|
https://typst.app/docs/reference/layout/grid/
|
||||||
https://typst.app/docs/reference/layout/grid/#definitions-cell
|
https://typst.app/docs/reference/layout/grid/#definitions-cell
|
||||||
|
|
@ -803,6 +929,7 @@ mod tests {
|
||||||
https://typst.app/docs/reference/math/variants/#functions-frak
|
https://typst.app/docs/reference/math/variants/#functions-frak
|
||||||
https://typst.app/docs/reference/math/variants/#functions-mono
|
https://typst.app/docs/reference/math/variants/#functions-mono
|
||||||
https://typst.app/docs/reference/math/variants/#functions-sans
|
https://typst.app/docs/reference/math/variants/#functions-sans
|
||||||
|
https://typst.app/docs/reference/math/variants/#functions-scr
|
||||||
https://typst.app/docs/reference/math/variants/#functions-serif
|
https://typst.app/docs/reference/math/variants/#functions-serif
|
||||||
https://typst.app/docs/reference/math/vec/
|
https://typst.app/docs/reference/math/vec/
|
||||||
https://typst.app/docs/reference/model/bibliography/
|
https://typst.app/docs/reference/model/bibliography/
|
||||||
|
|
@ -841,7 +968,9 @@ mod tests {
|
||||||
https://typst.app/docs/reference/model/table/#definitions-vline
|
https://typst.app/docs/reference/model/table/#definitions-vline
|
||||||
https://typst.app/docs/reference/model/terms/
|
https://typst.app/docs/reference/model/terms/
|
||||||
https://typst.app/docs/reference/model/terms/#definitions-item
|
https://typst.app/docs/reference/model/terms/#definitions-item
|
||||||
https://typst.app/docs/reference/pdf/embed/
|
https://typst.app/docs/reference/model/title/
|
||||||
|
https://typst.app/docs/reference/pdf/artifact/
|
||||||
|
https://typst.app/docs/reference/pdf/attach/
|
||||||
https://typst.app/docs/reference/text/highlight/
|
https://typst.app/docs/reference/text/highlight/
|
||||||
https://typst.app/docs/reference/text/linebreak/
|
https://typst.app/docs/reference/text/linebreak/
|
||||||
https://typst.app/docs/reference/text/lorem/
|
https://typst.app/docs/reference/text/lorem/
|
||||||
|
|
@ -912,6 +1041,6 @@ mod tests {
|
||||||
https://typst.app/docs/reference/visualize/square/
|
https://typst.app/docs/reference/visualize/square/
|
||||||
https://typst.app/docs/reference/visualize/stroke/
|
https://typst.app/docs/reference/visualize/stroke/
|
||||||
https://typst.app/docs/reference/visualize/tiling/
|
https://typst.app/docs/reference/visualize/tiling/
|
||||||
"###);
|
");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,9 @@ impl<'a> TestRunner<'a> {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
let label = Label::new(PicoStr::intern("test-html-example"));
|
let Some(label) = Label::new(PicoStr::intern("test-html-example")) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
// todo: error multiple times
|
// todo: error multiple times
|
||||||
doc.introspector.query_label(label).is_ok()
|
doc.introspector.query_label(label).is_ok()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,15 +274,15 @@ impl InstrumentWorker {
|
||||||
fn visit_node(&mut self, node: &SyntaxNode) {
|
fn visit_node(&mut self, node: &SyntaxNode) {
|
||||||
if let Some(expr) = node.cast::<ast::Expr>() {
|
if let Some(expr) = node.cast::<ast::Expr>() {
|
||||||
match expr {
|
match expr {
|
||||||
ast::Expr::Code(..) => {
|
ast::Expr::CodeBlock(..) => {
|
||||||
self.instrument_block(node);
|
self.instrument_block(node);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::While(while_expr) => {
|
ast::Expr::WhileLoop(while_expr) => {
|
||||||
self.instrument_block_child(node, while_expr.body().span(), Span::detached());
|
self.instrument_block_child(node, while_expr.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::For(for_expr) => {
|
ast::Expr::ForLoop(for_expr) => {
|
||||||
self.instrument_block_child(node, for_expr.body().span(), Span::detached());
|
self.instrument_block_child(node, for_expr.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -298,9 +298,9 @@ impl InstrumentWorker {
|
||||||
self.instrument_block_child(node, closure.body().span(), Span::detached());
|
self.instrument_block_child(node, closure.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::Show(show_rule) => {
|
ast::Expr::ShowRule(show_rule) => {
|
||||||
let transform = show_rule.transform().to_untyped().span();
|
let transform = show_rule.transform().to_untyped().span();
|
||||||
let is_set = matches!(show_rule.transform(), ast::Expr::Set(..));
|
let is_set = matches!(show_rule.transform(), ast::Expr::SetRule(..));
|
||||||
|
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
if transform == child.span() {
|
if transform == child.span() {
|
||||||
|
|
@ -335,9 +335,9 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Label(..)
|
| ast::Expr::Label(..)
|
||||||
| ast::Expr::Ref(..)
|
| ast::Expr::Ref(..)
|
||||||
| ast::Expr::Heading(..)
|
| ast::Expr::Heading(..)
|
||||||
| ast::Expr::List(..)
|
| ast::Expr::ListItem(..)
|
||||||
| ast::Expr::Enum(..)
|
| ast::Expr::EnumItem(..)
|
||||||
| ast::Expr::Term(..)
|
| ast::Expr::TermItem(..)
|
||||||
| ast::Expr::Equation(..)
|
| ast::Expr::Equation(..)
|
||||||
| ast::Expr::Math(..)
|
| ast::Expr::Math(..)
|
||||||
| ast::Expr::MathText(..)
|
| ast::Expr::MathText(..)
|
||||||
|
|
@ -357,7 +357,7 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Float(..)
|
| ast::Expr::Float(..)
|
||||||
| ast::Expr::Numeric(..)
|
| ast::Expr::Numeric(..)
|
||||||
| ast::Expr::Str(..)
|
| ast::Expr::Str(..)
|
||||||
| ast::Expr::Content(..)
|
| ast::Expr::ContentBlock(..)
|
||||||
| ast::Expr::Parenthesized(..)
|
| ast::Expr::Parenthesized(..)
|
||||||
| ast::Expr::Array(..)
|
| ast::Expr::Array(..)
|
||||||
| ast::Expr::Dict(..)
|
| ast::Expr::Dict(..)
|
||||||
|
|
@ -365,14 +365,14 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Binary(..)
|
| ast::Expr::Binary(..)
|
||||||
| ast::Expr::FieldAccess(..)
|
| ast::Expr::FieldAccess(..)
|
||||||
| ast::Expr::FuncCall(..)
|
| ast::Expr::FuncCall(..)
|
||||||
| ast::Expr::Let(..)
|
| ast::Expr::LetBinding(..)
|
||||||
| ast::Expr::DestructAssign(..)
|
| ast::Expr::DestructAssignment(..)
|
||||||
| ast::Expr::Set(..)
|
| ast::Expr::SetRule(..)
|
||||||
| ast::Expr::Import(..)
|
| ast::Expr::ModuleImport(..)
|
||||||
| ast::Expr::Include(..)
|
| ast::Expr::ModuleInclude(..)
|
||||||
| ast::Expr::Break(..)
|
| ast::Expr::LoopBreak(..)
|
||||||
| ast::Expr::Continue(..)
|
| ast::Expr::LoopContinue(..)
|
||||||
| ast::Expr::Return(..) => {}
|
| ast::Expr::FuncReturn(..) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ impl InstrumentWorker {
|
||||||
fn visit_node(&mut self, node: &SyntaxNode) {
|
fn visit_node(&mut self, node: &SyntaxNode) {
|
||||||
if let Some(expr) = node.cast::<ast::Expr>() {
|
if let Some(expr) = node.cast::<ast::Expr>() {
|
||||||
match expr {
|
match expr {
|
||||||
ast::Expr::Code(..) => {
|
ast::Expr::CodeBlock(..) => {
|
||||||
self.instrument_block(node);
|
self.instrument_block(node);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::While(while_expr) => {
|
ast::Expr::WhileLoop(while_expr) => {
|
||||||
self.instrument_block_child(node, while_expr.body().span(), Span::detached());
|
self.instrument_block_child(node, while_expr.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::For(for_expr) => {
|
ast::Expr::ForLoop(for_expr) => {
|
||||||
self.instrument_block_child(node, for_expr.body().span(), Span::detached());
|
self.instrument_block_child(node, for_expr.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ impl InstrumentWorker {
|
||||||
self.instrument_block_child(node, closure.body().span(), Span::detached());
|
self.instrument_block_child(node, closure.body().span(), Span::detached());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ast::Expr::Show(show_rule) => {
|
ast::Expr::ShowRule(show_rule) => {
|
||||||
let transform = show_rule.transform().to_untyped().span();
|
let transform = show_rule.transform().to_untyped().span();
|
||||||
|
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
|
|
@ -102,9 +102,9 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Label(..)
|
| ast::Expr::Label(..)
|
||||||
| ast::Expr::Ref(..)
|
| ast::Expr::Ref(..)
|
||||||
| ast::Expr::Heading(..)
|
| ast::Expr::Heading(..)
|
||||||
| ast::Expr::List(..)
|
| ast::Expr::ListItem(..)
|
||||||
| ast::Expr::Enum(..)
|
| ast::Expr::EnumItem(..)
|
||||||
| ast::Expr::Term(..)
|
| ast::Expr::TermItem(..)
|
||||||
| ast::Expr::Equation(..)
|
| ast::Expr::Equation(..)
|
||||||
| ast::Expr::Math(..)
|
| ast::Expr::Math(..)
|
||||||
| ast::Expr::MathText(..)
|
| ast::Expr::MathText(..)
|
||||||
|
|
@ -124,7 +124,7 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Float(..)
|
| ast::Expr::Float(..)
|
||||||
| ast::Expr::Numeric(..)
|
| ast::Expr::Numeric(..)
|
||||||
| ast::Expr::Str(..)
|
| ast::Expr::Str(..)
|
||||||
| ast::Expr::Content(..)
|
| ast::Expr::ContentBlock(..)
|
||||||
| ast::Expr::Parenthesized(..)
|
| ast::Expr::Parenthesized(..)
|
||||||
| ast::Expr::Array(..)
|
| ast::Expr::Array(..)
|
||||||
| ast::Expr::Dict(..)
|
| ast::Expr::Dict(..)
|
||||||
|
|
@ -132,15 +132,15 @@ impl InstrumentWorker {
|
||||||
| ast::Expr::Binary(..)
|
| ast::Expr::Binary(..)
|
||||||
| ast::Expr::FieldAccess(..)
|
| ast::Expr::FieldAccess(..)
|
||||||
| ast::Expr::FuncCall(..)
|
| ast::Expr::FuncCall(..)
|
||||||
| ast::Expr::Let(..)
|
| ast::Expr::LetBinding(..)
|
||||||
| ast::Expr::DestructAssign(..)
|
| ast::Expr::DestructAssignment(..)
|
||||||
| ast::Expr::Set(..)
|
| ast::Expr::SetRule(..)
|
||||||
| ast::Expr::Contextual(..)
|
| ast::Expr::Contextual(..)
|
||||||
| ast::Expr::Import(..)
|
| ast::Expr::ModuleImport(..)
|
||||||
| ast::Expr::Include(..)
|
| ast::Expr::ModuleInclude(..)
|
||||||
| ast::Expr::Break(..)
|
| ast::Expr::LoopBreak(..)
|
||||||
| ast::Expr::Continue(..)
|
| ast::Expr::LoopContinue(..)
|
||||||
| ast::Expr::Return(..) => {}
|
| ast::Expr::FuncReturn(..) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Provides derive for tinymist."
|
||||||
categories = ["compilers"]
|
categories = ["compilers"]
|
||||||
keywords = ["typst"]
|
keywords = ["typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Localization support for tinymist and typst."
|
||||||
categories = ["compilers", "command-line-utilities"]
|
categories = ["compilers", "command-line-utilities"]
|
||||||
keywords = ["language", "typst"]
|
keywords = ["language", "typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -193,8 +193,8 @@ impl<'w> Linter<'w> {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for set in block.iter() {
|
for set in block.iter() {
|
||||||
let msg = match set {
|
let msg = match set {
|
||||||
ast::Expr::Set(..) => "This set statement doesn't take effect.",
|
ast::Expr::SetRule(..) => "This set statement doesn't take effect.",
|
||||||
ast::Expr::Show(..) => "This show statement doesn't take effect.",
|
ast::Expr::ShowRule(..) => "This show statement doesn't take effect.",
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
let mut warning = SourceDiagnostic::warning(set.span(), msg);
|
let mut warning = SourceDiagnostic::warning(set.span(), msg);
|
||||||
|
|
@ -217,7 +217,7 @@ impl<'w> Linter<'w> {
|
||||||
for it in block.iter() {
|
for it in block.iter() {
|
||||||
if is_show_set(it) {
|
if is_show_set(it) {
|
||||||
has_set = true;
|
has_set = true;
|
||||||
} else if matches!(it, ast::Expr::Break(..) | ast::Expr::Continue(..)) {
|
} else if matches!(it, ast::Expr::LoopBreak(..) | ast::Expr::LoopContinue(..)) {
|
||||||
return has_set;
|
return has_set;
|
||||||
} else if !it.to_untyped().kind().is_trivia() {
|
} else if !it.to_untyped().kind().is_trivia() {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -601,7 +601,7 @@ impl DataFlowVisitor for LateFuncLinter<'_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn include(&mut self, expr: ast::ModuleInclude<'_>) -> Option<()> {
|
fn include(&mut self, expr: ast::ModuleInclude<'_>) -> Option<()> {
|
||||||
self.value(ast::Expr::Include(expr));
|
self.value(ast::Expr::ModuleInclude(expr));
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -656,7 +656,7 @@ impl DataFlowVisitor for LateFuncLinter<'_, '_> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
let diag = match expr {
|
let diag = match expr {
|
||||||
ast::Expr::Show(..) | ast::Expr::Set(..) => diag,
|
ast::Expr::ShowRule(..) | ast::Expr::SetRule(..) => diag,
|
||||||
expr if expr.hash() => diag.with_hint(eco_format!(
|
expr if expr.hash() => diag.with_hint(eco_format!(
|
||||||
"consider ignoring the value explicitly using underscore: `let _ = {}`",
|
"consider ignoring the value explicitly using underscore: `let _ = {}`",
|
||||||
expr.to_untyped().clone().into_text()
|
expr.to_untyped().clone().into_text()
|
||||||
|
|
@ -664,7 +664,8 @@ impl DataFlowVisitor for LateFuncLinter<'_, '_> {
|
||||||
_ => diag,
|
_ => diag,
|
||||||
};
|
};
|
||||||
self.linter.diag.push(diag);
|
self.linter.diag.push(diag);
|
||||||
} else if ri.return_none && matches!(expr, ast::Expr::Show(..) | ast::Expr::Set(..)) {
|
} else if ri.return_none && matches!(expr, ast::Expr::ShowRule(..) | ast::Expr::SetRule(..))
|
||||||
|
{
|
||||||
ri.warned = true;
|
ri.warned = true;
|
||||||
let diag = SourceDiagnostic::warning(
|
let diag = SourceDiagnostic::warning(
|
||||||
expr.span(),
|
expr.span(),
|
||||||
|
|
@ -680,12 +681,12 @@ impl DataFlowVisitor for LateFuncLinter<'_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, expr: ast::ShowRule<'_>) -> Option<()> {
|
fn show(&mut self, expr: ast::ShowRule<'_>) -> Option<()> {
|
||||||
self.value(ast::Expr::Show(expr));
|
self.value(ast::Expr::ShowRule(expr));
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set(&mut self, expr: ast::SetRule<'_>) -> Option<()> {
|
fn set(&mut self, expr: ast::SetRule<'_>) -> Option<()> {
|
||||||
self.value(ast::Expr::Set(expr));
|
self.value(ast::Expr::SetRule(expr));
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -719,8 +720,8 @@ trait DataFlowVisitor {
|
||||||
fn expr(&mut self, expr: ast::Expr) -> Option<()> {
|
fn expr(&mut self, expr: ast::Expr) -> Option<()> {
|
||||||
match expr {
|
match expr {
|
||||||
ast::Expr::Parenthesized(expr) => self.expr(expr.expr()),
|
ast::Expr::Parenthesized(expr) => self.expr(expr.expr()),
|
||||||
ast::Expr::Code(expr) => self.block(expr.body().exprs()),
|
ast::Expr::CodeBlock(expr) => self.block(expr.body().exprs()),
|
||||||
ast::Expr::Content(expr) => self.block(expr.body().exprs()),
|
ast::Expr::ContentBlock(expr) => self.block(expr.body().exprs()),
|
||||||
ast::Expr::Math(expr) => self.exprs(expr.exprs()),
|
ast::Expr::Math(expr) => self.exprs(expr.exprs()),
|
||||||
|
|
||||||
ast::Expr::Text(..) => self.value(expr),
|
ast::Expr::Text(..) => self.value(expr),
|
||||||
|
|
@ -751,9 +752,9 @@ trait DataFlowVisitor {
|
||||||
ast::Expr::Strong(content) => self.exprs(content.body().exprs()),
|
ast::Expr::Strong(content) => self.exprs(content.body().exprs()),
|
||||||
ast::Expr::Emph(content) => self.exprs(content.body().exprs()),
|
ast::Expr::Emph(content) => self.exprs(content.body().exprs()),
|
||||||
ast::Expr::Heading(content) => self.exprs(content.body().exprs()),
|
ast::Expr::Heading(content) => self.exprs(content.body().exprs()),
|
||||||
ast::Expr::List(content) => self.exprs(content.body().exprs()),
|
ast::Expr::ListItem(content) => self.exprs(content.body().exprs()),
|
||||||
ast::Expr::Enum(content) => self.exprs(content.body().exprs()),
|
ast::Expr::EnumItem(content) => self.exprs(content.body().exprs()),
|
||||||
ast::Expr::Term(content) => {
|
ast::Expr::TermItem(content) => {
|
||||||
self.exprs(content.term().exprs().chain(content.description().exprs()))
|
self.exprs(content.term().exprs().chain(content.description().exprs()))
|
||||||
}
|
}
|
||||||
ast::Expr::MathDelimited(content) => self.exprs(content.body().exprs()),
|
ast::Expr::MathDelimited(content) => self.exprs(content.body().exprs()),
|
||||||
|
|
@ -769,19 +770,19 @@ trait DataFlowVisitor {
|
||||||
ast::Expr::FieldAccess(expr) => self.field_access(expr),
|
ast::Expr::FieldAccess(expr) => self.field_access(expr),
|
||||||
ast::Expr::FuncCall(expr) => self.func_call(expr),
|
ast::Expr::FuncCall(expr) => self.func_call(expr),
|
||||||
ast::Expr::Closure(expr) => self.closure(expr),
|
ast::Expr::Closure(expr) => self.closure(expr),
|
||||||
ast::Expr::Let(expr) => self.let_binding(expr),
|
ast::Expr::LetBinding(expr) => self.let_binding(expr),
|
||||||
ast::Expr::DestructAssign(expr) => self.destruct_assign(expr),
|
ast::Expr::DestructAssignment(expr) => self.destruct_assign(expr),
|
||||||
ast::Expr::Set(expr) => self.set(expr),
|
ast::Expr::SetRule(expr) => self.set(expr),
|
||||||
ast::Expr::Show(expr) => self.show(expr),
|
ast::Expr::ShowRule(expr) => self.show(expr),
|
||||||
ast::Expr::Contextual(expr) => self.contextual(expr),
|
ast::Expr::Contextual(expr) => self.contextual(expr),
|
||||||
ast::Expr::Conditional(expr) => self.conditional(expr),
|
ast::Expr::Conditional(expr) => self.conditional(expr),
|
||||||
ast::Expr::While(expr) => self.while_loop(expr),
|
ast::Expr::WhileLoop(expr) => self.while_loop(expr),
|
||||||
ast::Expr::For(expr) => self.for_loop(expr),
|
ast::Expr::ForLoop(expr) => self.for_loop(expr),
|
||||||
ast::Expr::Import(expr) => self.import(expr),
|
ast::Expr::ModuleImport(expr) => self.import(expr),
|
||||||
ast::Expr::Include(expr) => self.include(expr),
|
ast::Expr::ModuleInclude(expr) => self.include(expr),
|
||||||
ast::Expr::Break(expr) => self.loop_break(expr),
|
ast::Expr::LoopBreak(expr) => self.loop_break(expr),
|
||||||
ast::Expr::Continue(expr) => self.loop_continue(expr),
|
ast::Expr::LoopContinue(expr) => self.loop_continue(expr),
|
||||||
ast::Expr::Return(expr) => self.func_return(expr),
|
ast::Expr::FuncReturn(expr) => self.func_return(expr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -958,8 +959,8 @@ enum Block<'a> {
|
||||||
impl<'a> Block<'a> {
|
impl<'a> Block<'a> {
|
||||||
fn from(expr: ast::Expr<'a>) -> Option<Self> {
|
fn from(expr: ast::Expr<'a>) -> Option<Self> {
|
||||||
Some(match expr {
|
Some(match expr {
|
||||||
ast::Expr::Code(block) => Block::Code(block.body()),
|
ast::Expr::CodeBlock(block) => Block::Code(block.body()),
|
||||||
ast::Expr::Content(block) => Block::Markup(block.body()),
|
ast::Expr::ContentBlock(block) => Block::Markup(block.body()),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1009,7 +1010,7 @@ impl BuggyBlockLoc<'_> {
|
||||||
fn hint(&self, show_set: ast::Expr<'_>) -> EcoString {
|
fn hint(&self, show_set: ast::Expr<'_>) -> EcoString {
|
||||||
match self {
|
match self {
|
||||||
BuggyBlockLoc::Show(show_parent) => {
|
BuggyBlockLoc::Show(show_parent) => {
|
||||||
if let ast::Expr::Show(show) = show_set {
|
if let ast::Expr::ShowRule(show) = show_set {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"consider changing parent to `show {}: it => {{ {}; it }}`",
|
"consider changing parent to `show {}: it => {{ {}; it }}`",
|
||||||
match show_parent.selector() {
|
match show_parent.selector() {
|
||||||
|
|
@ -1035,7 +1036,7 @@ impl BuggyBlockLoc<'_> {
|
||||||
} else {
|
} else {
|
||||||
"not "
|
"not "
|
||||||
};
|
};
|
||||||
if let ast::Expr::Show(show) = show_set {
|
if let ast::Expr::ShowRule(show) = show_set {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"consider changing parent to `show {}: if {neg}({}) {{ .. }}`",
|
"consider changing parent to `show {}: if {neg}({}) {{ .. }}`",
|
||||||
match show.selector() {
|
match show.selector() {
|
||||||
|
|
@ -1079,7 +1080,7 @@ enum ExprContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_show_set(it: ast::Expr) -> bool {
|
fn is_show_set(it: ast::Expr) -> bool {
|
||||||
matches!(it, ast::Expr::Set(..) | ast::Expr::Show(..))
|
matches!(it, ast::Expr::SetRule(..) | ast::Expr::ShowRule(..))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_compare_op(op: ast::BinOp) -> bool {
|
fn is_compare_op(op: ast::BinOp) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Tinymist package support for Typst."
|
||||||
categories = ["compilers"]
|
categories = ["compilers"]
|
||||||
keywords = ["api", "language", "typst"]
|
keywords = ["api", "language", "typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Project model of typst for tinymist."
|
||||||
categories = ["compilers"]
|
categories = ["compilers"]
|
||||||
keywords = ["language", "typst"]
|
keywords = ["language", "typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ impl<'a> ColorExprWorker<'a> {
|
||||||
|
|
||||||
fn push_color(&mut self, range: Range<usize>, color: Color) -> Option<()> {
|
fn push_color(&mut self, range: Range<usize>, color: Color) -> Option<()> {
|
||||||
let rng = self.ctx.to_lsp_range(range, &self.source);
|
let rng = self.ctx.to_lsp_range(range, &self.source);
|
||||||
let [r, g, b, a] = color.to_rgb().to_vec4();
|
let (r, g, b, a) = color.to_rgb().into_components();
|
||||||
|
|
||||||
self.colors.push(ColorInformation {
|
self.colors.push(ColorInformation {
|
||||||
range: rng,
|
range: rng,
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ impl<'a> CompletionCursor<'a> {
|
||||||
|
|
||||||
LspCompletion {
|
LspCompletion {
|
||||||
label: item.label.clone(),
|
label: item.label.clone(),
|
||||||
kind: item.kind,
|
kind: item.kind.clone(),
|
||||||
detail: item.detail.clone(),
|
detail: item.detail.clone(),
|
||||||
sort_text: item.sort_text.clone(),
|
sort_text: item.sort_text.clone(),
|
||||||
filter_text: item.filter_text.clone(),
|
filter_text: item.filter_text.clone(),
|
||||||
|
|
@ -853,17 +853,46 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
|
|
||||||
/// If is printable, return the symbol itself.
|
/// If is printable, return the symbol itself.
|
||||||
/// Otherwise, return the symbol's unicode detailed description.
|
/// Otherwise, return the symbol's unicode detailed description.
|
||||||
pub fn symbol_detail(ch: char) -> EcoString {
|
pub fn symbol_detail(s: &str) -> EcoString {
|
||||||
let ld = symbol_label_detail(ch);
|
let ld = symbol_label_detail(s);
|
||||||
if ld.starts_with("\\u") {
|
if ld.starts_with("\\u") {
|
||||||
return ld;
|
return ld;
|
||||||
}
|
}
|
||||||
format!("{}, unicode: `\\u{{{:04x}}}`", ld, ch as u32).into()
|
|
||||||
|
let mut chars = s.chars();
|
||||||
|
let unicode_repr = if let (Some(ch), None) = (chars.next(), chars.next()) {
|
||||||
|
format!("\\u{{{:04x}}}", ch as u32)
|
||||||
|
} else {
|
||||||
|
let codes: Vec<String> = s
|
||||||
|
.chars()
|
||||||
|
.map(|ch| format!("\\u{{{:04x}}}", ch as u32))
|
||||||
|
.collect();
|
||||||
|
codes.join(" + ")
|
||||||
|
};
|
||||||
|
|
||||||
|
format!("{ld}, unicode: `{unicode_repr}`").into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If is printable, return the symbol itself.
|
/// If is printable, return the symbol itself.
|
||||||
/// Otherwise, return the symbol's unicode description.
|
/// Otherwise, return the symbol's unicode description.
|
||||||
pub fn symbol_label_detail(ch: char) -> EcoString {
|
pub fn symbol_label_detail(s: &str) -> EcoString {
|
||||||
|
let mut chars = s.chars();
|
||||||
|
if let (Some(ch), None) = (chars.next(), chars.next()) {
|
||||||
|
return symbol_label_detail_single_char(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.chars().all(|ch| !ch.is_whitespace() && !ch.is_control()) {
|
||||||
|
return s.into();
|
||||||
|
}
|
||||||
|
|
||||||
|
let codes: Vec<String> = s
|
||||||
|
.chars()
|
||||||
|
.map(|ch| format!("\\u{{{:04x}}}", ch as u32))
|
||||||
|
.collect();
|
||||||
|
codes.join(" + ").into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn symbol_label_detail_single_char(ch: char) -> EcoString {
|
||||||
if !ch.is_whitespace() && !ch.is_control() {
|
if !ch.is_whitespace() && !ch.is_control() {
|
||||||
return ch.into();
|
return ch.into();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
// "#import "path.typ":|"
|
// "#import "path.typ":|"
|
||||||
if matches!(self.cursor.leaf.kind(), SyntaxKind::Colon)
|
if matches!(self.cursor.leaf.kind(), SyntaxKind::Colon)
|
||||||
&& let Some(parent) = self.cursor.leaf.clone().parent()
|
&& let Some(parent) = self.cursor.leaf.clone().parent()
|
||||||
&& let Some(ast::Expr::Import(import)) = parent.get().cast()
|
&& let Some(ast::Expr::ModuleImport(import)) = parent.get().cast()
|
||||||
&& !matches!(import.imports(), Some(ast::Imports::Wildcard))
|
&& !matches!(import.imports(), Some(ast::Imports::Wildcard))
|
||||||
&& let Some(source) = parent.children().find(|child| child.is::<ast::Expr>())
|
&& let Some(source) = parent.children().find(|child| child.is::<ast::Expr>())
|
||||||
{
|
{
|
||||||
|
|
@ -31,7 +31,7 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
// "#import "path.typ": a, b, |".
|
// "#import "path.typ": a, b, |".
|
||||||
|
|
||||||
if let Some(prev) = self.cursor.leaf.prev_sibling()
|
if let Some(prev) = self.cursor.leaf.prev_sibling()
|
||||||
&& let Some(ast::Expr::Import(import)) = prev.get().cast()
|
&& let Some(ast::Expr::ModuleImport(import)) = prev.get().cast()
|
||||||
&& !self.cursor.text[prev.offset()..self.cursor.cursor].contains('\n')
|
&& !self.cursor.text[prev.offset()..self.cursor.cursor].contains('\n')
|
||||||
&& let Some(ast::Imports::Items(items)) = import.imports()
|
&& let Some(ast::Imports::Items(items)) = import.imports()
|
||||||
&& let Some(source) = prev.children().find(|child| child.is::<ast::Expr>())
|
&& let Some(source) = prev.children().find(|child| child.is::<ast::Expr>())
|
||||||
|
|
@ -47,7 +47,7 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
&& let Some(parent) = self.cursor.leaf.clone().parent()
|
&& let Some(parent) = self.cursor.leaf.clone().parent()
|
||||||
&& parent.kind() == SyntaxKind::ImportItems
|
&& parent.kind() == SyntaxKind::ImportItems
|
||||||
&& let Some(grand) = parent.parent()
|
&& let Some(grand) = parent.parent()
|
||||||
&& let Some(ast::Expr::Import(import)) = grand.get().cast()
|
&& let Some(ast::Expr::ModuleImport(import)) = grand.get().cast()
|
||||||
&& let Some(ast::Imports::Items(items)) = import.imports()
|
&& let Some(ast::Imports::Items(items)) = import.imports()
|
||||||
&& let Some(source) = grand.children().find(|child| child.is::<ast::Expr>())
|
&& let Some(source) = grand.children().find(|child| child.is::<ast::Expr>())
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +64,7 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
&& let Some(parent) = path_ctx.parent()
|
&& let Some(parent) = path_ctx.parent()
|
||||||
&& parent.kind() == SyntaxKind::ImportItems
|
&& parent.kind() == SyntaxKind::ImportItems
|
||||||
&& let Some(grand) = parent.parent()
|
&& let Some(grand) = parent.parent()
|
||||||
&& let Some(ast::Expr::Import(import)) = grand.get().cast()
|
&& let Some(ast::Expr::ModuleImport(import)) = grand.get().cast()
|
||||||
&& let Some(ast::Imports::Items(items)) = import.imports()
|
&& let Some(ast::Imports::Items(items)) = import.imports()
|
||||||
&& let Some(source) = grand.children().find(|child| child.is::<ast::Expr>())
|
&& let Some(source) = grand.children().find(|child| child.is::<ast::Expr>())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ pub(crate) fn value_to_completion_kind(value: &Value) -> CompletionKind {
|
||||||
Value::Func(..) => CompletionKind::Func,
|
Value::Func(..) => CompletionKind::Func,
|
||||||
Value::Module(..) => CompletionKind::Module,
|
Value::Module(..) => CompletionKind::Module,
|
||||||
Value::Type(..) => CompletionKind::Type,
|
Value::Type(..) => CompletionKind::Type,
|
||||||
Value::Symbol(s) => CompletionKind::Symbol(s.get()),
|
Value::Symbol(s) => CompletionKind::Symbol(s.get().into()),
|
||||||
Value::None
|
Value::None
|
||||||
| Value::Auto
|
| Value::Auto
|
||||||
| Value::Bool(..)
|
| Value::Bool(..)
|
||||||
|
|
|
||||||
|
|
@ -255,13 +255,13 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symbol_completions(&mut self, label: EcoString, symbol: &Symbol) {
|
pub fn symbol_completions(&mut self, label: EcoString, symbol: &Symbol) {
|
||||||
let ch = symbol.get();
|
let sym_val = symbol.get();
|
||||||
let kind = CompletionKind::Symbol(ch);
|
let kind = CompletionKind::Symbol(sym_val.into());
|
||||||
self.push_completion(Completion {
|
self.push_completion(Completion {
|
||||||
kind,
|
kind,
|
||||||
label: label.clone(),
|
label: label.clone(),
|
||||||
label_details: Some(symbol_label_detail(ch)),
|
label_details: Some(symbol_label_detail(sym_val)),
|
||||||
detail: Some(symbol_detail(ch)),
|
detail: Some(symbol_detail(sym_val)),
|
||||||
..Completion::default()
|
..Completion::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
|
|
||||||
pub fn symbol_var_completions(&mut self, symbol: &Symbol, prefix: Option<&str>) {
|
pub fn symbol_var_completions(&mut self, symbol: &Symbol, prefix: Option<&str>) {
|
||||||
for modifier in symbol.modifiers() {
|
for modifier in symbol.modifiers() {
|
||||||
if let Ok(modified) = symbol.clone().modified(modifier) {
|
if let Ok(modified) = symbol.clone().modified((), modifier) {
|
||||||
let label = match &prefix {
|
let label = match &prefix {
|
||||||
Some(prefix) => eco_format!("{prefix}.{modifier}"),
|
Some(prefix) => eco_format!("{prefix}.{modifier}"),
|
||||||
None => modifier.into(),
|
None => modifier.into(),
|
||||||
|
|
|
||||||
|
|
@ -200,13 +200,11 @@ fn ref_definition(
|
||||||
name: &str,
|
name: &str,
|
||||||
ref_expr: ast::Expr,
|
ref_expr: ast::Expr,
|
||||||
) -> Option<Definition> {
|
) -> Option<Definition> {
|
||||||
let label = Label::construct(name.into());
|
|
||||||
let sel = Selector::Label(label);
|
|
||||||
|
|
||||||
// if it is a label, we put the selection range to itself
|
// if it is a label, we put the selection range to itself
|
||||||
let (decl, ty) = match ref_expr {
|
let (decl, ty) = match ref_expr {
|
||||||
ast::Expr::Label(label) => (Decl::label(name, label.span()), None),
|
ast::Expr::Label(label) => (Decl::label(name, label.span()), None),
|
||||||
ast::Expr::Ref(..) => {
|
ast::Expr::Ref(..) => {
|
||||||
|
let sel = Selector::Label(Label::construct(name.into()).ok()?);
|
||||||
let elem = introspector.query_first(&sel)?;
|
let elem = introspector.query_first(&sel)?;
|
||||||
let span = elem.labelled_at();
|
let span = elem.labelled_at();
|
||||||
let decl = if !span.is_detached() {
|
let decl = if !span.is_detached() {
|
||||||
|
|
|
||||||
|
|
@ -1447,7 +1447,7 @@ fn analyze_bib(
|
||||||
|
|
||||||
// todo: it doesn't respect the style chain which can be get from
|
// todo: it doesn't respect the style chain which can be get from
|
||||||
// `analyze_expr`
|
// `analyze_expr`
|
||||||
let csl_style = bib_elem.style(StyleChain::default()).derived;
|
let csl_style = bib_elem.style.get_cloned(StyleChain::default()).derived;
|
||||||
|
|
||||||
let Value::Array(paths) = bib_elem.sources.clone().into_value() else {
|
let Value::Array(paths) = bib_elem.sources.clone().into_value() else {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
||||||
|
|
@ -415,8 +415,8 @@ impl Tokenizer {
|
||||||
PositionEncoding::Utf8 => t - s,
|
PositionEncoding::Utf8 => t - s,
|
||||||
PositionEncoding::Utf16 => {
|
PositionEncoding::Utf16 => {
|
||||||
// todo: whether it is safe to unwrap
|
// todo: whether it is safe to unwrap
|
||||||
let utf16_start = self.source.byte_to_utf16(s).unwrap();
|
let utf16_start = self.source.lines().byte_to_utf16(s).unwrap();
|
||||||
let utf16_end = self.source.byte_to_utf16(t).unwrap();
|
let utf16_end = self.source.lines().byte_to_utf16(t).unwrap();
|
||||||
utf16_end - utf16_start
|
utf16_end - utf16_start
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -432,12 +432,14 @@ impl Tokenizer {
|
||||||
});
|
});
|
||||||
self.curr_pos = position;
|
self.curr_pos = position;
|
||||||
} else {
|
} else {
|
||||||
let final_line = self
|
let final_line =
|
||||||
.source
|
self.source
|
||||||
.byte_to_line(utf8_end)
|
.lines()
|
||||||
.unwrap_or_else(|| self.source.len_lines()) as u32;
|
.byte_to_line(utf8_end)
|
||||||
|
.unwrap_or_else(|| self.source.lines().len_lines()) as u32;
|
||||||
let next_offset = self
|
let next_offset = self
|
||||||
.source
|
.source
|
||||||
|
.lines()
|
||||||
.line_to_byte((self.curr_pos.line + 1) as usize)
|
.line_to_byte((self.curr_pos.line + 1) as usize)
|
||||||
.unwrap_or(source_len);
|
.unwrap_or(source_len);
|
||||||
let inline_length = encode_length(utf8_start, utf8_end.min(next_offset)) as u32;
|
let inline_length = encode_length(utf8_start, utf8_end.min(next_offset)) as u32;
|
||||||
|
|
@ -462,6 +464,7 @@ impl Tokenizer {
|
||||||
utf8_end
|
utf8_end
|
||||||
} else {
|
} else {
|
||||||
self.source
|
self.source
|
||||||
|
.lines()
|
||||||
.line_to_byte((line + 1) as usize)
|
.line_to_byte((line + 1) as usize)
|
||||||
.unwrap_or(source_len)
|
.unwrap_or(source_len)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tinymist_analysis::analyze_expr;
|
use tinymist_analysis::analyze_expr;
|
||||||
use tinymist_world::ShadowApi;
|
use tinymist_world::ShadowApi;
|
||||||
use typst::foundations::{Bytes, IntoValue, StyleChain};
|
use typst::{
|
||||||
|
foundations::{Bytes, IntoValue, StyleChain},
|
||||||
|
text::TextElem,
|
||||||
|
};
|
||||||
use typst_shim::syntax::LinkedNodeExt;
|
use typst_shim::syntax::LinkedNodeExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -157,9 +160,7 @@ impl InteractCodeContextRequest {
|
||||||
fn style_at(cursor_style: StyleChain, style: &str) -> Option<JsonValue> {
|
fn style_at(cursor_style: StyleChain, style: &str) -> Option<JsonValue> {
|
||||||
match style {
|
match style {
|
||||||
"text.font" => {
|
"text.font" => {
|
||||||
let font = typst::text::TextElem::font_in(cursor_style)
|
let font = cursor_style.get_cloned(TextElem::font).into_value();
|
||||||
.clone()
|
|
||||||
.into_value();
|
|
||||||
serde_json::to_value(font).ok()
|
serde_json::to_value(font).ok()
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use typst::foundations::Repr;
|
use typst::foundations::Repr;
|
||||||
|
use typst::visualize::Color;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
|
@ -42,15 +43,15 @@ impl ColorPresentationRequest {
|
||||||
));
|
));
|
||||||
Some(vec![
|
Some(vec![
|
||||||
simple(format!("{:?}", color.to_hex())),
|
simple(format!("{:?}", color.to_hex())),
|
||||||
simple(color.to_rgb().repr().to_string()),
|
simple(Color::Rgb(color.to_rgb()).repr().to_string()),
|
||||||
simple(color.to_luma().repr().to_string()),
|
simple(Color::Luma(color.to_luma()).repr().to_string()),
|
||||||
simple(color.to_oklab().repr().to_string()),
|
simple(Color::Oklab(color.to_oklab()).repr().to_string()),
|
||||||
simple(color.to_oklch().repr().to_string()),
|
simple(Color::Oklch(color.to_oklch()).repr().to_string()),
|
||||||
simple(color.to_rgb().repr().to_string()),
|
simple(Color::Rgb(color.to_rgb()).repr().to_string()),
|
||||||
simple(color.to_linear_rgb().repr().to_string()),
|
simple(Color::LinearRgb(color.to_linear_rgb()).repr().to_string()),
|
||||||
simple(color.to_cmyk().repr().to_string()),
|
simple(Color::Cmyk(color.to_cmyk()).repr().to_string()),
|
||||||
simple(color.to_hsl().repr().to_string()),
|
simple(Color::Hsl(color.to_hsl()).repr().to_string()),
|
||||||
simple(color.to_hsv().repr().to_string()),
|
simple(Color::Hsv(color.to_hsv()).repr().to_string()),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::StrRef;
|
||||||
use super::LspRange;
|
use super::LspRange;
|
||||||
|
|
||||||
/// A kind of item that can be completed.
|
/// A kind of item that can be completed.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||||
pub enum CompletionKind {
|
pub enum CompletionKind {
|
||||||
/// A syntactical structure.
|
/// A syntactical structure.
|
||||||
Syntax,
|
Syntax,
|
||||||
|
|
@ -25,7 +25,7 @@ pub enum CompletionKind {
|
||||||
/// A reference.
|
/// A reference.
|
||||||
Reference,
|
Reference,
|
||||||
/// A symbol.
|
/// A symbol.
|
||||||
Symbol(char),
|
Symbol(EcoString),
|
||||||
/// A variable.
|
/// A variable.
|
||||||
Variable,
|
Variable,
|
||||||
/// A module.
|
/// A module.
|
||||||
|
|
@ -36,8 +36,8 @@ pub enum CompletionKind {
|
||||||
Folder,
|
Folder,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CompletionKind> for lsp_types::CompletionItemKind {
|
impl From<&CompletionKind> for lsp_types::CompletionItemKind {
|
||||||
fn from(value: CompletionKind) -> Self {
|
fn from(value: &CompletionKind) -> Self {
|
||||||
match value {
|
match value {
|
||||||
CompletionKind::Syntax => Self::SNIPPET,
|
CompletionKind::Syntax => Self::SNIPPET,
|
||||||
CompletionKind::Func => Self::FUNCTION,
|
CompletionKind::Func => Self::FUNCTION,
|
||||||
|
|
@ -60,7 +60,7 @@ impl serde::Serialize for CompletionKind {
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
<Self as Into<lsp_types::CompletionItemKind>>::into(*self).serialize(serializer)
|
<&Self as Into<lsp_types::CompletionItemKind>>::into(self).serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,8 @@ impl DocumentMetricsWorker<'_> {
|
||||||
let range = source.range(span)?;
|
let range = source.range(span)?;
|
||||||
let byte_index = range.start + usize::from(span_offset);
|
let byte_index = range.start + usize::from(span_offset);
|
||||||
let byte_index = byte_index.min(range.end - 1);
|
let byte_index = byte_index.min(range.end - 1);
|
||||||
let line = source.byte_to_line(byte_index)?;
|
let line = source.lines().byte_to_line(byte_index)?;
|
||||||
let column = source.byte_to_column(byte_index)?;
|
let column = source.lines().byte_to_column(byte_index)?;
|
||||||
|
|
||||||
let filepath = self.ctx.path_for_id(file_id).ok()?;
|
let filepath = self.ctx.path_for_id(file_id).ok()?;
|
||||||
let filepath_str = filepath.as_path().display().to_string();
|
let filepath_str = filepath.as_path().display().to_string();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/builtin_shadow.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(fill-rest: false) => none"
|
"description": "(fill-rest: false) => none"
|
||||||
},
|
},
|
||||||
"sortText": "139",
|
"sortText": "138",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/builtin_shadow_existin
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(fill-rest: false) => none"
|
"description": "(fill-rest: false) => none"
|
||||||
},
|
},
|
||||||
"sortText": "141",
|
"sortText": "139",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/colon_markup.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, b: content | none, bl: content | none, br: content | none, t: content | none, tl: content | none, tr: content | none) => attach"
|
"description": "(content, b: content | none, bl: content | none, br: content | none, t: content | none, tl: content | none, tr: content | none) => attach"
|
||||||
},
|
},
|
||||||
"sortText": "076",
|
"sortText": "080",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " attach(${1:})",
|
"newText": " attach(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/colon_math.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, b: content | none, bl: content | none, br: content | none, t: content | none, tl: content | none, tr: content | none) => attach"
|
"description": "(content, b: content | none, bl: content | none, br: content | none, t: content | none, tl: content | none, tr: content | none) => attach"
|
||||||
},
|
},
|
||||||
"sortText": "076",
|
"sortText": "080",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " attach(${1:})",
|
"newText": " attach(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/context_code_init.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "140",
|
"sortText": "139",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/context_init.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "140",
|
"sortText": "139",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/element_where.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "content | none"
|
"description": "content | none"
|
||||||
},
|
},
|
||||||
"sortText": "000",
|
"sortText": "001",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "caption: ${1:}",
|
"newText": "caption: ${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/func_module_raw.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "160",
|
"sortText": "159",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw",
|
"newText": "raw",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -43,7 +43,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/func_module_raw.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "161",
|
"sortText": "160",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw(${1:})",
|
"newText": "raw(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/half_completion.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "array | text.font"
|
"description": "array | text.font"
|
||||||
},
|
},
|
||||||
"sortText": "010",
|
"sortText": "011",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "font: ${1:}, ",
|
"newText": "font: ${1:}, ",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -48,7 +48,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/half_completion.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "array | text.font"
|
"description": "array | text.font"
|
||||||
},
|
},
|
||||||
"sortText": "010",
|
"sortText": "011",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "font: ${1:}",
|
"newText": "font: ${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/hash.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "139",
|
"sortText": "138",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/hash_ident.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "139",
|
"sortText": "138",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/hash_math.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "139",
|
"sortText": "138",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/hash_math_ident.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "139",
|
"sortText": "138",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/import_star_typing.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content) => content"
|
"description": "(content) => content"
|
||||||
},
|
},
|
||||||
"sortText": "218",
|
"sortText": "219",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "todo(${1:})",
|
"newText": "todo(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -48,7 +48,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/import_star_typing.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content) => content"
|
"description": "(content) => content"
|
||||||
},
|
},
|
||||||
"sortText": "218",
|
"sortText": "219",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "todo(${1:})",
|
"newText": "todo(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/import_typing.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content) => content"
|
"description": "(content) => content"
|
||||||
},
|
},
|
||||||
"sortText": "217",
|
"sortText": "218",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "todo(${1:})",
|
"newText": "todo(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -48,7 +48,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/import_typing.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content) => content"
|
"description": "(content) => content"
|
||||||
},
|
},
|
||||||
"sortText": "217",
|
"sortText": "218",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "todo(${1:})",
|
"newText": "todo(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/let_closure_init.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "141",
|
"sortText": "140",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/let_fn_init.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "141",
|
"sortText": "140",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/let_init.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
|
||||||
},
|
},
|
||||||
"sortText": "141",
|
"sortText": "140",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "pagebreak()${1:}",
|
"newText": "pagebreak()${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_bold2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content) => content"
|
"description": "(content) => content"
|
||||||
},
|
},
|
||||||
"sortText": "087",
|
"sortText": "093",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "bold(${1:})",
|
"newText": "bold(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "057",
|
"sortText": "059",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "abs(${1:})",
|
"newText": "abs(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "056",
|
"sortText": "058",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "abs(${1:})",
|
"newText": "abs(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call3.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "055",
|
"sortText": "057",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "abs(${1:})",
|
"newText": "abs(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call4.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "055",
|
"sortText": "057",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "abs(${1:})",
|
"newText": "abs(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs
|
||||||
description: Completion on / (22..23)
|
description: Completion on / (22..23)
|
||||||
expression: "JsonRepr::new_pure(results)"
|
expression: "JsonRepr::new_pure(results)"
|
||||||
input_file: crates/tinymist-query/src/fixtures/completion/math_ident.typ
|
input_file: crates/tinymist-query/src/fixtures/completion/math_ident.typ
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|
@ -15,7 +14,7 @@ snapshot_kind: text
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "ℜ"
|
"description": "ℜ"
|
||||||
},
|
},
|
||||||
"sortText": "039",
|
"sortText": "040",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "Re",
|
"newText": "Re",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_ident_in_call.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "229",
|
"sortText": "259",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "norm(${1:})",
|
"newText": "norm(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/math_ident_in_call2.ty
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, size: relative) => content"
|
"description": "(content, size: relative) => content"
|
||||||
},
|
},
|
||||||
"sortText": "230",
|
"sortText": "260",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "norm(${1:})",
|
"newText": "norm(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs
|
||||||
description: Completion on / (21..22)
|
description: Completion on / (21..22)
|
||||||
expression: "JsonRepr::new_pure(results)"
|
expression: "JsonRepr::new_pure(results)"
|
||||||
input_file: crates/tinymist-query/src/fixtures/completion/math_text.typ
|
input_file: crates/tinymist-query/src/fixtures/completion/math_text.typ
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|
@ -15,7 +14,7 @@ snapshot_kind: text
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "ℜ"
|
"description": "ℜ"
|
||||||
},
|
},
|
||||||
"sortText": "039",
|
"sortText": "040",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "Re",
|
"newText": "Re",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/mode_math.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "op(text: [tanh], limits: false)"
|
"description": "op(text: [tanh], limits: false)"
|
||||||
},
|
},
|
||||||
"sortText": "318",
|
"sortText": "361",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "tanh",
|
"newText": "tanh",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,31 @@ input_file: crates/tinymist-query/src/fixtures/completion/set_param.typ
|
||||||
{
|
{
|
||||||
"isIncomplete": false,
|
"isIncomplete": false,
|
||||||
"items": [
|
"items": [
|
||||||
|
{
|
||||||
|
"command": {
|
||||||
|
"command": "tinymist.triggerSuggestAndParameterHints",
|
||||||
|
"title": ""
|
||||||
|
},
|
||||||
|
"kind": 5,
|
||||||
|
"label": "body",
|
||||||
|
"labelDetails": {
|
||||||
|
"description": "content"
|
||||||
|
},
|
||||||
|
"sortText": "002",
|
||||||
|
"textEdit": {
|
||||||
|
"newText": "body: ${1:}",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 1
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": {
|
"command": {
|
||||||
"command": "tinymist.triggerSuggestAndParameterHints",
|
"command": "tinymist.triggerSuggestAndParameterHints",
|
||||||
|
|
@ -18,7 +43,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/set_param.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "color"
|
"description": "color"
|
||||||
},
|
},
|
||||||
"sortText": "009",
|
"sortText": "010",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "fill: ${1:}",
|
"newText": "fill: ${1:}",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "227",
|
"sortText": "226",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw",
|
"newText": "raw",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -43,7 +43,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "229",
|
"sortText": "228",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw.with(${1:})",
|
"newText": "raw.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "230",
|
"sortText": "229",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "read(${1:})",
|
"newText": "read(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -93,7 +93,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "231",
|
"sortText": "230",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "read.with(${1:})",
|
"newText": "read.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -115,7 +115,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform.typ
|
||||||
},
|
},
|
||||||
"kind": 15,
|
"kind": 15,
|
||||||
"label": "replacement",
|
"label": "replacement",
|
||||||
"sortText": "244",
|
"sortText": "243",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "[${1:content}]",
|
"newText": "[${1:content}]",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "227",
|
"sortText": "226",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw",
|
"newText": "raw",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -43,7 +43,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "229",
|
"sortText": "228",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "raw.with(${1:})",
|
"newText": "raw.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "230",
|
"sortText": "229",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "read(${1:})",
|
"newText": "read(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -93,7 +93,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform2.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "231",
|
"sortText": "230",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "read.with(${1:})",
|
"newText": "read.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -115,7 +115,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform2.typ
|
||||||
},
|
},
|
||||||
"kind": 15,
|
"kind": 15,
|
||||||
"label": "replacement",
|
"label": "replacement",
|
||||||
"sortText": "244",
|
"sortText": "243",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "[${1:content}]",
|
"newText": "[${1:content}]",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform3.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "227",
|
"sortText": "226",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " raw",
|
"newText": " raw",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -43,7 +43,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform3.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
|
||||||
},
|
},
|
||||||
"sortText": "229",
|
"sortText": "228",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " raw.with(${1:})",
|
"newText": " raw.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform3.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "230",
|
"sortText": "229",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " read(${1:})",
|
"newText": " read(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -93,7 +93,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform3.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
"description": "([any], encoding: \"utf8\" | none) => bytes | str"
|
||||||
},
|
},
|
||||||
"sortText": "231",
|
"sortText": "230",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " read.with(${1:})",
|
"newText": " read.with(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
@ -115,7 +115,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show_transform3.typ
|
||||||
},
|
},
|
||||||
"kind": 15,
|
"kind": 15,
|
||||||
"label": "replacement",
|
"label": "replacement",
|
||||||
"sortText": "244",
|
"sortText": "243",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": " [${1:content}]",
|
"newText": " [${1:content}]",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -29,29 +29,32 @@ A table of items.
|
||||||
Tables are used to arrange content in cells. Cells can contain arbitrary
|
Tables are used to arrange content in cells. Cells can contain arbitrary
|
||||||
content, including multiple paragraphs and are specified in row-major order.
|
content, including multiple paragraphs and are specified in row-major order.
|
||||||
For a hands-on explanation of all the ways you can use and customize tables
|
For a hands-on explanation of all the ways you can use and customize tables
|
||||||
in Typst, check out the [table guide](https://typst.app/docs/guides/table-guide/).
|
in Typst, check out the [Table Guide](https://typst.app/docs/guides/tables/).
|
||||||
|
|
||||||
Because tables are just grids with different defaults for some cell
|
Because tables are just grids with different defaults for some cell
|
||||||
properties (notably `stroke` and `inset`), refer to the [grid
|
properties (notably `stroke` and `inset`), refer to the [grid
|
||||||
documentation](https://typst.app/docs/reference/layout/grid/) for more information on how to size the table tracks
|
documentation](https://typst.app/docs/reference/layout/grid/#track-size) for more information on how to size the
|
||||||
and specify the cell appearance properties.
|
table tracks and specify the cell appearance properties.
|
||||||
|
|
||||||
If you are unsure whether you should be using a table or a grid, consider
|
If you are unsure whether you should be using a table or a grid, consider
|
||||||
whether the content you are arranging semantically belongs together as a set
|
whether the content you are arranging semantically belongs together as a set
|
||||||
of related data points or similar or whether you are just want to enhance
|
of related data points or similar or whether you are just want to enhance
|
||||||
your presentation by arranging unrelated content in a grid. In the former
|
your presentation by arranging unrelated content in a grid. In the former
|
||||||
case, a table is the right choice, while in the latter case, a grid is more
|
case, a table is the right choice, while in the latter case, a grid is more
|
||||||
appropriate. Furthermore, Typst will annotate its output in the future such
|
appropriate. Furthermore, Assistive Technology (AT) like screen readers will
|
||||||
that screenreaders will announce content in `table` as tabular while a
|
announce content in a `table` as tabular while a grid's content will be
|
||||||
grid's content will be announced no different than multiple content blocks
|
announced no different than multiple content blocks in the document flow. AT
|
||||||
in the document flow.
|
users will be able to navigate tables two-dimensionally by cell.
|
||||||
|
|
||||||
Note that, to override a particular cell's properties or apply show rules on
|
Note that, to override a particular cell's properties or apply show rules on
|
||||||
table cells, you can use the [`table.cell`](https://typst.app/docs/reference/model/table/#definitions-cell) element. See its
|
table cells, you can use the [`table.cell`] element. See its documentation
|
||||||
documentation for more information.
|
for more information.
|
||||||
|
|
||||||
Although the `table` and the `grid` share most properties, set and show
|
Although the `table` and the `grid` share most properties, set and show
|
||||||
rules on one of them do not affect the other.
|
rules on one of them do not affect the other. Locating most of your styling
|
||||||
|
in set and show rules is recommended, as it keeps the table's actual usages
|
||||||
|
clean and easy to read. It also allows you to easily change the appearance
|
||||||
|
of all tables in one place.
|
||||||
|
|
||||||
To give a table a caption and make it [referenceable](https://typst.app/docs/reference/model/ref/), put it into a
|
To give a table a caption and make it [referenceable](https://typst.app/docs/reference/model/ref/), put it into a
|
||||||
[figure].
|
[figure].
|
||||||
|
|
@ -80,8 +83,8 @@ The example below demonstrates some of the most common table options.
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Much like with grids, you can use [`table.cell`](https://typst.app/docs/reference/model/table/#definitions-cell) to customize
|
Much like with grids, you can use [`table.cell`] to customize the appearance
|
||||||
the appearance and the position of each cell.
|
and the position of each cell.
|
||||||
|
|
||||||
```typ
|
```typ
|
||||||
>>> #set page(width: auto)
|
>>> #set page(width: auto)
|
||||||
|
|
@ -125,6 +128,18 @@ the appearance and the position of each cell.
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Accessibility
|
||||||
|
Tables are challenging to consume for users of Assistive Technology (AT). To
|
||||||
|
make the life of AT users easier, we strongly recommend that you use
|
||||||
|
[`table.header`] and [`table.footer`] to mark the header and footer sections
|
||||||
|
of your table. This will allow AT to announce the column labels for each
|
||||||
|
cell.
|
||||||
|
|
||||||
|
Because navigating a table by cell is more cumbersome than reading it
|
||||||
|
visually, you should consider making the core information in your table
|
||||||
|
available as text as well. You can do this by wrapping your table in a
|
||||||
|
[figure] and using its caption to summarize the table's content.
|
||||||
|
|
||||||
# Rest Parameters
|
# Rest Parameters
|
||||||
|
|
||||||
## children
|
## children
|
||||||
|
|
@ -134,8 +149,7 @@ type: content
|
||||||
```
|
```
|
||||||
|
|
||||||
The contents of the table cells, plus any extra table lines specified
|
The contents of the table cells, plus any extra table lines specified
|
||||||
with the [`table.hline`](https://typst.app/docs/reference/model/table/#definitions-hline) and
|
with the [`table.hline`] and [`table.vline`] elements.
|
||||||
[`table.vline`](https://typst.app/docs/reference/model/table/#definitions-vline) elements.
|
|
||||||
|
|
||||||
# Named Parameters
|
# Named Parameters
|
||||||
|
|
||||||
|
|
@ -147,10 +161,15 @@ type: alignment | array | auto | function
|
||||||
|
|
||||||
How to align the cells' content.
|
How to align the cells' content.
|
||||||
|
|
||||||
This can either be a single alignment, an array of alignments
|
If set to `auto`, the outer alignment is used.
|
||||||
(corresponding to each column) or a function that returns an alignment.
|
|
||||||
The function receives the cells' column and row indices, starting from
|
You can specify the alignment in any of the following fashions:
|
||||||
zero. If set to `auto`, the outer alignment is used.
|
- use a single alignment for all cells
|
||||||
|
- use an array of alignments corresponding to each column
|
||||||
|
- use a function that maps a cell's X/Y position (both starting from
|
||||||
|
zero) to its alignment
|
||||||
|
|
||||||
|
See the [Table Guide](https://typst.app/docs/guides/tables/#alignment) for details.
|
||||||
|
|
||||||
```typ
|
```typ
|
||||||
#table(
|
#table(
|
||||||
|
|
@ -168,7 +187,7 @@ type: array | auto | length | type
|
||||||
```
|
```
|
||||||
|
|
||||||
The gaps between columns. Takes precedence over `gutter`. See the
|
The gaps between columns. Takes precedence over `gutter`. See the
|
||||||
[grid documentation](https://typst.app/docs/reference/layout/grid/) for more information on gutters.
|
[grid documentation](https://typst.app/docs/reference/layout/grid/#parameters-gutter) for more information on gutters.
|
||||||
|
|
||||||
## columns (named)
|
## columns (named)
|
||||||
|
|
||||||
|
|
@ -176,8 +195,8 @@ The gaps between columns. Takes precedence over `gutter`. See the
|
||||||
type: array | auto | length | type
|
type: array | auto | length | type
|
||||||
```
|
```
|
||||||
|
|
||||||
The column sizes. See the [grid documentation](https://typst.app/docs/reference/layout/grid/) for more
|
The column sizes. See the [grid documentation](https://typst.app/docs/reference/layout/grid/#track-size) for
|
||||||
information on track sizing.
|
more information on track sizing.
|
||||||
|
|
||||||
## fill (named)
|
## fill (named)
|
||||||
|
|
||||||
|
|
@ -187,9 +206,14 @@ type: color
|
||||||
|
|
||||||
How to fill the cells.
|
How to fill the cells.
|
||||||
|
|
||||||
This can be a color or a function that returns a color. The function
|
This can be:
|
||||||
receives the cells' column and row indices, starting from zero. This can
|
- a single fill for all cells
|
||||||
be used to implement striped tables.
|
- an array of fill corresponding to each column
|
||||||
|
- a function that maps a cell's position to its fill
|
||||||
|
|
||||||
|
Most notably, arrays and functions are useful for creating striped
|
||||||
|
tables. See the [Table Guide](https://typst.app/docs/guides/tables/#fills) for more
|
||||||
|
details.
|
||||||
|
|
||||||
```typ
|
```typ
|
||||||
#table(
|
#table(
|
||||||
|
|
@ -216,7 +240,7 @@ type: array | auto | length | type
|
||||||
|
|
||||||
The gaps between rows and columns. This is a shorthand for setting
|
The gaps between rows and columns. This is a shorthand for setting
|
||||||
`column-gutter` and `row-gutter` to the same value. See the [grid
|
`column-gutter` and `row-gutter` to the same value. See the [grid
|
||||||
documentation](https://typst.app/docs/reference/layout/grid/) for more information on gutters.
|
documentation](https://typst.app/docs/reference/layout/grid/#parameters-gutter) for more information on gutters.
|
||||||
|
|
||||||
## inset (named)
|
## inset (named)
|
||||||
|
|
||||||
|
|
@ -226,8 +250,21 @@ type: inset
|
||||||
|
|
||||||
How much to pad the cells' content.
|
How much to pad the cells' content.
|
||||||
|
|
||||||
|
To specify the same inset for all cells, use a single length for all
|
||||||
|
sides, or a dictionary of lengths for individual sides. See the
|
||||||
|
[box's documentation](https://typst.app/docs/reference/layout/box/#parameters-inset) for more details.
|
||||||
|
|
||||||
|
To specify a varying inset for different cells, you can:
|
||||||
|
- use a single, uniform inset for all cells
|
||||||
|
- use an array of insets for each column
|
||||||
|
- use a function that maps a cell's X/Y position (both starting from
|
||||||
|
zero) to its inset
|
||||||
|
|
||||||
|
See the [grid documentation](https://typst.app/docs/reference/layout/grid/#styling) for more details.
|
||||||
|
|
||||||
```typ
|
```typ
|
||||||
#table(
|
#table(
|
||||||
|
columns: 2,
|
||||||
inset: 10pt,
|
inset: 10pt,
|
||||||
[Hello],
|
[Hello],
|
||||||
[World],
|
[World],
|
||||||
|
|
@ -235,10 +272,7 @@ How much to pad the cells' content.
|
||||||
|
|
||||||
#table(
|
#table(
|
||||||
columns: 2,
|
columns: 2,
|
||||||
inset: (
|
inset: (x: 20pt, y: 10pt),
|
||||||
x: 20pt,
|
|
||||||
y: 10pt,
|
|
||||||
),
|
|
||||||
[Hello],
|
[Hello],
|
||||||
[World],
|
[World],
|
||||||
)
|
)
|
||||||
|
|
@ -251,7 +285,7 @@ type: array | auto | length | type
|
||||||
```
|
```
|
||||||
|
|
||||||
The gaps between rows. Takes precedence over `gutter`. See the
|
The gaps between rows. Takes precedence over `gutter`. See the
|
||||||
[grid documentation](https://typst.app/docs/reference/layout/grid/) for more information on gutters.
|
[grid documentation](https://typst.app/docs/reference/layout/grid/#parameters-gutter) for more information on gutters.
|
||||||
|
|
||||||
## rows (named)
|
## rows (named)
|
||||||
|
|
||||||
|
|
@ -259,8 +293,8 @@ The gaps between rows. Takes precedence over `gutter`. See the
|
||||||
type: array | auto | length | type
|
type: array | auto | length | type
|
||||||
```
|
```
|
||||||
|
|
||||||
The row sizes. See the [grid documentation](https://typst.app/docs/reference/layout/grid/) for more information
|
The row sizes. See the [grid documentation](https://typst.app/docs/reference/layout/grid/#track-size) for more
|
||||||
on track sizing.
|
information on track sizing.
|
||||||
|
|
||||||
## stroke (named)
|
## stroke (named)
|
||||||
|
|
||||||
|
|
@ -273,13 +307,20 @@ How to [stroke] the cells.
|
||||||
Strokes can be disabled by setting this to `none`.
|
Strokes can be disabled by setting this to `none`.
|
||||||
|
|
||||||
If it is necessary to place lines which can cross spacing between cells
|
If it is necessary to place lines which can cross spacing between cells
|
||||||
produced by the `gutter` option, or to override the stroke between
|
produced by the [`gutter`](https://typst.app/docs/reference/model/table/#parameters-gutter) option, or to override the
|
||||||
multiple specific cells, consider specifying one or more of
|
stroke between multiple specific cells, consider specifying one or more
|
||||||
[`table.hline`](https://typst.app/docs/reference/model/table/#definitions-hline) and [`table.vline`](https://typst.app/docs/reference/model/table/#definitions-vline)
|
of [`table.hline`] and [`table.vline`] alongside your table cells.
|
||||||
alongside your table cells.
|
|
||||||
|
|
||||||
See the [grid documentation](https://typst.app/docs/reference/layout/grid/#parameters-stroke) for more information on
|
To specify the same stroke for all cells, use a single [stroke] for all
|
||||||
strokes.
|
sides, or a dictionary of [strokes](https://typst.app/docs/reference/visualize/stroke/) for individual sides. See
|
||||||
|
the [rectangle's documentation](https://typst.app/docs/reference/visualize/rect/#parameters-stroke) for more details.
|
||||||
|
|
||||||
|
To specify varying strokes for different cells, you can:
|
||||||
|
- use a single stroke for all cells
|
||||||
|
- use an array of strokes corresponding to each column
|
||||||
|
- use a function that maps a cell's position to its stroke
|
||||||
|
|
||||||
|
See the [Table Guide](https://typst.app/docs/guides/tables/#strokes) for more details.
|
||||||
|
|
||||||
|
|
||||||
======
|
======
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,15 @@ more details on compound theory.
|
||||||
In 1984, the first ...
|
In 1984, the first ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Even without manual page breaks, content will be automatically paginated
|
||||||
|
based on the configured page size. You can set [the page height](https://typst.app/docs/reference/layout/page/#parameters-height)
|
||||||
|
to `auto` to let the page grow dynamically until a manual page break
|
||||||
|
occurs.
|
||||||
|
|
||||||
|
Pagination tries to avoid single lines of text at the top or bottom of a
|
||||||
|
page (these are called _widows_ and _orphans_). You can adjust the
|
||||||
|
[`text.costs`] parameter to disable this behavior.
|
||||||
|
|
||||||
# Named Parameters
|
# Named Parameters
|
||||||
|
|
||||||
## to
|
## to
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ Ref: `fig:test1`
|
||||||
```typc
|
```typc
|
||||||
figure(
|
figure(
|
||||||
body: [Test1],
|
body: [Test1],
|
||||||
|
alt: none,
|
||||||
placement: none,
|
placement: none,
|
||||||
scope: "column",
|
scope: "column",
|
||||||
caption: none,
|
caption: none,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-core-slides.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, gap: length, justify: bool) => repeat"
|
"description": "(content, gap: length, justify: bool) => repeat"
|
||||||
},
|
},
|
||||||
"sortText": "177",
|
"sortText": "176",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "repeat(${1:})",
|
"newText": "repeat(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ description: "Check on \"(\" (18)"
|
||||||
expression: post_ty
|
expression: post_ty
|
||||||
input_file: crates/tinymist-query/src/fixtures/post_type_check/with_element.typ
|
input_file: crates/tinymist-query/src/fixtures/post_type_check/with_element.typ
|
||||||
---
|
---
|
||||||
( ⪰ "alternates": Type(bool) | "baseline": Type(length) | "body": Type(content) | "bottom-edge": (Type(length) | "baseline" | "bounds" | "descender") | "cjk-latin-spacing": (Type(auto) | Type(none)) | "costs": {"hyphenation": Type(ratio), "orphan": Type(ratio), "runt": Type(ratio), "widow": Type(ratio)} | "dir": Dir | "discretionary-ligatures": Type(bool) | "fallback": Type(bool) | "features": (Type(array) | Type(dictionary)) | "fill": Color | "font": (TextFont | Array<TextFont>) | "fractions": Type(bool) | "historical-ligatures": Type(bool) | "hyphenate": (Type(auto) | Type(bool)) | "kerning": Type(bool) | "lang": TextLang | "ligatures": Type(bool) | "number-type": (Type(auto) | "lining" | "old-style") | "number-width": (Type(auto) | "proportional" | "tabular") | "overhang": Type(bool) | "region": TextRegion | "script": (Type(auto) | Type(str)) | "size": TextSize | "slashed-zero": Type(bool) | "spacing": Type(relative) | "stretch": Type(ratio) | "stroke": Stroke | "style": ("italic" | "normal" | "oblique") | "stylistic-set": (Type(array) | Type(int) | Type(none)) | "top-edge": (Type(length) | "ascender" | "baseline" | "bounds" | "cap-height" | "x-height") | "tracking": Type(length) | "weight": (Type(int) | "black" | "bold" | "extrabold" | "extralight" | "light" | "medium" | "regular" | "semibold" | "thin"))
|
( ⪰ "alternates": Type(bool) | "baseline": Type(length) | "body": Type(content) | "bottom-edge": (Type(length) | "baseline" | "bounds" | "descender") | "cjk-latin-spacing": (Type(auto) | Type(none)) | "costs": {"hyphenation": Type(ratio), "orphan": Type(ratio), "runt": Type(ratio), "widow": Type(ratio)} | "dir": Dir | "discretionary-ligatures": Type(bool) | "fallback": Type(bool) | "features": (Type(array) | Type(dictionary)) | "fill": Color | "font": (TextFont | Array<TextFont>) | "fractions": Type(bool) | "historical-ligatures": Type(bool) | "hyphenate": (Type(auto) | Type(bool)) | "kerning": Type(bool) | "lang": TextLang | "ligatures": Type(bool) | "number-type": (Type(auto) | "lining" | "old-style") | "number-width": (Type(auto) | "proportional" | "tabular") | "overhang": Type(bool) | "region": TextRegion | "script": (Type(auto) | Type(str)) | "size": TextSize | "slashed-zero": Type(bool) | "spacing": Type(relative) | "stretch": Type(ratio) | "stroke": Stroke | "style": ("italic" | "normal" | "oblique") | "stylistic-set": (Type(array) | Type(int) | Type(none)) | "text": Type(str) | "top-edge": (Type(length) | "ascender" | "baseline" | "bounds" | "cap-height" | "x-height") | "tracking": Type(length) | "weight": (Type(int) | "black" | "bold" | "extrabold" | "extralight" | "light" | "medium" | "regular" | "semibold" | "thin"))
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ input_file: crates/tinymist-query/src/fixtures/type_check/infer.typ
|
||||||
80..83 -> Func(xml)
|
80..83 -> Func(xml)
|
||||||
80..95 -> Any
|
80..95 -> Any
|
||||||
98..102 -> Func(toml)
|
98..102 -> Func(toml)
|
||||||
98..115 -> Any
|
98..115 -> Type(dictionary)
|
||||||
|
|
|
||||||
|
|
@ -280,8 +280,8 @@ fn is_one_line(src: &Source, arg_node: &LinkedNode<'_>) -> bool {
|
||||||
fn is_one_line_(src: &Source, arg_node: &LinkedNode<'_>) -> Option<bool> {
|
fn is_one_line_(src: &Source, arg_node: &LinkedNode<'_>) -> Option<bool> {
|
||||||
let lb = arg_node.children().next()?;
|
let lb = arg_node.children().next()?;
|
||||||
let rb = arg_node.children().next_back()?;
|
let rb = arg_node.children().next_back()?;
|
||||||
let ll = src.byte_to_line(lb.offset())?;
|
let ll = src.lines().byte_to_line(lb.offset())?;
|
||||||
let rl = src.byte_to_line(rb.offset())?;
|
let rl = src.lines().byte_to_line(rb.offset())?;
|
||||||
Some(ll == rl)
|
Some(ll == rl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ pub fn jump_from_click(
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's no link, search for a jump target.
|
// If there's no link, search for a jump target.
|
||||||
for (pos, item) in frame.items().rev() {
|
for &(mut pos, ref item) in frame.items().rev() {
|
||||||
let mut pos = *pos;
|
|
||||||
match item {
|
match item {
|
||||||
FrameItem::Group(group) => {
|
FrameItem::Group(group) => {
|
||||||
// TODO: Handle transformation.
|
// TODO: Handle transformation.
|
||||||
|
|
@ -169,8 +168,7 @@ fn jump_from_cursor_(
|
||||||
|
|
||||||
/// Finds the position of a span in a frame.
|
/// Finds the position of a span in a frame.
|
||||||
fn find_in_frame(frame: &Frame, span: Span, min_dis: &mut u64, res: &mut Point) -> Option<Point> {
|
fn find_in_frame(frame: &Frame, span: Span, min_dis: &mut u64, res: &mut Point) -> Option<Point> {
|
||||||
for (pos, item) in frame.items() {
|
for &(mut pos, ref item) in frame.items() {
|
||||||
let mut pos = *pos;
|
|
||||||
if let FrameItem::Group(group) = item {
|
if let FrameItem::Group(group) = item {
|
||||||
// TODO: Handle transformation.
|
// TODO: Handle transformation.
|
||||||
if let Some(point) = find_in_frame(&group.frame, span, min_dis, res) {
|
if let Some(point) = find_in_frame(&group.frame, span, min_dis, res) {
|
||||||
|
|
|
||||||
|
|
@ -250,11 +250,11 @@ impl RenameFileWorker<'_> {
|
||||||
let import_node = root.find(span).and_then(first_ancestor_expr)?;
|
let import_node = root.find(span).and_then(first_ancestor_expr)?;
|
||||||
let (import_path, has_path_var) = node_ancestors(&import_node).find_map(|import_node| {
|
let (import_path, has_path_var) = node_ancestors(&import_node).find_map(|import_node| {
|
||||||
match import_node.cast::<ast::Expr>()? {
|
match import_node.cast::<ast::Expr>()? {
|
||||||
ast::Expr::Import(import) => Some((
|
ast::Expr::ModuleImport(import) => Some((
|
||||||
import.source(),
|
import.source(),
|
||||||
import.new_name().is_none() && import.imports().is_none(),
|
import.new_name().is_none() && import.imports().is_none(),
|
||||||
)),
|
)),
|
||||||
ast::Expr::Include(include) => Some((include.source(), false)),
|
ast::Expr::ModuleInclude(include) => Some((include.source(), false)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ pub(crate) fn expr_of(
|
||||||
route.insert(source.id(), None);
|
route.insert(source.id(), None);
|
||||||
|
|
||||||
let cache_hit = prev.and_then(|prev| {
|
let cache_hit = prev.and_then(|prev| {
|
||||||
if prev.source.len_bytes() != source.len_bytes()
|
if prev.source.lines().len_bytes() != source.lines().len_bytes()
|
||||||
|| hash128(&prev.source) != hash128(&source)
|
|| hash128(&prev.source) != hash128(&source)
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
|
|
@ -273,18 +273,18 @@ impl ExprWorker<'_> {
|
||||||
|
|
||||||
Equation(equation) => self.check_math(equation.body().to_untyped().children()),
|
Equation(equation) => self.check_math(equation.body().to_untyped().children()),
|
||||||
Math(math) => self.check_math(math.to_untyped().children()),
|
Math(math) => self.check_math(math.to_untyped().children()),
|
||||||
Code(code_block) => self.check_code(code_block.body()),
|
CodeBlock(code_block) => self.check_code(code_block.body()),
|
||||||
Content(content_block) => self.check_markup(content_block.body()),
|
ContentBlock(content_block) => self.check_markup(content_block.body()),
|
||||||
|
|
||||||
Ident(ident) => self.check_ident(ident),
|
Ident(ident) => self.check_ident(ident),
|
||||||
MathIdent(math_ident) => self.check_math_ident(math_ident),
|
MathIdent(math_ident) => self.check_math_ident(math_ident),
|
||||||
Label(label) => self.check_label(label),
|
Label(label) => self.check_label(label),
|
||||||
Ref(ref_node) => self.check_ref(ref_node),
|
Ref(ref_node) => self.check_ref(ref_node),
|
||||||
|
|
||||||
Let(let_binding) => self.check_let(let_binding),
|
LetBinding(let_binding) => self.check_let(let_binding),
|
||||||
Closure(closure) => self.check_closure(closure),
|
Closure(closure) => self.check_closure(closure),
|
||||||
Import(module_import) => self.check_module_import(module_import),
|
ModuleImport(module_import) => self.check_module_import(module_import),
|
||||||
Include(module_include) => self.check_module_include(module_include),
|
ModuleInclude(module_include) => self.check_module_include(module_include),
|
||||||
|
|
||||||
Parenthesized(paren_expr) => self.check(paren_expr.expr()),
|
Parenthesized(paren_expr) => self.check(paren_expr.expr()),
|
||||||
Array(array) => self.check_array(array),
|
Array(array) => self.check_array(array),
|
||||||
|
|
@ -293,18 +293,20 @@ impl ExprWorker<'_> {
|
||||||
Binary(binary) => self.check_binary(binary),
|
Binary(binary) => self.check_binary(binary),
|
||||||
FieldAccess(field_access) => self.check_field_access(field_access),
|
FieldAccess(field_access) => self.check_field_access(field_access),
|
||||||
FuncCall(func_call) => self.check_func_call(func_call),
|
FuncCall(func_call) => self.check_func_call(func_call),
|
||||||
DestructAssign(destruct_assignment) => self.check_destruct_assign(destruct_assignment),
|
DestructAssignment(destruct_assignment) => {
|
||||||
Set(set_rule) => self.check_set(set_rule),
|
self.check_destruct_assign(destruct_assignment)
|
||||||
Show(show_rule) => self.check_show(show_rule),
|
}
|
||||||
|
SetRule(set_rule) => self.check_set(set_rule),
|
||||||
|
ShowRule(show_rule) => self.check_show(show_rule),
|
||||||
Contextual(contextual) => {
|
Contextual(contextual) => {
|
||||||
Expr::Unary(UnInst::new(UnaryOp::Context, self.defer(contextual.body())))
|
Expr::Unary(UnInst::new(UnaryOp::Context, self.defer(contextual.body())))
|
||||||
}
|
}
|
||||||
Conditional(conditional) => self.check_conditional(conditional),
|
Conditional(conditional) => self.check_conditional(conditional),
|
||||||
While(while_loop) => self.check_while_loop(while_loop),
|
WhileLoop(while_loop) => self.check_while_loop(while_loop),
|
||||||
For(for_loop) => self.check_for_loop(for_loop),
|
ForLoop(for_loop) => self.check_for_loop(for_loop),
|
||||||
Break(..) => Expr::Type(Ty::Builtin(BuiltinTy::Break)),
|
LoopBreak(..) => Expr::Type(Ty::Builtin(BuiltinTy::Break)),
|
||||||
Continue(..) => Expr::Type(Ty::Builtin(BuiltinTy::Continue)),
|
LoopContinue(..) => Expr::Type(Ty::Builtin(BuiltinTy::Continue)),
|
||||||
Return(func_return) => Expr::Unary(UnInst::new(
|
FuncReturn(func_return) => Expr::Unary(UnInst::new(
|
||||||
UnaryOp::Return,
|
UnaryOp::Return,
|
||||||
func_return
|
func_return
|
||||||
.body()
|
.body()
|
||||||
|
|
@ -355,15 +357,15 @@ impl ExprWorker<'_> {
|
||||||
let body = self.check_markup(heading.body());
|
let body = self.check_markup(heading.body());
|
||||||
self.check_element::<HeadingElem>(eco_vec![body])
|
self.check_element::<HeadingElem>(eco_vec![body])
|
||||||
}
|
}
|
||||||
List(item) => {
|
ListItem(item) => {
|
||||||
let body = self.check_markup(item.body());
|
let body = self.check_markup(item.body());
|
||||||
self.check_element::<ListElem>(eco_vec![body])
|
self.check_element::<ListElem>(eco_vec![body])
|
||||||
}
|
}
|
||||||
Enum(item) => {
|
EnumItem(item) => {
|
||||||
let body = self.check_markup(item.body());
|
let body = self.check_markup(item.body());
|
||||||
self.check_element::<EnumElem>(eco_vec![body])
|
self.check_element::<EnumElem>(eco_vec![body])
|
||||||
}
|
}
|
||||||
Term(item) => {
|
TermItem(item) => {
|
||||||
let term = self.check_markup(item.term());
|
let term = self.check_markup(item.term());
|
||||||
let description = self.check_markup(item.description());
|
let description = self.check_markup(item.description());
|
||||||
self.check_element::<TermsElem>(eco_vec![term, description])
|
self.check_element::<TermsElem>(eco_vec![term, description])
|
||||||
|
|
@ -1064,7 +1066,7 @@ impl ExprWorker<'_> {
|
||||||
let ident = Interned::new(Decl::ref_(ref_node));
|
let ident = Interned::new(Decl::ref_(ref_node));
|
||||||
let body = ref_node
|
let body = ref_node
|
||||||
.supplement()
|
.supplement()
|
||||||
.map(|block| self.check(ast::Expr::Content(block)));
|
.map(|block| self.check(ast::Expr::ContentBlock(block)));
|
||||||
let ref_expr = ContentRefExpr {
|
let ref_expr = ContentRefExpr {
|
||||||
ident: ident.clone(),
|
ident: ident.clone(),
|
||||||
of: None,
|
of: None,
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ struct UserTestConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_test_configuration(doc: &TypstDocument) -> Result<TestConfig> {
|
fn extract_test_configuration(doc: &TypstDocument) -> Result<TestConfig> {
|
||||||
let selector = Label::new(PicoStr::intern("test-config"));
|
let selector = Label::new(PicoStr::intern("test-config")).context("failed to create label")?;
|
||||||
let metadata = doc.introspector().query(&Selector::Label(selector));
|
let metadata = doc.introspector().query(&Selector::Label(selector));
|
||||||
if metadata.len() > 1 {
|
if metadata.len() > 1 {
|
||||||
// todo: attach source locations.
|
// todo: attach source locations.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "tinymist-std"
|
name = "tinymist-std"
|
||||||
description = "Additional functions wrapping Rust's standard library."
|
description = "Additional functions wrapping Rust's standard library."
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
@ -43,6 +43,7 @@ rkyv = { workspace = true, optional = true }
|
||||||
|
|
||||||
# feature = "typst"
|
# feature = "typst"
|
||||||
typst = { workspace = true, optional = true }
|
typst = { workspace = true, optional = true }
|
||||||
|
typst-html = { workspace = true, optional = true }
|
||||||
typst-shim = { workspace = true, optional = true }
|
typst-shim = { workspace = true, optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
|
@ -70,7 +71,7 @@ hex.workspace = true
|
||||||
default = ["full"]
|
default = ["full"]
|
||||||
full = ["web", "rkyv", "typst"]
|
full = ["web", "rkyv", "typst"]
|
||||||
|
|
||||||
typst = ["dep:typst", "dep:typst-shim"]
|
typst = ["dep:typst", "dep:typst-shim", "dep:typst-html"]
|
||||||
|
|
||||||
rkyv = ["rkyv/alloc", "rkyv/archive_le"]
|
rkyv = ["rkyv/alloc", "rkyv/archive_le"]
|
||||||
rkyv-validation = ["rkyv/validation"]
|
rkyv-validation = ["rkyv/validation"]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ pub(crate) mod well_known {
|
||||||
|
|
||||||
pub use typst::layout::PagedDocument as TypstPagedDocument;
|
pub use typst::layout::PagedDocument as TypstPagedDocument;
|
||||||
|
|
||||||
pub use typst::html::HtmlDocument as TypstHtmlDocument;
|
pub use typst_html::HtmlDocument as TypstHtmlDocument;
|
||||||
|
|
||||||
pub use typst::text::Font as TypstFont;
|
pub use typst::text::Font as TypstFont;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Task model of typst for tinymist."
|
||||||
categories = ["compilers"]
|
categories = ["compilers"]
|
||||||
keywords = ["language", "typst"]
|
keywords = ["language", "typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,10 @@ use tinymist_std::typst::TypstDocument;
|
||||||
use tinymist_world::{CompilerFeat, ExportComputation, WorldComputeGraph};
|
use tinymist_world::{CompilerFeat, ExportComputation, WorldComputeGraph};
|
||||||
use typst::World;
|
use typst::World;
|
||||||
use typst::diag::{SourceResult, StrResult};
|
use typst::diag::{SourceResult, StrResult};
|
||||||
|
use typst::engine::Sink;
|
||||||
use typst::foundations::{Content, IntoValue, LocatableSelector, Scope, Value};
|
use typst::foundations::{Content, IntoValue, LocatableSelector, Scope, Value};
|
||||||
use typst::routines::EvalMode;
|
|
||||||
use typst::syntax::Span;
|
use typst::syntax::Span;
|
||||||
|
use typst::syntax::SyntaxMode;
|
||||||
use typst_eval::eval_string;
|
use typst_eval::eval_string;
|
||||||
|
|
||||||
use crate::QueryTask;
|
use crate::QueryTask;
|
||||||
|
|
@ -30,9 +31,10 @@ impl DocumentQuery {
|
||||||
let selector = eval_string(
|
let selector = eval_string(
|
||||||
&typst::ROUTINES,
|
&typst::ROUTINES,
|
||||||
world.track(),
|
world.track(),
|
||||||
|
Sink::new().track_mut(),
|
||||||
selector,
|
selector,
|
||||||
Span::detached(),
|
Span::detached(),
|
||||||
EvalMode::Code,
|
SyntaxMode::Code,
|
||||||
Scope::default(),
|
Scope::default(),
|
||||||
)
|
)
|
||||||
.map_err(|errors| {
|
.map_err(|errors| {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use typst::html::{HtmlNode::*, tag};
|
use typst_html::{HtmlNode::*, tag};
|
||||||
|
|
||||||
use crate::ExportTextTask;
|
use crate::ExportTextTask;
|
||||||
use tinymist_std::error::prelude::*;
|
use tinymist_std::error::prelude::*;
|
||||||
|
|
@ -61,14 +61,14 @@ impl FullTextDigest<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_element(f: &mut fmt::Formatter<'_>, elem: &typst::html::HtmlElement) -> fmt::Result {
|
fn export_element(f: &mut fmt::Formatter<'_>, elem: &typst_html::HtmlElement) -> fmt::Result {
|
||||||
for child in elem.children.iter() {
|
for child in elem.children.iter() {
|
||||||
Self::export_html_node(f, child)?;
|
Self::export_html_node(f, child)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_html_node(f: &mut fmt::Formatter<'_>, node: &typst::html::HtmlNode) -> fmt::Result {
|
fn export_html_node(f: &mut fmt::Formatter<'_>, node: &typst_html::HtmlNode) -> fmt::Result {
|
||||||
match node {
|
match node {
|
||||||
Tag(_) => Ok(()),
|
Tag(_) => Ok(()),
|
||||||
Element(elem) => {
|
Element(elem) => {
|
||||||
|
|
@ -80,7 +80,7 @@ impl FullTextDigest<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text(t, _) => f.write_str(t.as_str()),
|
Text(t, _) => f.write_str(t.as_str()),
|
||||||
Frame(frame) => Self::export_frame(f, frame),
|
Frame(frame) => Self::export_frame(f, &frame.inner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "tinymist-vfs"
|
name = "tinymist-vfs"
|
||||||
description = "Vfs for tinymist."
|
description = "Vfs for tinymist."
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description = "Typst's World implementation for tinymist."
|
||||||
categories = ["compilers"]
|
categories = ["compilers"]
|
||||||
keywords = ["language", "typst"]
|
keywords = ["language", "typst"]
|
||||||
# group: world
|
# group: world
|
||||||
version = "0.13.30"
|
version = "0.14.0-rc1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -231,15 +231,17 @@ fn token_from_hashtag(hashtag: &LinkedNode) -> Option<TokenType> {
|
||||||
|
|
||||||
/// Converts an offset to a position in UTF-8.
|
/// Converts an offset to a position in UTF-8.
|
||||||
fn offset_to_position_utf8(typst_offset: usize, typst_source: &Source) -> (u32, u32) {
|
fn offset_to_position_utf8(typst_offset: usize, typst_source: &Source) -> (u32, u32) {
|
||||||
let line_index = typst_source.byte_to_line(typst_offset).unwrap();
|
let (line_index, column_index) = typst_source
|
||||||
let column_index = typst_source.byte_to_column(typst_offset).unwrap();
|
.lines()
|
||||||
|
.byte_to_line_column(typst_offset)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
(line_index as u32, column_index as u32)
|
(line_index as u32, column_index as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts an offset to a position in UTF-16.
|
/// Converts an offset to a position in UTF-16.
|
||||||
fn offset_to_position_utf16(typst_offset: usize, typst_source: &Source) -> (u32, u32) {
|
fn offset_to_position_utf16(typst_offset: usize, typst_source: &Source) -> (u32, u32) {
|
||||||
let line_index = typst_source.byte_to_line(typst_offset).unwrap();
|
let line_index = typst_source.lines().byte_to_line(typst_offset).unwrap();
|
||||||
|
|
||||||
let lsp_line = line_index as u32;
|
let lsp_line = line_index as u32;
|
||||||
|
|
||||||
|
|
@ -250,10 +252,13 @@ fn offset_to_position_utf16(typst_offset: usize, typst_source: &Source) -> (u32,
|
||||||
// we need here. Submit a PR to `typst` to add it, then update
|
// we need here. Submit a PR to `typst` to add it, then update
|
||||||
// this if/when merged.
|
// this if/when merged.
|
||||||
|
|
||||||
let utf16_offset = typst_source.byte_to_utf16(typst_offset).unwrap();
|
let utf16_offset = typst_source.lines().byte_to_utf16(typst_offset).unwrap();
|
||||||
|
|
||||||
let byte_line_offset = typst_source.line_to_byte(line_index).unwrap();
|
let byte_line_offset = typst_source.lines().line_to_byte(line_index).unwrap();
|
||||||
let utf16_line_offset = typst_source.byte_to_utf16(byte_line_offset).unwrap();
|
let utf16_line_offset = typst_source
|
||||||
|
.lines()
|
||||||
|
.byte_to_utf16(byte_line_offset)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let utf16_column_offset = utf16_offset - utf16_line_offset;
|
let utf16_column_offset = utf16_offset - utf16_line_offset;
|
||||||
let lsp_column = utf16_column_offset;
|
let lsp_column = utf16_column_offset;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
//!
|
//!
|
||||||
//! Note: If a world is mutated, the cache of the world is invalidated.
|
//! Note: If a world is mutated, the cache of the world is invalidated.
|
||||||
|
|
||||||
|
use ecow::EcoVec;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
num::NonZeroUsize,
|
num::NonZeroUsize,
|
||||||
|
|
@ -19,14 +20,12 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{Arc, LazyLock, OnceLock},
|
sync::{Arc, LazyLock, OnceLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ecow::EcoVec;
|
|
||||||
use tinymist_std::{ImmutPath, error::prelude::*};
|
use tinymist_std::{ImmutPath, error::prelude::*};
|
||||||
use tinymist_vfs::{
|
use tinymist_vfs::{
|
||||||
FileId, FsProvider, PathResolution, RevisingVfs, SourceCache, Vfs, WorkspaceResolver,
|
FileId, FsProvider, PathResolution, RevisingVfs, SourceCache, Vfs, WorkspaceResolver,
|
||||||
};
|
};
|
||||||
use typst::{
|
use typst::{
|
||||||
Features, Library, World, WorldExt,
|
Features, Library, LibraryExt, World, WorldExt,
|
||||||
diag::{At, EcoString, FileError, FileResult, SourceResult, eco_format},
|
diag::{At, EcoString, FileError, FileResult, SourceResult, eco_format},
|
||||||
foundations::{Bytes, Datetime, Dict},
|
foundations::{Bytes, Datetime, Dict},
|
||||||
syntax::{Source, Span, VirtualPath},
|
syntax::{Source, Span, VirtualPath},
|
||||||
|
|
@ -1024,18 +1023,19 @@ impl<'a> codespan_reporting::files::Files<'a> for CodeSpanReportWorld<'a> {
|
||||||
fn line_index(&'a self, id: FileId, given: usize) -> CodespanResult<usize> {
|
fn line_index(&'a self, id: FileId, given: usize) -> CodespanResult<usize> {
|
||||||
let source = self.world.lookup(id);
|
let source = self.world.lookup(id);
|
||||||
source
|
source
|
||||||
|
.lines()
|
||||||
.byte_to_line(given)
|
.byte_to_line(given)
|
||||||
.ok_or_else(|| CodespanError::IndexTooLarge {
|
.ok_or_else(|| CodespanError::IndexTooLarge {
|
||||||
given,
|
given,
|
||||||
max: source.len_bytes(),
|
max: source.lines().len_bytes(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`codespan_reporting::files::Files::column_number`].
|
/// See [`codespan_reporting::files::Files::column_number`].
|
||||||
fn column_number(&'a self, id: FileId, _: usize, given: usize) -> CodespanResult<usize> {
|
fn column_number(&'a self, id: FileId, _: usize, given: usize) -> CodespanResult<usize> {
|
||||||
let source = self.world.lookup(id);
|
let source = self.world.lookup(id);
|
||||||
source.byte_to_column(given).ok_or_else(|| {
|
source.lines().byte_to_column(given).ok_or_else(|| {
|
||||||
let max = source.len_bytes();
|
let max = source.lines().len_bytes();
|
||||||
if given <= max {
|
if given <= max {
|
||||||
CodespanError::InvalidCharBoundary { given }
|
CodespanError::InvalidCharBoundary { given }
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1049,10 +1049,11 @@ impl<'a> codespan_reporting::files::Files<'a> for CodeSpanReportWorld<'a> {
|
||||||
match self.world.source(id).ok() {
|
match self.world.source(id).ok() {
|
||||||
Some(source) => {
|
Some(source) => {
|
||||||
source
|
source
|
||||||
|
.lines()
|
||||||
.line_to_range(given)
|
.line_to_range(given)
|
||||||
.ok_or_else(|| CodespanError::LineTooLarge {
|
.ok_or_else(|| CodespanError::LineTooLarge {
|
||||||
given,
|
given,
|
||||||
max: source.len_lines(),
|
max: source.lines().len_lines(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
None => Ok(0..0),
|
None => Ok(0..0),
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ use serde::Deserialize;
|
||||||
use sync_ls::{internal_error, invalid_params, invalid_request, just_ok, SchedulableResponse};
|
use sync_ls::{internal_error, invalid_params, invalid_request, just_ok, SchedulableResponse};
|
||||||
use tinymist_std::error::prelude::*;
|
use tinymist_std::error::prelude::*;
|
||||||
use typst::{
|
use typst::{
|
||||||
|
engine::Sink,
|
||||||
foundations::Repr,
|
foundations::Repr,
|
||||||
routines::EvalMode,
|
syntax::{LinkedNode, Span, SyntaxMode},
|
||||||
syntax::{LinkedNode, Span},
|
|
||||||
World,
|
World,
|
||||||
};
|
};
|
||||||
use typst_shim::syntax::LinkedNodeExt;
|
use typst_shim::syntax::LinkedNodeExt;
|
||||||
|
|
@ -213,9 +213,10 @@ impl ServerState {
|
||||||
let val = typst_shim::eval::eval_string(
|
let val = typst_shim::eval::eval_string(
|
||||||
&typst::ROUTINES,
|
&typst::ROUTINES,
|
||||||
(world as &dyn World).track(),
|
(world as &dyn World).track(),
|
||||||
|
Sink::new().track_mut(),
|
||||||
&args.expression,
|
&args.expression,
|
||||||
span,
|
span,
|
||||||
EvalMode::Code,
|
SyntaxMode::Code,
|
||||||
source.scope().clone(),
|
source.scope().clone(),
|
||||||
)
|
)
|
||||||
.map_err(|e| invalid_params(format!("{e:?}")))?;
|
.map_err(|e| invalid_params(format!("{e:?}")))?;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ struct ResourceSymbolResponse {
|
||||||
struct ResourceSymbolItem {
|
struct ResourceSymbolItem {
|
||||||
id: String,
|
id: String,
|
||||||
category: SymCategory,
|
category: SymCategory,
|
||||||
unicode: u32,
|
symbol: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
glyph: Option<String>,
|
glyph: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ struct ResourceSymbolItem {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct SymbolItem {
|
struct SymbolItem {
|
||||||
category: SymCategory,
|
category: SymCategory,
|
||||||
unicode: u32,
|
symbol: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
|
|
@ -991,9 +991,10 @@ fn populate(
|
||||||
fallback_cat: SymCategory,
|
fallback_cat: SymCategory,
|
||||||
out: &mut ResourceSymbolMap,
|
out: &mut ResourceSymbolMap,
|
||||||
) {
|
) {
|
||||||
for (modifier_name, ch) in sym.variants() {
|
for (modifier_name, ch, _) in sym.variants() {
|
||||||
let mut name =
|
let mut name = String::with_capacity(
|
||||||
String::with_capacity(mod_name.len() + sym_name.len() + modifier_name.len() + 2);
|
mod_name.len() + sym_name.len() + modifier_name.as_str().len() + 2,
|
||||||
|
);
|
||||||
|
|
||||||
name.push_str(mod_name);
|
name.push_str(mod_name);
|
||||||
name.push('.');
|
name.push('.');
|
||||||
|
|
@ -1001,7 +1002,7 @@ fn populate(
|
||||||
|
|
||||||
if !modifier_name.is_empty() {
|
if !modifier_name.is_empty() {
|
||||||
name.push('.');
|
name.push('.');
|
||||||
name.push_str(modifier_name);
|
name.push_str(modifier_name.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
let category = CAT_MAP.get(name.as_str()).cloned().unwrap_or(fallback_cat);
|
let category = CAT_MAP.get(name.as_str()).cloned().unwrap_or(fallback_cat);
|
||||||
|
|
@ -1009,7 +1010,7 @@ fn populate(
|
||||||
name,
|
name,
|
||||||
SymbolItem {
|
SymbolItem {
|
||||||
category,
|
category,
|
||||||
unicode: ch as u32,
|
symbol: ch.into(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1031,7 +1032,7 @@ fn render_symbols(
|
||||||
|
|
||||||
let math_shaping_text = symbols.iter().fold(PRELUDE.to_owned(), |mut o, (k, e)| {
|
let math_shaping_text = symbols.iter().fold(PRELUDE.to_owned(), |mut o, (k, e)| {
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
writeln!(o, "$#{k}$/* {} */#pagebreak()", e.unicode).ok();
|
writeln!(o, "$#{k}$/* {} */#pagebreak()", e.symbol).ok();
|
||||||
o
|
o
|
||||||
});
|
});
|
||||||
log::debug!("math shaping text: {math_shaping_text}");
|
log::debug!("math shaping text: {math_shaping_text}");
|
||||||
|
|
@ -1147,7 +1148,7 @@ fn render_glyphs(
|
||||||
.map(|(k, v)| ResourceSymbolItem {
|
.map(|(k, v)| ResourceSymbolItem {
|
||||||
id: k.clone(),
|
id: k.clone(),
|
||||||
category: v.category,
|
category: v.category,
|
||||||
unicode: v.unicode,
|
symbol: v.symbol.clone(),
|
||||||
glyph: render_sym(k),
|
glyph: render_sym(k),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -472,6 +472,6 @@ fn resolve_span(world: &LspWorld, span: Span) -> Option<(String, u32)> {
|
||||||
let id = span.id()?;
|
let id = span.id()?;
|
||||||
let source = world.source(id).ok()?;
|
let source = world.source(id).ok()?;
|
||||||
let range = source.range(span)?;
|
let range = source.range(span)?;
|
||||||
let line = source.byte_to_line(range.start)?;
|
let line = source.lines().byte_to_line(range.start)?;
|
||||||
Some((format!("{id:?}"), line as u32 + 1))
|
Some((format!("{id:?}"), line as u32 + 1))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,9 @@ impl tinymist_preview::CompileView for PreviewCompileView {
|
||||||
let source_id = world.id_for_path(Path::new(&loc.filepath))?;
|
let source_id = world.id_for_path(Path::new(&loc.filepath))?;
|
||||||
|
|
||||||
let source = world.source(source_id).ok()?;
|
let source = world.source(source_id).ok()?;
|
||||||
let cursor =
|
let cursor = source
|
||||||
source.line_column_to_byte(loc.pos.line as usize, loc.pos.character as usize)?;
|
.lines()
|
||||||
|
.line_column_to_byte(loc.pos.line as usize, loc.pos.character as usize)?;
|
||||||
|
|
||||||
let node = LinkedNode::new(source.root()).leaf_at_compat(cursor)?;
|
let node = LinkedNode::new(source.root()).leaf_at_compat(cursor)?;
|
||||||
if !matches!(node.kind(), SyntaxKind::Text | SyntaxKind::MathText) {
|
if !matches!(node.kind(), SyntaxKind::Text | SyntaxKind::MathText) {
|
||||||
|
|
@ -167,7 +168,7 @@ impl tinymist_preview::CompileView for PreviewCompileView {
|
||||||
let Some(source) = world.source(source_id).ok() else {
|
let Some(source) = world.source(source_id).ok() else {
|
||||||
return vec![];
|
return vec![];
|
||||||
};
|
};
|
||||||
let Some(cursor) = source.line_column_to_byte(line, column) else {
|
let Some(cursor) = source.lines().line_column_to_byte(line, column) else {
|
||||||
return vec![];
|
return vec![];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -176,8 +177,11 @@ impl tinymist_preview::CompileView for PreviewCompileView {
|
||||||
|
|
||||||
fn resolve_span(&self, span: Span, offset: Option<usize>) -> Option<DocToSrcJumpInfo> {
|
fn resolve_span(&self, span: Span, offset: Option<usize>) -> Option<DocToSrcJumpInfo> {
|
||||||
let world = self.art.world();
|
let world = self.art.world();
|
||||||
let resolve_off =
|
let resolve_off = |src: &Source, off: usize| {
|
||||||
|src: &Source, off: usize| src.byte_to_line(off).zip(src.byte_to_column(off));
|
src.lines()
|
||||||
|
.byte_to_line(off)
|
||||||
|
.zip(src.lines().byte_to_column(off))
|
||||||
|
};
|
||||||
|
|
||||||
let source = world.source(span.id()?).ok()?;
|
let source = world.source(span.id()?).ok()?;
|
||||||
let mut range = source.find(span)?.range();
|
let mut range = source.find(span)?.range();
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
use ecow::EcoString;
|
use ecow::EcoString;
|
||||||
use tinymist_derive::TypliteAttr;
|
use tinymist_derive::TypliteAttr;
|
||||||
use typst::html::HtmlAttrs;
|
use typst_html::HtmlAttrs;
|
||||||
|
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
/// Tag attributes defined for HTML elements.
|
/// Tag attributes defined for HTML elements.
|
||||||
pub mod md_attr {
|
pub mod md_attr {
|
||||||
use typst::html::HtmlAttr;
|
use typst_html::HtmlAttr;
|
||||||
|
|
||||||
macro_rules! attrs {
|
macro_rules! attrs {
|
||||||
($($attr:ident -> $name:ident)*) => {
|
($($attr:ident -> $name:ident)*) => {
|
||||||
|
|
@ -32,6 +32,7 @@ pub mod md_attr {
|
||||||
value -> value
|
value -> value
|
||||||
caption -> caption
|
caption -> caption
|
||||||
class -> class
|
class -> class
|
||||||
|
id -> id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,17 +44,20 @@ pub struct IdocAttr {
|
||||||
|
|
||||||
#[derive(TypliteAttr, Default)]
|
#[derive(TypliteAttr, Default)]
|
||||||
pub struct HeadingAttr {
|
pub struct HeadingAttr {
|
||||||
|
pub id: EcoString,
|
||||||
pub level: usize,
|
pub level: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TypliteAttr, Default)]
|
#[derive(TypliteAttr, Default)]
|
||||||
pub struct ImageAttr {
|
pub struct ImageAttr {
|
||||||
|
pub id: EcoString,
|
||||||
pub src: EcoString,
|
pub src: EcoString,
|
||||||
pub alt: EcoString,
|
pub alt: EcoString,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TypliteAttr, Default)]
|
#[derive(TypliteAttr, Default)]
|
||||||
pub struct FigureAttr {
|
pub struct FigureAttr {
|
||||||
|
pub id: EcoString,
|
||||||
pub caption: EcoString,
|
pub caption: EcoString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,6 +68,7 @@ pub struct LinkAttr {
|
||||||
|
|
||||||
#[derive(TypliteAttr, Default)]
|
#[derive(TypliteAttr, Default)]
|
||||||
pub struct RawAttr {
|
pub struct RawAttr {
|
||||||
|
pub id: EcoString,
|
||||||
pub lang: EcoString,
|
pub lang: EcoString,
|
||||||
pub block: bool,
|
pub block: bool,
|
||||||
pub text: EcoString,
|
pub text: EcoString,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/docs/nest_list.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><p>These again are dictionaries with the keys</p><ul><li><span><m1raw lang="" block="false" text="description"><code>description</code></m1raw></span> (optional): The description for the argument.</li></ul><m1parbreak></m1parbreak><p>See show-module() for outputting the results of this function.</p><m1parbreak></m1parbreak><ul><li>name (string): The name for the module.</li><li><p>label-prefix (auto, string): The label-prefix for internal function references. If <span><m1raw lang="" block="false" text="auto"><code>auto</code></m1raw></span>, the label-prefix name will be the module name.</p><ul><li>nested something</li><li>nested something 2</li></ul></li></ul><p>-> string</p></m1document></body>
|
<body><m1document><p>These again are dictionaries with the keys</p><ul><li><span><m1raw lang block="false" text="description"><code>description</code></m1raw></span> (optional): The description for the argument.</li></ul><m1parbreak></m1parbreak><p>See show-module() for outputting the results of this function.</p><m1parbreak></m1parbreak><ul><li>name (string): The name for the module.</li><li><p>label-prefix (auto, string): The label-prefix for internal function references. If <span><m1raw lang block="false" text="auto"><code>auto</code></m1raw></span>, the label-prefix name will be the module name.</p><ul><li>nested something</li><li>nested something 2</li></ul></li></ul><p>-> string</p></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/docs/tidy.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><p>These again are dictionaries with the keys</p><ul><li><span><m1raw lang="" block="false" text="description"><code>description</code></m1raw></span> (optional): The description for the argument.</li><li><span><m1raw lang="" block="false" text="types"><code>types</code></m1raw></span> (optional): A list of accepted argument types.</li><li><span><m1raw lang="" block="false" text="default"><code>default</code></m1raw></span> (optional): Default value for this argument.</li></ul><m1parbreak></m1parbreak><p>See show-module() for outputting the results of this function.</p><m1parbreak></m1parbreak><ul><li>content (string): Content of <span><m1raw lang="" block="false" text=".typ"><code>.typ</code></m1raw></span> file to analyze for docstrings.</li><li>name (string): The name for the module.</li><li>label-prefix (auto, string): The label-prefix for internal function references. If <span><m1raw lang="" block="false" text="auto"><code>auto</code></m1raw></span>, the label-prefix name will be the module name.</li><li>require-all-parameters (boolean): Require that all parameters of a functions are documented and fail if some are not.</li><li>scope (dictionary): A dictionary of definitions that are then available in all function and parameter descriptions.</li><li>preamble (string): Code to prepend to all code snippets shown with <span><m1raw lang="" block="false" text="#example()"><code>#example()</code></m1raw></span>. This can for instance be used to import something from the scope.</li></ul><p>-> string</p></m1document></body>
|
<body><m1document><p>These again are dictionaries with the keys</p><ul><li><span><m1raw lang block="false" text="description"><code>description</code></m1raw></span> (optional): The description for the argument.</li><li><span><m1raw lang block="false" text="types"><code>types</code></m1raw></span> (optional): A list of accepted argument types.</li><li><span><m1raw lang block="false" text="default"><code>default</code></m1raw></span> (optional): Default value for this argument.</li></ul><m1parbreak></m1parbreak><p>See show-module() for outputting the results of this function.</p><m1parbreak></m1parbreak><ul><li>content (string): Content of <span><m1raw lang block="false" text=".typ"><code>.typ</code></m1raw></span> file to analyze for docstrings.</li><li>name (string): The name for the module.</li><li>label-prefix (auto, string): The label-prefix for internal function references. If <span><m1raw lang block="false" text="auto"><code>auto</code></m1raw></span>, the label-prefix name will be the module name.</li><li>require-all-parameters (boolean): Require that all parameters of a functions are documented and fail if some are not.</li><li>scope (dictionary): A dictionary of definitions that are then available in all function and parameter descriptions.</li><li>preamble (string): Code to prepend to all code snippets shown with <span><m1raw lang block="false" text="#example()"><code>#example()</code></m1raw></span>. This can for instance be used to import something from the scope.</li></ul><p>-> string</p></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -1,353 +0,0 @@
|
||||||
/// path: ieee-lib.typ
|
|
||||||
|
|
||||||
#let sys-is-html-target = ("target" in dictionary(std))
|
|
||||||
|
|
||||||
// This function gets your whole document as its `body` and formats
|
|
||||||
// it as an article in the style of the IEEE.
|
|
||||||
#let ieee(
|
|
||||||
// The paper's title.
|
|
||||||
title: [Paper Title],
|
|
||||||
// An array of authors. For each author you can specify a name,
|
|
||||||
// department, organization, location, and email. Everything but
|
|
||||||
// but the name is optional.
|
|
||||||
authors: (),
|
|
||||||
// The paper's abstract. Can be omitted if you don't have one.
|
|
||||||
abstract: none,
|
|
||||||
// A list of index terms to display after the abstract.
|
|
||||||
index-terms: (),
|
|
||||||
// The article's paper size. Also affects the margins.
|
|
||||||
paper-size: "us-letter",
|
|
||||||
// The result of a call to the `bibliography` function or `none`.
|
|
||||||
bibliography: none,
|
|
||||||
// How figures are referred to from within the text.
|
|
||||||
// Use "Figure" instead of "Fig." for computer-related publications.
|
|
||||||
figure-supplement: [Fig.],
|
|
||||||
// The paper's content.
|
|
||||||
body,
|
|
||||||
) = if sys-is-html-target {
|
|
||||||
set heading(numbering: "I.A.a)")
|
|
||||||
set math.equation(numbering: "(1)")
|
|
||||||
|
|
||||||
body
|
|
||||||
|
|
||||||
// Display bibliography.
|
|
||||||
bibliography
|
|
||||||
}else {
|
|
||||||
// Set document metadata.
|
|
||||||
set document(title: title, author: authors.map(author => author.name))
|
|
||||||
|
|
||||||
// Set the body font.
|
|
||||||
// As of 2024-08, the IEEE LaTeX template uses wider interword spacing
|
|
||||||
// - See e.g. the definition \def\@IEEEinterspaceratioM{0.35} in IEEEtran.cls
|
|
||||||
set text(font: "TeX Gyre Termes", size: 10pt, spacing: .35em)
|
|
||||||
|
|
||||||
// Enums numbering
|
|
||||||
set enum(numbering: "1)a)i)")
|
|
||||||
|
|
||||||
// Tables & figures
|
|
||||||
show figure: set block(spacing: 15.5pt)
|
|
||||||
show figure: set place(clearance: 15.5pt)
|
|
||||||
show figure.where(kind: table): set figure.caption(position: top, separator: [\ ])
|
|
||||||
show figure.where(kind: table): set text(size: 8pt)
|
|
||||||
show figure.where(kind: table): set figure(numbering: "I")
|
|
||||||
show figure.where(kind: image): set figure(supplement: figure-supplement, numbering: "1")
|
|
||||||
show figure.caption: set text(size: 8pt)
|
|
||||||
show figure.caption: set align(start)
|
|
||||||
show figure.caption.where(kind: table): set align(center)
|
|
||||||
|
|
||||||
// Adapt supplement in caption independently from supplement used for
|
|
||||||
// references.
|
|
||||||
set figure.caption(separator: [. ])
|
|
||||||
show figure: fig => {
|
|
||||||
let prefix = (
|
|
||||||
if fig.kind == table [TABLE] else if fig.kind == image [Fig.] else [#fig.supplement]
|
|
||||||
)
|
|
||||||
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
|
|
||||||
show figure.caption: it => [#prefix~#numbers#it.separator#it.body]
|
|
||||||
show figure.caption.where(kind: table): smallcaps
|
|
||||||
fig
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code blocks
|
|
||||||
show raw: set text(
|
|
||||||
font: "TeX Gyre Cursor",
|
|
||||||
ligatures: false,
|
|
||||||
size: 1em / 0.8,
|
|
||||||
spacing: 100%,
|
|
||||||
)
|
|
||||||
|
|
||||||
// Configure the page and multi-column properties.
|
|
||||||
set columns(gutter: 12pt)
|
|
||||||
set page(
|
|
||||||
columns: 2,
|
|
||||||
paper: paper-size,
|
|
||||||
// The margins depend on the paper size.
|
|
||||||
margin: if paper-size == "a4" {
|
|
||||||
(x: 41.5pt, top: 80.51pt, bottom: 89.51pt)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
x: (50pt / 216mm) * 100%,
|
|
||||||
top: (55pt / 279mm) * 100%,
|
|
||||||
bottom: (64pt / 279mm) * 100%,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// Configure equation numbering and spacing.
|
|
||||||
set math.equation(numbering: "(1)")
|
|
||||||
show math.equation: set block(spacing: 0.65em)
|
|
||||||
|
|
||||||
// Configure appearance of equation references
|
|
||||||
show ref: it => {
|
|
||||||
if it.element != none and it.element.func() == math.equation {
|
|
||||||
// Override equation references.
|
|
||||||
link(
|
|
||||||
it.element.location(),
|
|
||||||
numbering(
|
|
||||||
it.element.numbering,
|
|
||||||
..counter(math.equation).at(it.element.location()),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// Other references as usual.
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure lists.
|
|
||||||
set enum(indent: 10pt, body-indent: 9pt)
|
|
||||||
set list(indent: 10pt, body-indent: 9pt)
|
|
||||||
|
|
||||||
// Configure headings.
|
|
||||||
set heading(numbering: "I.A.a)")
|
|
||||||
show heading: it => {
|
|
||||||
// Find out the final number of the heading counter.
|
|
||||||
let levels = counter(heading).get()
|
|
||||||
let deepest = if levels != () {
|
|
||||||
levels.last()
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
|
|
||||||
set text(10pt, weight: 400)
|
|
||||||
if it.level == 1 {
|
|
||||||
// First-level headings are centered smallcaps.
|
|
||||||
// We don't want to number the acknowledgment section.
|
|
||||||
let is-ack = it.body in ([Acknowledgment], [Acknowledgement], [Acknowledgments], [Acknowledgements])
|
|
||||||
set align(center)
|
|
||||||
set text(if is-ack { 10pt } else { 11pt })
|
|
||||||
show: block.with(above: 15pt, below: 13.75pt, sticky: true)
|
|
||||||
show: smallcaps
|
|
||||||
if it.numbering != none and not is-ack {
|
|
||||||
numbering("I.", deepest)
|
|
||||||
h(7pt, weak: true)
|
|
||||||
}
|
|
||||||
it.body
|
|
||||||
} else if it.level == 2 {
|
|
||||||
// Second-level headings are run-ins.
|
|
||||||
set par(first-line-indent: 0pt)
|
|
||||||
set text(style: "italic")
|
|
||||||
show: block.with(spacing: 10pt, sticky: true)
|
|
||||||
if it.numbering != none {
|
|
||||||
numbering("A.", deepest)
|
|
||||||
h(7pt, weak: true)
|
|
||||||
}
|
|
||||||
it.body
|
|
||||||
} else [
|
|
||||||
// Third level headings are run-ins too, but different.
|
|
||||||
#if it.level == 3 {
|
|
||||||
numbering("a)", deepest)
|
|
||||||
[ ]
|
|
||||||
}
|
|
||||||
_#(it.body):_
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Style bibliography.
|
|
||||||
show std.bibliography: set text(8pt)
|
|
||||||
show std.bibliography: set block(spacing: 0.5em)
|
|
||||||
set std.bibliography(title: text(10pt)[References], style: "ieee")
|
|
||||||
|
|
||||||
// Display the paper's title and authors at the top of the page,
|
|
||||||
// spanning all columns (hence floating at the scope of the
|
|
||||||
// columns' parent, which is the page).
|
|
||||||
place(
|
|
||||||
top,
|
|
||||||
float: true,
|
|
||||||
scope: "parent",
|
|
||||||
clearance: 30pt,
|
|
||||||
{
|
|
||||||
v(3pt, weak: true)
|
|
||||||
align(center, par(leading: 0.5em, text(size: 24pt, title)))
|
|
||||||
v(8.35mm, weak: true)
|
|
||||||
|
|
||||||
// Display the authors list.
|
|
||||||
set par(leading: 0.6em)
|
|
||||||
for i in range(calc.ceil(authors.len() / 3)) {
|
|
||||||
let end = calc.min((i + 1) * 3, authors.len())
|
|
||||||
let is-last = authors.len() == end
|
|
||||||
let slice = authors.slice(i * 3, end)
|
|
||||||
grid(
|
|
||||||
columns: slice.len() * (1fr,),
|
|
||||||
gutter: 12pt,
|
|
||||||
..slice.map(author => align(
|
|
||||||
center,
|
|
||||||
{
|
|
||||||
text(size: 11pt, author.name)
|
|
||||||
if "department" in author [
|
|
||||||
\ #emph(author.department)
|
|
||||||
]
|
|
||||||
if "organization" in author [
|
|
||||||
\ #emph(author.organization)
|
|
||||||
]
|
|
||||||
if "location" in author [
|
|
||||||
\ #author.location
|
|
||||||
]
|
|
||||||
if "email" in author {
|
|
||||||
if type(author.email) == str [
|
|
||||||
\ #link("mailto:" + author.email)
|
|
||||||
] else [
|
|
||||||
\ #author.email
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
if not is-last {
|
|
||||||
v(16pt, weak: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// Configure paragraph properties.
|
|
||||||
set par(spacing: 0.45em, justify: true, first-line-indent: 1em, leading: 0.45em)
|
|
||||||
|
|
||||||
// Display abstract and index terms.
|
|
||||||
if abstract != none [
|
|
||||||
#set text(9pt, weight: 700, spacing: 150%)
|
|
||||||
#h(1em) _Abstract_---#h(weak: true, 0pt)#abstract
|
|
||||||
|
|
||||||
#if index-terms != () [
|
|
||||||
#h(.3em)_Index Terms_---#h(weak: true, 0pt)#index-terms.join(", ")
|
|
||||||
]
|
|
||||||
#v(2pt)
|
|
||||||
]
|
|
||||||
|
|
||||||
// Display the paper's contents.
|
|
||||||
set par(leading: 0.5em)
|
|
||||||
body
|
|
||||||
|
|
||||||
// Display bibliography.
|
|
||||||
bibliography
|
|
||||||
}
|
|
||||||
-----
|
|
||||||
/// path: refs.bib
|
|
||||||
@article{netwok2020,
|
|
||||||
title={At-scale impact of the {Net Wok}: A culinarically holistic investigation of distributed dumplings},
|
|
||||||
author={Astley, Rick and Morris, Linda},
|
|
||||||
journal={Armenian Journal of Proceedings},
|
|
||||||
volume={61},
|
|
||||||
pages={192--219},
|
|
||||||
year=2020,
|
|
||||||
publisher={Automatic Publishing Inc.}
|
|
||||||
}
|
|
||||||
|
|
||||||
@article{netwok2022,
|
|
||||||
title={{Net Wok}++: Taking distributed dumplings to the cloud},
|
|
||||||
author={Morris, Linda and Astley, Rick},
|
|
||||||
journal={Armenian Journal of Proceedings},
|
|
||||||
volume={65},
|
|
||||||
pages={101--118},
|
|
||||||
year=2022,
|
|
||||||
publisher={Automatic Publishing Inc.}
|
|
||||||
}
|
|
||||||
-----
|
|
||||||
#import "ieee-lib.typ": ieee
|
|
||||||
|
|
||||||
#show: ieee.with(
|
|
||||||
title: [A Typesetting System to Untangle the Scientific Writing Process],
|
|
||||||
abstract: [
|
|
||||||
The process of scientific writing is often tangled up with the intricacies of typesetting, leading to frustration and wasted time for researchers. In this paper, we introduce Typst, a new typesetting system designed specifically for scientific writing. Typst untangles the typesetting process, allowing researchers to compose papers faster. In a series of experiments we demonstrate that Typst offers several advantages, including faster document creation, simplified syntax, and increased ease-of-use.
|
|
||||||
],
|
|
||||||
authors: (
|
|
||||||
(
|
|
||||||
name: "Martin Haug",
|
|
||||||
department: [Co-Founder],
|
|
||||||
organization: [Typst GmbH],
|
|
||||||
location: [Berlin, Germany],
|
|
||||||
email: "haug@typst.app",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
name: "Laurenz Mädje",
|
|
||||||
department: [Co-Founder],
|
|
||||||
organization: [Typst GmbH],
|
|
||||||
location: [Berlin, Germany],
|
|
||||||
email: "maedje@typst.app",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
index-terms: ("Scientific writing", "Typesetting", "Document creation", "Syntax"),
|
|
||||||
bibliography: bibliography("refs.bib"),
|
|
||||||
figure-supplement: [Fig.],
|
|
||||||
)
|
|
||||||
|
|
||||||
= Introduction
|
|
||||||
Scientific writing is a crucial part of the research process, allowing researchers to share their findings with the wider scientific community. However, the process of typesetting scientific documents can often be a frustrating and time-consuming affair, particularly when using outdated tools such as LaTeX. Despite being over 30 years old, it remains a popular choice for scientific writing due to its power and flexibility. However, it also comes with a steep learning curve, complex syntax, and long compile times, leading to frustration and despair for many researchers @netwok2020 @netwok2022.
|
|
||||||
|
|
||||||
== Paper overview
|
|
||||||
In this paper we introduce Typst, a new typesetting system designed to streamline the scientific writing process and provide researchers with a fast, efficient, and easy-to-use alternative to existing systems. Our goal is to shake up the status quo and offer researchers a better way to approach scientific writing.
|
|
||||||
|
|
||||||
By leveraging advanced algorithms and a user-friendly interface, Typst offers several advantages over existing typesetting systems, including faster document creation, simplified syntax, and increased ease-of-use.
|
|
||||||
|
|
||||||
To demonstrate the potential of Typst, we conducted a series of experiments comparing it to other popular typesetting systems, including LaTeX. Our findings suggest that Typst offers several benefits for scientific writing, particularly for novice users who may struggle with the complexities of LaTeX. Additionally, we demonstrate that Typst offers advanced features for experienced users, allowing for greater customization and flexibility in document creation.
|
|
||||||
|
|
||||||
Overall, we believe that Typst represents a significant step forward in the field of scientific writing and typesetting, providing researchers with a valuable tool to streamline their workflow and focus on what really matters: their research. In the following sections, we will introduce Typst in more detail and provide evidence for its superiority over other typesetting systems in a variety of scenarios.
|
|
||||||
|
|
||||||
= Methods <sec:methods>
|
|
||||||
#lorem(45)
|
|
||||||
|
|
||||||
$ a + b = gamma $ <eq:gamma>
|
|
||||||
|
|
||||||
#lorem(80)
|
|
||||||
|
|
||||||
#figure(
|
|
||||||
placement: none,
|
|
||||||
circle(radius: 15pt),
|
|
||||||
caption: [A circle representing the Sun.],
|
|
||||||
) <fig:sun>
|
|
||||||
|
|
||||||
In @fig:sun you can see a common representation of the Sun, which is a star that is located at the center of the solar system.
|
|
||||||
|
|
||||||
#lorem(120)
|
|
||||||
|
|
||||||
#figure(
|
|
||||||
caption: [The Planets of the Solar System and Their Average Distance from the Sun],
|
|
||||||
placement: top,
|
|
||||||
table(
|
|
||||||
// Table styling is not mandated by the IEEE. Feel free to adjust these
|
|
||||||
// settings and potentially move them into a set rule.
|
|
||||||
columns: (6em, auto),
|
|
||||||
align: (left, right),
|
|
||||||
inset: (x: 8pt, y: 4pt),
|
|
||||||
stroke: (x, y) => if y <= 1 { (top: 0.5pt) },
|
|
||||||
fill: (x, y) => if y > 0 and calc.rem(y, 2) == 0 { rgb("#efefef") },
|
|
||||||
|
|
||||||
table.header[Planet][Distance (million km)],
|
|
||||||
[Mercury], [57.9],
|
|
||||||
[Venus], [108.2],
|
|
||||||
[Earth], [149.6],
|
|
||||||
[Mars], [227.9],
|
|
||||||
[Jupiter], [778.6],
|
|
||||||
[Saturn], [1,433.5],
|
|
||||||
[Uranus], [2,872.5],
|
|
||||||
[Neptune], [4,495.1],
|
|
||||||
),
|
|
||||||
) <tab:planets>
|
|
||||||
|
|
||||||
In @tab:planets, you see the planets of the solar system and their average distance from the Sun.
|
|
||||||
The distances were calculated with @eq:gamma that we presented in @sec:methods.
|
|
||||||
|
|
||||||
#lorem(240)
|
|
||||||
|
|
||||||
#lorem(240)
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: crates/typlite/src/tests.rs
|
source: crates/typlite/src/tests.rs
|
||||||
expression: "conv(world, false)"
|
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
||||||
input_file: crates/typlite/src/fixtures/integration/base.typ
|
input_file: crates/typlite/src/fixtures/integration/base.typ
|
||||||
---
|
---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/base.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1heading level="1"><span style="display: inline-block;">Hello, World!</span></m1heading><p>This is a typst document.</p></m1document></body>
|
<body><m1document><m1heading level="1"><span style="display: inline-block">Hello, World!</span></m1heading><p>This is a typst document.</p></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/figure_image.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1figure caption=""><m1image src="./fig.svg" alt=""></m1image></m1figure></m1document></body>
|
<body><m1document><m1figure caption><m1image src="./fig.svg" alt></m1image></m1figure></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/figure_image_alt.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1figure caption=""><m1image src="./fig.svg" alt="Content"></m1image></m1figure></m1document></body>
|
<body><m1document><m1figure caption><m1image src="./fig.svg" alt="Content"></m1image></m1figure></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/figure_raw.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1figure caption=""><m1raw lang="md" block="true" text="markdown"><pre>markdown</pre></m1raw></m1figure></m1document></body>
|
<body><m1document><m1figure caption><m1raw lang="md" block="true" text="markdown"><pre><code data-lang="md">markdown</code></pre></m1raw></m1figure></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
source: crates/typlite/src/tests.rs
|
source: crates/typlite/src/tests.rs
|
||||||
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
||||||
input_file: crates/typlite/src/fixtures/integration/highlight.typ
|
input_file: crates/typlite/src/fixtures/integration/highlight.typ
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
@ -10,7 +9,7 @@ snapshot_kind: text
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><span><m1highlight>highlight</m1highlight></span></m1document></body>
|
<body><m1document><mark>highlight</mark></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: crates/typlite/src/tests.rs
|
source: crates/typlite/src/tests.rs
|
||||||
expression: "conv(world, false)"
|
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
||||||
input_file: crates/typlite/src/fixtures/integration/image.typ
|
input_file: crates/typlite/src/fixtures/integration/image.typ
|
||||||
---
|
---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/image.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1image src="./fig.svg" alt=""></m1image></m1document></body>
|
<body><m1document><m1image src="./fig.svg" alt></m1image></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/issue-1844.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1parbreak></m1parbreak><m1parbreak></m1parbreak><m1heading level="1"><span style="display: inline-block;">Reproducer document</span></m1heading><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block;">Example</span></m1heading><m1parbreak></m1parbreak><m1parbreak></m1parbreak><p>Just the source (ok)</p><m1parbreak></m1parbreak><m1verbatim src="````
|
<body><m1document><m1parbreak></m1parbreak><m1parbreak></m1parbreak><m1heading level="1"><span style="display: inline-block">Reproducer document</span></m1heading><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block">Example</span></m1heading><m1parbreak></m1parbreak><m1parbreak></m1parbreak><p>Just the source (ok)</p><m1parbreak></m1parbreak><m1verbatim src="````
|
||||||
|
|
||||||
== Under the Greenwood Tree
|
== Under the Greenwood Tree
|
||||||
by Shakespeare.
|
by Shakespeare.
|
||||||
|
|
@ -19,17 +19,7 @@ Under the greenwood tree #emoji.tree
|
||||||
Who loves to lie with me,
|
Who loves to lie with me,
|
||||||
...
|
...
|
||||||
```)
|
```)
|
||||||
````"></m1verbatim><m1parbreak></m1parbreak><p>Source in grid</p><m1parbreak></m1parbreak><table x="test"><tr><td><p>Placeholder for</p><m1linebreak></m1linebreak><p>separately rendered SVG</p></td><td><m1verbatim src="````
|
````"></m1verbatim><m1parbreak></m1parbreak><p>Source in grid</p><m1parbreak></m1parbreak><table x="test"><tr><td></td><td></td></tr></table></m1document></body>
|
||||||
|
|
||||||
== Under the Greenwood Tree
|
|
||||||
by Shakespeare.
|
|
||||||
|
|
||||||
#some-function(```
|
|
||||||
Under the greenwood tree #emoji.tree
|
|
||||||
Who loves to lie with me,
|
|
||||||
...
|
|
||||||
```)
|
|
||||||
````"></m1verbatim></td></tr></table></m1document></body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
@ -57,26 +47,7 @@ Source in grid
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td /><td />
|
||||||
|
|
||||||
Placeholder for<br />
|
|
||||||
separately rendered SVG
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
````
|
|
||||||
|
|
||||||
== Under the Greenwood Tree
|
|
||||||
by Shakespeare.
|
|
||||||
|
|
||||||
#some-function(```
|
|
||||||
Under the greenwood tree #emoji.tree
|
|
||||||
Who loves to lie with me,
|
|
||||||
...
|
|
||||||
```)
|
|
||||||
````
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,58 +9,10 @@ input_file: crates/typlite/src/fixtures/integration/issue-1845.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1grid><m1table><table><tr><td>Header</td><td>Row</td></tr><tr><td><m1raw lang="" block="true" text="Code line 1
|
<body><m1document><m1grid><m1table><table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table></m1table></m1grid></m1document></body>
|
||||||
Code line 2"><pre><p>Code line 1</p><m1linebreak></m1linebreak><p>Code line 2</p></pre></m1raw></td><td>Regular text</td></tr></table></m1table></m1grid></m1document></body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
<table>
|
| | |
|
||||||
|
| --- | --- |
|
||||||
<tr>
|
| | |
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
Header
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
Row
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr><tr>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<m1raw lang="" block="true" text="Code line 1
|
|
||||||
Code line 2">
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
Code line 1
|
|
||||||
|
|
||||||
</p><m1linebreak>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</m1linebreak><p>
|
|
||||||
|
|
||||||
Code line 2
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</m1raw>
|
|
||||||
|
|
||||||
</td><td>
|
|
||||||
|
|
||||||
Regular text
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
source: crates/typlite/src/tests.rs
|
source: crates/typlite/src/tests.rs
|
||||||
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
expression: "conv(world, ConvKind::Md { for_docs: false })"
|
||||||
input_file: crates/typlite/src/fixtures/integration/linebreak.typ
|
input_file: crates/typlite/src/fixtures/integration/linebreak.typ
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
@ -10,7 +9,7 @@ snapshot_kind: text
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><p>Text2</p><m1linebreak></m1linebreak><p>Text1</p><m1linebreak></m1linebreak><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block;">H1</span></m1heading></m1document></body>
|
<body><m1document><p>Text2</p><m1linebreak></m1linebreak><p>Text1</p><m1linebreak></m1linebreak><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block">H1</span></m1heading></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ input_file: crates/typlite/src/fixtures/integration/outline.typ
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body><m1document><m1outline><m1heading level="1"><span style="display: inline-block;">Contents</span></m1heading><m1outentry level="2"><m1heading level="2"><span style="display: inline-block;">Heading 1</span></m1heading></m1outentry><m1outentry level="3"><m1heading level="3"><span style="display: inline-block;">Heading 2</span></m1heading></m1outentry></m1outline><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block;">Heading 1</span></m1heading><m1parbreak></m1parbreak><m1heading level="3"><span style="display: inline-block;">Heading 2</span></m1heading><m1parbreak></m1parbreak><p><span><m1link dest="https://example.com">This is a link to example.com</m1link></span></p><m1parbreak></m1parbreak><p>Inline <span><m1raw lang="" block="false" text="code"><code>code</code></m1raw></span> has <span><m1raw lang="" block="false" text="back-ticks around"><code>back-ticks around</code></m1raw></span> it.</p><m1parbreak></m1parbreak><m1raw lang="cs" block="true" text="using System.IO.Compression;
|
<body><m1document><m1outline><nav role="doc-toc"><m1heading level="1"><span style="display: inline-block">Contents</span></m1heading><ol style="list-style-type: none"><li><div><m1outentry level="2"><m1heading level="2"><span style="display: inline-block">Heading 1</span></m1heading></m1outentry></div><ol style="list-style-type: none"><li><m1outentry level="3"><m1heading level="3"><span style="display: inline-block">Heading 2</span></m1heading></m1outentry></li></ol></li></ol></nav></m1outline><m1parbreak></m1parbreak><m1heading level="2"><span style="display: inline-block">Heading 1</span></m1heading><m1parbreak></m1parbreak><m1heading level="3"><span style="display: inline-block">Heading 2</span></m1heading><m1parbreak></m1parbreak><p><span><m1link dest="https://example.com">This is a link to example.com</m1link></span></p><m1parbreak></m1parbreak><p>Inline <span><m1raw lang block="false" text="code"><code>code</code></m1raw></span> has <span><m1raw lang block="false" text="back-ticks around"><code>back-ticks around</code></m1raw></span> it.</p><m1parbreak></m1parbreak><m1raw lang="cs" block="true" text="using System.IO.Compression;
|
||||||
|
|
||||||
#pragma warning disable 414, 3021
|
#pragma warning disable 414, 3021
|
||||||
|
|
||||||
|
|
@ -24,15 +24,20 @@ namespace MyApplication
|
||||||
return new List<int>(new int[] { 1, 2, 3 })
|
return new List<int>(new int[] { 1, 2, 3 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"><pre><p>using System.IO.Compression;</p><m1linebreak></m1linebreak><m1linebreak></m1linebreak><p>#pragma warning disable 414, 3021</p><m1linebreak></m1linebreak><m1linebreak></m1linebreak><p>namespace MyApplication</p><m1linebreak></m1linebreak><p>{</p><m1linebreak></m1linebreak><p> [Obsolete("...")]</p><m1linebreak></m1linebreak><p> class Program : IInterface</p><m1linebreak></m1linebreak><p> {</p><m1linebreak></m1linebreak><p> public static List<int> JustDoIt(int count)</p><m1linebreak></m1linebreak><p> {</p><m1linebreak></m1linebreak><p> Console.WriteLine($"Hello {Name}!");</p><m1linebreak></m1linebreak><p> return new List<int>(new int[] { 1, 2, 3 })</p><m1linebreak></m1linebreak><p> }</p><m1linebreak></m1linebreak><p> }</p><m1linebreak></m1linebreak><p>}</p></pre></m1raw><m1parbreak></m1parbreak><p>Math inline:</p><m1eqinline>redacted-frame</m1eqinline><p>and block:</p><m1eqblock>redacted-frame</m1eqblock><m1parbreak></m1parbreak><ul><li>First item</li><li><p>Second item</p><ol><li>First sub-item</li><li><p>Second sub-item</p><ul><li>First sub-sub-item</li></ul></li></ol></li></ul><m1parbreak></m1parbreak><dl><dt>First term</dt><dd>First definition</dd></dl><m1parbreak></m1parbreak><m1table><table><tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td></tr></table></m1table></m1document></body>
|
}"><pre><code data-lang="cs"><p><span style="color: #d73948">using</span> System.IO.Compression;</p><m1linebreak></m1linebreak><m1linebreak></m1linebreak><p><span style="color: #d73948">#</span><span style="color: #d73948">pragma</span> <span style="color: #d73948">warning</span> <span style="color: #d73948">disable</span> 414, 3021</p><m1linebreak></m1linebreak><m1linebreak></m1linebreak><p><span style="color: #d73948">namespace</span> <span style="color: #4b69c6">MyApplication</span></p><m1linebreak></m1linebreak><p>{</p><m1linebreak></m1linebreak><p> <span style="color: #301414">[</span><span style="color: #301414">Obsolete</span><span style="color: #301414">(</span><span style="color: #198810">"</span><span style="color: #198810">...</span><span style="color: #198810">"</span><span style="color: #301414">)</span><span style="color: #301414">]</span></p><m1linebreak></m1linebreak><p> <span style="color: #d73948">class</span> <span style="color: #4b69c6">Program</span> : <span style="color: #8b41b1">IInterface</span></p><m1linebreak></m1linebreak><p> {</p><m1linebreak></m1linebreak><p> <span style="color: #d73948">public</span> <span style="color: #d73948">static</span> <span style="color: #4b69c6">List</span><<span style="color: #d73948">int</span>> <span style="color: #4b69c6">JustDoIt</span>(<span style="color: #d73948">int</span> count)</p><m1linebreak></m1linebreak><p> {</p><m1linebreak></m1linebreak><p> Console.<span style="color: #4b69c6">WriteLine</span>(<span style="color: #198810">$"</span><span style="color: #198810">Hello </span>{Name}<span style="color: #198810">!</span><span style="color: #198810">"</span>);</p><m1linebreak></m1linebreak><p> <span style="color: #d73948">return</span> <span style="color: #d73948">new</span> <span style="color: #4b69c6">List</span><<span style="color: #d73948">int</span>>(<span style="color: #d73948">new</span> <span style="color: #d73948">int</span>[] { <span style="color: #b60157">1</span>, <span style="color: #b60157">2</span>, <span style="color: #b60157">3</span> })</p><m1linebreak></m1linebreak><p> }</p><m1linebreak></m1linebreak><p> }</p><m1linebreak></m1linebreak><p>}</p></code></pre></m1raw><m1parbreak></m1parbreak><p>Math inline:</p><m1eqinline>redacted-frame</m1eqinline><p>and block:</p><m1eqblock>redacted-frame</m1eqblock><m1parbreak></m1parbreak><ul><li>First item</li><li><p>Second item</p><ol><li>First sub-item</li><li><p>Second sub-item</p><ul><li>First sub-sub-item</li></ul></li></ol></li></ul><m1parbreak></m1parbreak><dl><dt>First term</dt><dd>First definition</dd></dl><m1parbreak></m1parbreak><m1table><table><tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td></tr></table></m1table></m1document></body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
=====
|
=====
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
### Heading 1
|
1. ### Heading 1
|
||||||
|
1. #### Heading 2
|
||||||
|
|
||||||
#### Heading 2
|
<nav role="doc-toc">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
### Heading 1
|
### Heading 1
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue