Skip to content

Instantly share code, notes, and snippets.

@librasteve
Created June 2, 2023 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save librasteve/79a2731e699022ebbda737131b37c4f9 to your computer and use it in GitHub Desktop.
Save librasteve/79a2731e699022ebbda737131b37c4f9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env raku
use MONKEY-SEE-NO-EVAL;
#| takes markdown file and evals all code lines delimited by '```'
sub MAIN(
$filename!, #= '/pathto/example.md'
) {
my @lines = $filename.IO.lines or die 'no file found';
my $toggle = False;
my $code;
for @lines -> $line {
when $line ~~ /^ '```perl6'/ { $toggle = True }
when $line ~~ /^ '```'/ { $toggle = False }
when $toggle { $code ~= "$line\n" }
}
EVAL $code // warn "no code found";
}
#`[
##ramd - raku markdown Provides literate programming as the combination of markdown explanation and embedded raku code.
- write a regular markdown file with filetype '.md'
- place raku code in line-oriented triple backticks as perl6
- go ./bin/ramd README.md to run the main README.md
- go [raws](./literature/raws.md) to link another md file
- go say qqx`./bin/ramd ./literature/raws.md`; to include it
#]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment