My personal website, in gleam+lustre!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

following for djotparse


Signed-off-by: MLC Bloeiman <mar@strawmelonjuice.com>

+14 -3
+14 -3
src/homepage/djotparse.gleam
··· 5 5 import gleam/list 6 6 import gleam/option.{type Option, None, Some} 7 7 import gleam/string 8 + import homepage/stuff 8 9 import homepage/stuff/prestyled_elements 9 10 import jot 11 + import lustre/attribute 10 12 import lustre/element 11 13 import smalto 12 14 import smalto/grammar.{type Grammar} ··· 17 19 import smalto/languages/rust 18 20 19 21 pub fn djot_to_html(djot djot: String) -> String { 20 - let #(h1, h2, h3, h4) = { 22 + let #(h1, h2, h3, h4, a, p) = { 23 + // keep the styling defined in one place. 21 24 #( 22 25 // H1 > H3 23 26 prestyled_elements.h3("") |> element.to_string() |> string.drop_end(6), ··· 27 30 prestyled_elements.h5("") |> element.to_string() |> string.drop_end(6), 28 31 // H5 > H6 29 32 prestyled_elements.h6("") |> element.to_string() |> string.drop_end(6), 33 + // links 34 + prestyled_elements.link(stuff.NotFound(""), "", fn(_) { attribute.none() }) 35 + |> element.to_string() 36 + |> string.drop_end(5), 37 + // paragraphs 38 + prestyled_elements.paragraph("") 39 + |> element.to_string() 40 + |> string.drop_end(4), 30 41 ) 31 42 } 32 43 djot 33 44 |> preprocess_codeblocks 34 45 |> preprocess_tables 35 46 |> jot.to_html 36 - |> string.replace("<p>", "<p class=\"mt-4\">") 47 + |> string.replace("<p>", p) 37 48 |> string.replace("<li", "<li class=\"mt-2\"") 38 49 |> string.replace("<h4", h4) 39 50 |> string.replace("<h3", h3) 40 51 |> string.replace("<h2", h2) 41 52 |> string.replace("<h1", h1) 42 - |> string.replace("<a ", "<a class=\"link link-accent\" ") 53 + |> string.replace("<a ", a) 43 54 |> string.replace("<strong", "<strong class=\"font-bold\"") 44 55 |> string.replace("<em", "<em class=\"italic\"") 45 56 |> string.replace("<ul", "<ul class=\"list-inside list-disc\"")