Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add feature to not evaluate but display code #44

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/show-example.typ
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
///
/// Lines in the raw code that start with `>>>` are removed from the outputted code
/// but evaluated in the preview.
///
/// Lines starting with `<<<` are displayed in the preview, but not evaluated.
#let show-example(

/// Raw object holding the example code.
Expand Down Expand Up @@ -152,12 +154,16 @@
..options

) = {
let displayed-code = code.text
let displayed-code = code
.text
.split("\n")
.filter(x => not x.starts-with(">>>"))
.map(x => x.trim("<<<", at: start))
.join("\n")
let executed-code = code.text
let executed-code = code
.text
.split("\n")
.filter(x => not x.starts-with("<<<"))
.map(x => x.trim(">>>", at: start))
.join("\n")

Expand Down