diff --git a/scripts/build-book b/scripts/build-book
index f1d8b7b..62af9b9 100755
--- a/scripts/build-book
+++ b/scripts/build-book
@@ -23,7 +23,7 @@ sub not-ignored($path) {
# Copy a file from the current directory to the temporary directory, preserving
# realtive path. Resolves symlinks in source, but does not reflect symlink
# resoultion in the output path
-sub cp-temp($src) {
+sub copy-to-dest($src) {
my $src-path = do given $src {
when Str {
$src.IO
@@ -45,42 +45,16 @@ sub cp-temp($src) {
$src-path.resolve.copy: $output-path;
}
-# Invoke katla on a source file, streaming its output to the temporary directory
-sub katla($src, $ttc-src) {
- # Run katla and collect the output
- my $katla = run 'katla', 'markdown', $src, $ttc-src, :out;
- my $output = $katla.out.slurp(:close);
- # TODO: Post process them to set themeing correctly
- $output ~~ s:g/''//;
- $output ~~ s:g/'
'//;
- $output ~~ s:g/'\\*'/*/;
- $output ~~ s:g/'\\_'/_/;
- $output ~~ s:g/'\\\\'/\\/;
- $output ~~ s:g/''/<\/code><\/pre>/;
- $output ~~ s:g/'class="IdrisKeyword"'/class="hljs-keyword"/;
- $output ~~ s:g/'class="IdrisModule"'/class="hljs-symbol hljs-emphasis"/;
- $output ~~ s:g/'class="IdrisComment"'/class="hljs-comment"/;
- $output ~~ s:g/'class="IdrisFunction"'/class="hljs-symbol"/;
- $output ~~ s:g/'class="IdrisBound"'/class="hljs-name"/;
- $output ~~ s:g/'class="IdrisData"'/class="hljs-title"/;
- $output ~~ s:g/'class="IdrisType"'/class="hljs-type"/;
- $output ~~ s:g/'class="IdrisNamespace"'/class="hljs-symbol hljs-emphasis"/;
-
- # Spurt the output to the temporary directory
- my $output-path = $tempdir.add: $src;
- if !$output-path.parent.d {
- $output-path.parent.mkdir;
- }
- $output-path.spurt($output);
-}
+# Special handling for our readme file, we need to butcher up it's links
+my $readme-contents = 'README.md'.IO.slurp;
+$readme-contents ~~ s:g/'src/'//;
+my $readme-dest = $tempdir.add('src/README.md');
+$readme-dest.parent.mkdir;
+$readme-dest.spurt: $readme-contents;
# Copy our metadata files
-cp-temp "book.toml";
-# TODO: Special Handling for the README so we don't need the symlink and the
-# links work
-cp-temp "src/README.md";
-cp-temp "src/SUMMARY.md";
+copy-to-dest "book.toml";
+copy-to-dest "src/SUMMARY.md";
# Katla over the source files
for paths("src", :file(*.¬-ignored)) -> $path {
@@ -104,3 +78,38 @@ if $upload {
'ubuntu@static.stranger.systems:/var/www/static.stranger.systems/idris-by-contrived-example';
die "rsync went bad" unless $rsync;
}
+
+# This function goes at the end because it breaks emacs fontification after it
+# for some bizzare reason.
+#
+# Invoke katla on a source file, streaming its output to the temporary directory
+sub katla($src, $ttc-src) {
+ # Run katla and collect the output
+ my $katla = run 'katla', 'markdown', $src, $ttc-src, :out;
+ my $output = $katla.out.slurp(:close);
+ # Post process them to set themeing correctly
+ # TODO: We need to remove the extra new line after the start of code blocks
+ # still
+ $output ~~ s:g/''//;
+ $output ~~ s:g/'
'//;
+ $output ~~ s:g/'\\*'/*/;
+ $output ~~ s:g/'\\_'/_/;
+ $output ~~ s:g/'\\\\'/\\/;
+ $output ~~ s:g/''/<\/code><\/pre>/;
+ $output ~~ s:g/'="IdrisKeyword"'/="hljs-keyword"/;
+ $output ~~ s:g/'="IdrisModule"'/="hljs-symbol hljs-emphasis"/;
+ $output ~~ s:g/'="IdrisComment"'/="hljs-comment"/;
+ $output ~~ s:g/'="IdrisFunction"'/="hljs-symbol"/;
+ $output ~~ s:g/'="IdrisBound"'/="hljs-name"/;
+ $output ~~ s:g/'="IdrisData"'/="hljs-title"/;
+ $output ~~ s:g/'="IdrisType"'/="hljs-type"/;
+ $output ~~ s:g/'="IdrisNamespace"'/="hljs-symbol hljs-emphasis"/;
+
+ # Spurt the output to the temporary directory
+ my $output-path = $tempdir.add: $src;
+ if !$output-path.parent.d {
+ $output-path.parent.mkdir;
+ }
+ $output-path.spurt($output);
+}