8/4/26 21:23
This commit is contained in:
+24
-2
@@ -8,9 +8,17 @@ import "core:path/filepath"
|
||||
import "core:strings"
|
||||
import http "submodules/odin-http"
|
||||
|
||||
foreign import goldmark "libgoldmark.lib"
|
||||
|
||||
foreign goldmark {
|
||||
MarkdownToHTML :: proc(source: cstring) -> cstring ---
|
||||
FreeString :: proc(s: cstring) ---
|
||||
}
|
||||
|
||||
State :: struct {
|
||||
num: int,
|
||||
global_css: string,
|
||||
num: int,
|
||||
global_css: string,
|
||||
import_html: cstring,
|
||||
}
|
||||
|
||||
state := State {
|
||||
@@ -18,6 +26,18 @@ state := State {
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
|
||||
markdown, err1 := os.read_entire_file_from_path("test.markdown", context.temp_allocator)
|
||||
|
||||
src_c := strings.clone_to_cstring(string(markdown))
|
||||
result_c := MarkdownToHTML(src_c)
|
||||
|
||||
defer FreeString(result_c)
|
||||
defer delete(src_c)
|
||||
|
||||
state.import_html = result_c
|
||||
|
||||
|
||||
context.logger = log.create_console_logger(.Info)
|
||||
|
||||
data, err2 := os.read_entire_file_from_path("styles/main.css", context.temp_allocator)
|
||||
@@ -56,6 +76,8 @@ main :: proc() {
|
||||
|
||||
err := http.listen_and_serve(&s, routed, net.Endpoint{address = net.IP4_Loopback, port = 6969})
|
||||
fmt.assertf(err == nil, "server stopped with error: %v", err)
|
||||
|
||||
free_all(context.temp_allocator)
|
||||
}
|
||||
|
||||
// ROUTERS
|
||||
|
||||
Reference in New Issue
Block a user