diff --git a/src/Bif/Bif.fsproj b/src/Bif/Bif.fsproj deleted file mode 100644 index b6d18c5..0000000 --- a/src/Bif/Bif.fsproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - Exe - net10.0 - - - - - - - - - - - diff --git a/src/Bif/Program.fs b/src/Bif/Program.fs deleted file mode 100644 index 3e108fb..0000000 --- a/src/Bif/Program.fs +++ /dev/null @@ -1,82 +0,0 @@ -open System.Net -open System.IO -open Fibble.FibLib -open Fibble.FibLib.Ast // Ger oss tillgång till Element, Text, RawHtml etc. -open Fibble.FibLib.Pandoc -open Fibble.FibLib.Utils - -// ========================================== -// 1. Prelude (Dina egna taggar) -// ========================================== - - -let myPrelude : Map = - Map [ - "quotient", fun _ args _ -> - match args with - | [_, one; _, two] -> - Text (sprintf "%d" (int one / int two)) - | _ -> - Text "[Fel: quotient kräver två argument]" - "bold", fun _ args children -> - Element("b", args, children) - "image", positional (fun _ args _ -> Element("img", [("src", args[0])], [])) - "value", positional (fun meta args _ -> - match Map.tryFind args.Head meta with - | Some(v) -> Text v - | None -> Text $"value {args.Head} not found in metadata") - "link", positional (fun _ args children -> - let url = if args.Length > 0 then args.[0].Trim '"' else "#" - Element("a", [("href", args.Head)], children)) - - // @br har varken argument eller barn, så vi returnerar bara rå HTML direkt - "br", nameToElement "br" - "table", fun _ _ children -> Text "hej" - "md", fun meta args children -> RawHtml (mdToHtml (stringifyNodes children)) - ] - -// ========================================== -// 2. Mall och Evaluator -// ========================================== -// -module File = - let readFile path = - match Path.Exists(path) with - | true -> File.ReadAllText(path) - | _ -> failwith $"{path} does not exist" - -let pageTemplate = File.readFile "_page-template" - -let sourceCode = File.readFile "document.fib" -// ========================================== -// 3. Huvudpipeline -// ========================================== -let processDocument (source: string) = - let evaluator = Evaluators.FsiEvaluator() - - // Steg 1: Parsa koden - let metadata, rawBlocks = Parser.parse source - - - // Steg 2: Transformera och exekvera trädet - let evaluatedBlocks = - rawBlocks |> List.map (function - | Paragraph children -> - Paragraph (children - |> List.map (Execution.transform metadata myPrelude evaluator)) - | Section(l, a, children) -> - Section(l, a, children - |> List.map (Execution.transform metadata myPrelude evaluator)) - ) - - // Steg 3: Be printern skriva ut trädet till HTML - let bodyHtml = HtmlPrinter.render (metadata, evaluatedBlocks) - - // Steg 4: Fyll i din HTML-mall - let mutable finalHtml = pageTemplate.Replace("{{body}}", bodyHtml) - - finalHtml - -// Kör programmet -let output = processDocument sourceCode -printfn "%s" output diff --git a/src/Bif/document.fib b/src/Bif/document.fib deleted file mode 100644 index 923d706..0000000 --- a/src/Bif/document.fib +++ /dev/null @@ -1,39 +0,0 @@ ---- -author: bajs -date: yesterday -title: FSI Test ---- - -@section{Definitioner} -Vi definierar en funktion och en variabel. -@""" -let globalCounter = ref 0 - -let increment () = - globalCounter.Value <- globalCounter.Value + 1 - sprintf "Räknaren är nu %d" globalCounter.Value -""" -@(1) - -@link[www.google.com]{hejsan hoppsan fallerallera} - -Detta är en paragraf som har lite text i sig och lite @md{inbäddad *markdown* som kanske} funkar. Det är bra så. - -@md{ -en tabell - -hej hopp ---- ---- -abc defg -bde dddd -ueo eoau -ueo aoeu -} - -elleR? - -@section{Användning} -Första anropet: @(increment()) -Andra anropet: @(increment()) - -Test av utskrift: @value[date]