commit 7f72a5c2394fa31a727ce5306626eecc2c0ca474
parent 638ce3304b7ed23cfe24ecefee5f0d469946f481
Author: Andrew Laack <andrew@laack.co>
Date: Thu, 27 Aug 2026 00:13:55 -0500
Basic rendering of md -> html
Diffstat:
5 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/example/ocaml.rl b/example/ocaml.rl
@@ -0,0 +1,13 @@
+# OCaml
+
+## History
+
+OCaml is the acronym for Objective Categorical Abstract Machine Language.
+
+## Syntax
+
+In OCaml we use the 'let' keyword to bind a expressions to names (variables). Shown below is an example of this:
+
+```ocaml
+let x = 10
+```
diff --git a/learning/bin/dune b/learning/bin/dune
@@ -1,4 +1,4 @@
(executable
(public_name learning)
(name main)
- (libraries learning))
+ (libraries dream))
diff --git a/learning/bin/main.ml b/learning/bin/main.ml
@@ -1 +1,34 @@
-let () = print_endline "Hello, World!"
+let countPrefix char data =
+ let rec go idx =
+ if String.length data > idx && data.[idx] = char
+ then
+ go (idx + 1)
+ else idx
+ in go 0
+
+
+let handle_normal_line line =
+ if String.length line > 0 then
+ let hashCount = countPrefix '#' line in
+ if hashCount > 0
+ then
+ "<h" ^ string_of_int hashCount ^ ">" ^ line ^ "</h" ^ string_of_int hashCount ^ ">"
+ else
+ "<div>" ^ line ^ "</div>"
+ else
+ "<div>" ^ line ^ "<div>"
+
+
+let readFile fileName =
+ let ic = open_in fileName in
+ let rec readAll acc =
+ try
+ readAll (acc ^ (handle_normal_line (input_line ic)) ^ "\n")
+ with End_of_file ->
+ close_in_noerr ic;
+ acc
+ in readAll ""
+
+let () =
+ Dream.run (fun _ ->
+ Dream.html (readFile "../example/ocaml.rl"))
diff --git a/learning/dune-project b/learning/dune-project
@@ -5,11 +5,11 @@
(generate_opam_files true)
(source
- (github username/reponame))
+ (github andrewlaack/learning-takes-time))
-(authors "Author Name <author@example.com>")
+(authors "Andrew Laack <andrew@laack.co>")
-(maintainers "Maintainer Name <maintainer@example.com>")
+(maintainers "Andrew Laack <andrew@laack.co>")
(license LICENSE)
@@ -19,7 +19,7 @@
(name learning)
(synopsis "A short synopsis")
(description "A longer description")
- (depends ocaml)
+ (depends ocaml dream)
(tags
("add topics" "to describe" your project)))
diff --git a/learning/dune-workspace b/learning/dune-workspace
@@ -0,0 +1,2 @@
+(lang dune 3.21)
+(pkg enabled)