From a41a7e083a9188d4cfa7bdf80464d0b2a9607587 Mon Sep 17 00:00:00 2001 From: Nikolai Neff-Sarnow Date: Thu, 27 Feb 2025 21:04:26 +0100 Subject: [PATCH] [add] feature to not evaluate but display code (#44) --- src/show-example.typ | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/show-example.typ b/src/show-example.typ index 8fa2105..69a7dbe 100644 --- a/src/show-example.typ +++ b/src/show-example.typ @@ -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. @@ -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")