Skip to content

Commit

Permalink
[add] feature to not evaluate but display code (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
nineff authored Feb 27, 2025
1 parent 11bf61e commit a41a7e0
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit a41a7e0

Please sign in to comment.