From d09b6410643208561098429443d1bfcf2a13b005 Mon Sep 17 00:00:00 2001 From: Dan Baker Date: Fri, 9 Feb 2024 13:50:18 -0800 Subject: [PATCH] Made fenced code blocks prettier with syntax highlights and filenames. (#7) --- lessons/010-basic-types/{run => run.sh} | 0 lib/lessons.nix | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) rename lessons/010-basic-types/{run => run.sh} (100%) diff --git a/lessons/010-basic-types/run b/lessons/010-basic-types/run.sh similarity index 100% rename from lessons/010-basic-types/run rename to lessons/010-basic-types/run.sh diff --git a/lib/lessons.nix b/lib/lessons.nix index f7594c8..2a0be3f 100644 --- a/lib/lessons.nix +++ b/lib/lessons.nix @@ -14,6 +14,21 @@ ) ); + getFileExtension = path: ( + lib.concatStringsSep + "." + ( + builtins.tail ( + lib.splitString + "." + ( + builtins.baseNameOf + path + ) + ) + ) + ); + createLessonMetadata = name: value: let lessonPath = value; rawLesson = builtins.readFile (lib.path.append lessonPath "lesson.md"); @@ -35,8 +50,10 @@ textToSubstitute = ( builtins.map ( - file: '' - ``` + file: let + fileExtension = getFileExtension file; + in '' + ``` ${fileExtension} title="${file}" ${ builtins.readFile (