# HG changeset patch # User June Park # Date 1768406359 28800 # Node ID 1c0878eb17debdfca274bb75afbefe67bad66c96 # Parent 2db6253f355dfdfb5ed5ea8375ead799180c6d73 [MrJuneJune] Readme file gets compiled in server side. diff -r 2db6253f355d -r 1c0878eb17de markdown_converter/BUILD --- a/markdown_converter/BUILD Tue Jan 13 19:18:47 2026 -0800 +++ b/markdown_converter/BUILD Wed Jan 14 07:59:19 2026 -0800 @@ -10,9 +10,18 @@ visibility = ["//visibility:public"], ) +filegroup( + name = "markdown_to_html_hdrs", + srcs = glob([ + "*.h", + ], allow_empty=True), + visibility = ["//visibility:public"], +) + # C implementation for native use cc_library( name = "markdown_to_html_c", srcs = ["markdown_to_html.c"], + hdrs = [":markdown_to_html_hdrs"], visibility = ["//visibility:public"], ) diff -r 2db6253f355d -r 1c0878eb17de markdown_converter/markdown_to_html.c --- a/markdown_converter/markdown_to_html.c Tue Jan 13 19:18:47 2026 -0800 +++ b/markdown_converter/markdown_to_html.c Wed Jan 14 07:59:19 2026 -0800 @@ -1,74 +1,10 @@ -/** - * Markdown to HTML Converter - C Implementation - * Supports: headers, bold, italic, links, lists, code blocks, blockquotes, horizontal rules - */ - -#ifndef MARKDOWN_TO_HTML_H -#define MARKDOWN_TO_HTML_H - -#include - -// Export macro for WASM/Emscripten -#ifdef __EMSCRIPTEN__ - #include - #define MDAPI EMSCRIPTEN_KEEPALIVE -#else - #ifdef _WIN32 - #ifdef MARKDOWN_EXPORTS - #define MDAPI __declspec(dllexport) - #else - #define MDAPI __declspec(dllimport) - #endif - #else - #define MDAPI extern - #endif -#endif - -/** - * Convert markdown string to HTML string. - * - * @param markdown The input markdown string (null-terminated) - * @return Newly allocated HTML string. Caller must free with markdown_free(). - * Returns NULL on allocation failure. - * - * Supported markdown features: - * - Headers: # H1, ## H2, ... ###### H6 - * - Bold: **text** or __text__ - * - Italic: *text* or _text_ - * - Strikethrough: ~~text~~ - * - Links: [text](url) - * - Images: ![alt](url) - * - Inline code: `code` - * - Code blocks: ```code``` - * - Unordered lists: -, *, + - * - Ordered lists: 1., 2., etc. - * - Blockquotes: > text - * - Horizontal rules: ---, ***, ___ - */ -MDAPI char *markdown_to_html(const char *markdown); - -/** - * Free HTML string returned by markdown_to_html. - * - * @param html The HTML string to free - */ -MDAPI void markdown_free(char *html); - -/** - * Get length of HTML string (useful for WASM memory operations). - * - * @param html The HTML string - * @return Length of the string, or 0 if NULL - */ -MDAPI size_t markdown_get_length(const char *html); - -#endif // MARKDOWN_TO_HTML_H #include #include #include #include +#include "markdown_converter/markdown_to_html.h" -#define INITIAL_BUFFER_SIZE 4096 +#define INITIAL_BUFFER_SIZE 1024 * 1024 // 1MB // String buffer for building HTML output typedef struct { @@ -319,16 +255,18 @@ } } + // This might not be needed for now. // HTML escape special characters - if (text[i] == '<') { - buffer_append(buf, "<"); - } else if (text[i] == '>') { - buffer_append(buf, ">"); - } else if (text[i] == '&') { - buffer_append(buf, "&"); - } else { - buffer_append_char(buf, text[i]); - } + // if (text[i] == '<') { + // buffer_append(buf, "<"); + // } else if (text[i] == '>') { + // buffer_append(buf, ">"); + // } else if (text[i] == '&') { + // buffer_append(buf, "&"); + // } else { + // buffer_append_char(buf, text[i]); + // } + buffer_append_char(buf, text[i]); i++; } } diff -r 2db6253f355d -r 1c0878eb17de markdown_converter/markdown_to_html.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/markdown_converter/markdown_to_html.h Wed Jan 14 07:59:19 2026 -0800 @@ -0,0 +1,64 @@ +/** + * Markdown to HTML Converter - C Implementation + * Supports: headers, bold, italic, links, lists, code blocks, blockquotes, horizontal rules + */ +#ifndef MARKDOWN_TO_HTML_H +#define MARKDOWN_TO_HTML_H + +#include + +// Export macro for WASM/Emscripten +#ifdef __EMSCRIPTEN__ + #include + #define MDAPI EMSCRIPTEN_KEEPALIVE +#else + #ifdef _WIN32 + #ifdef MARKDOWN_EXPORTS + #define MDAPI __declspec(dllexport) + #else + #define MDAPI __declspec(dllimport) + #endif + #else + #define MDAPI extern + #endif +#endif + +/** + * Convert markdown string to HTML string. + * + * @param markdown The input markdown string (null-terminated) + * @return Newly allocated HTML string. Caller must free with markdown_free(). + * Returns NULL on allocation failure. + * + * Supported markdown features: + * - Headers: # H1, ## H2, ... ###### H6 + * - Bold: **text** or __text__ + * - Italic: *text* or _text_ + * - Strikethrough: ~~text~~ + * - Links: [text](url) + * - Images: ![alt](url) + * - Inline code: `code` + * - Code blocks: ```code``` + * - Unordered lists: -, *, + + * - Ordered lists: 1., 2., etc. + * - Blockquotes: > text + * - Horizontal rules: ---, ***, ___ + */ +MDAPI char *markdown_to_html(const char *markdown); + +/** + * Free HTML string returned by markdown_to_html. + * + * @param html The HTML string to free + */ +MDAPI void markdown_free(char *html); + +/** + * Get length of HTML string (useful for WASM memory operations). + * + * @param html The HTML string + * @return Length of the string, or 0 if NULL + */ +MDAPI size_t markdown_get_length(const char *html); + +#endif // MARKDOWN_TO_HTML_H diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/BUILD --- a/mrjunejune/BUILD Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/BUILD Wed Jan 14 07:59:19 2026 -0800 @@ -4,7 +4,7 @@ # Files move_files_into_dir( - name = "compiled_ts_games", + name = "react_pages", srcs = [ "//react_games:games" ], @@ -12,17 +12,24 @@ ) move_files_into_dir( - name = "compiled_ts", + name = "shared_js_non_public", srcs = [ "//markdown_converter:markdown_to_html", - "//markdown_converter:markdown_to_html_wasm", ], dest = "src", ) +move_files_into_dir( + name = "shared_js_file", + srcs = [ + "//third_party/highlight:js", + ], + dest = "src/public/highlight", +) + filegroup( name = "src_files", - srcs = glob(["src/**"]) + [":compiled_ts", ":compiled_ts_games"], + srcs = glob(["src/**"]) + [":react_pages", ":shared_js_non_public", "shared_js_file"], visibility = ["//mrjunejune/test:__pkg__"], ) @@ -30,7 +37,10 @@ cc_binary( name = "mrjunejune_server", srcs = ["main.c"], - deps = ["//seobeo:seobeo_tcp_server_ws"], + deps = [ + "//seobeo:seobeo_tcp_server_ws", + "//markdown_converter:markdown_to_html_c", + ], data = [":src_files"], visibility = ["//mrjunejune/test:__pkg__"], ) @@ -39,7 +49,10 @@ cc_binary( name = "mrjunejune_server_debug", srcs = ["main.c"], - deps = ["//seobeo:seobeo_tcp_server_ws_debug"], + deps = [ + "//seobeo:seobeo_tcp_server_ws_debug", + "//markdown_converter:markdown_to_html_c" + ], data = [":src_files"], ) diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mrjunejune/README.md Wed Jan 14 07:59:19 2026 -0800 @@ -0,0 +1,9 @@ +# Mrjunejune + +My personal website where I post my blogs / about me and resume. + +## TODO + +- Add caching layer +- Update talk to be part +- Update test to automatically tests all paths for blogs. diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/main.c --- a/mrjunejune/main.c Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/main.c Wed Jan 14 07:59:19 2026 -0800 @@ -1,10 +1,30 @@ // Debug mode is now controlled by build target: use //seobeo:seobeo_tcp_server_ws_debug #include "seobeo/seobeo.h" +#include "markdown_converter/markdown_to_html.h" #include // UUID + /tmp/ + format (max 4) #define TMP_FILE_LENGTH 47 #define UUID_LEN 37 +#define BLOG_HTML "" \ +"" \ +"" \ +" " \ +" " \ +" Multi Threading in JS" \ +" {{/parts/base_head.html}}" \ +" " \ +" " \ +" " \ +"" \ +"" \ +" {{/parts/header.html}}" \ +"
" \ +"%s" \ +"
" \ +" {{/parts/footer.html}}" \ +" "\ +"" volatile sig_atomic_t stop_server = 0; static _Atomic uint32_t counter = 0; @@ -15,17 +35,12 @@ stop_server = 1; } -void Seobeo_ServerSideRender( +void Seobeo_Render_Html( char *final_body, - char *path, + char *template, Dowa_Arena *arena -) { - Seobeo_Log(SEOBEO_DEBUG, "[Curr] %s\n", path); - size_t html_size = 0; - char *template = Seobeo_Web_LoadFile(path, &html_size); - if (!template) return; - Seobeo_Log(SEOBEO_DEBUG, "[Curr] ??\n"); - +) +{ size_t current_offset = 0; char *cursor = template; @@ -61,14 +76,26 @@ cursor = end_tag + 2; } strcpy(final_body + current_offset, cursor); - free(template); +} + + +void Seobeo_Render_Html_FilePath( + char *final_body, + char *path, + Dowa_Arena *arena +) { + Seobeo_Log(SEOBEO_DEBUG, "[Curr] %s\n", path); + size_t html_size = 0; + char *template = Seobeo_Web_LoadFile(path, &html_size); + if (!template) return; + Seobeo_Render_Html(final_body, template, arena); } Seobeo_Request_Entry* GetHomePage(Seobeo_Request_Entry *req, Dowa_Arena *arena) { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -77,7 +104,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/resume/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/resume/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -86,7 +113,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/tools/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/tools/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -96,7 +123,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/tools/markdown_to_html/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/tools/markdown_to_html/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -105,7 +132,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/tools/file_converter/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/tools/file_converter/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -443,7 +470,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/blog/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/blog/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -451,7 +478,7 @@ Seobeo_Request_Entry *RenderBlog(Seobeo_Request_Entry *req, Dowa_Arena *arena) { - Seobeo_Log(SEOBEO_DEBUG, "[CURR], Hello\n"); + Seobeo_Log(SEOBEO_DEBUG, "[CURR], Blog\n"); Seobeo_Request_Entry *resp = NULL; void *blog_id_kv = Dowa_HashMap_Get_Ptr(req, ":blog_id"); @@ -465,11 +492,19 @@ } const char *blog_id = ((Seobeo_Request_Entry *)blog_id_kv)->value; - char *html_path = Dowa_Arena_Allocate(arena, 512); - sprintf(html_path, "/blog/%s/index.html", blog_id); + char *md_path = Dowa_Arena_Allocate(arena, 512); + sprintf(md_path, "/blog/%s/index.md", blog_id); + + size_t md_file_size = 0; + char *md_file = Seobeo_Web_LoadFile(md_path, &md_file_size); - char *final_body = Dowa_Arena_Allocate(arena, 100 * 1024); // TODO: Think about the sizes - Seobeo_ServerSideRender(final_body, html_path, arena); + char *md = markdown_to_html(md_file); + size_t buffer_sizes = 100 * 1024; // TODO: Think about the sizes + char *ssr_body = Dowa_Arena_Allocate(arena, buffer_sizes); + char *final_body = Dowa_Arena_Allocate(arena, buffer_sizes); + + snprintf(ssr_body, 100*1024, BLOG_HTML, md); + Seobeo_Render_Html(final_body, ssr_body, arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -492,7 +527,7 @@ { Seobeo_Request_Entry *resp = NULL; char *final_body = Dowa_Arena_Allocate(arena, 50 * 1024); - Seobeo_ServerSideRender(final_body, "/talk/index.html", arena); + Seobeo_Render_Html_FilePath(final_body, "/talk/index.html", arena); Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } @@ -534,11 +569,8 @@ // -- Talk --/ Seobeo_Router_Register("GET", "/talk", GetTalk); - // TODO: Bug where I can't est redriect huh... Seobeo_Router_Register("GET", "/talk/index.html", GetRedirectTalk); - printf("Registered Websockets\n"); - Seobeo_WebSocket_Server_Init(); Seobeo_WebSocket_Server_Register("/chat", Chat_Handler, NULL); diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/src/base.css --- a/mrjunejune/src/base.css Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/src/base.css Wed Jan 14 07:59:19 2026 -0800 @@ -240,10 +240,14 @@ blockquote { border-left: 4px solid var(--accent); padding: 0 0 0 20px; - margin: 0px; + margin-bottom: 1.25em; font-size: 1.333em; } +ul { + margin-bottom: 1.25em; +} + hr { border: none; border-top: 1px solid rgb(var(--gray-light)); diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/src/blog/thoughts-on-tdd/index.md --- a/mrjunejune/src/blog/thoughts-on-tdd/index.md Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/src/blog/thoughts-on-tdd/index.md Wed Jan 14 07:59:19 2026 -0800 @@ -37,7 +37,6 @@ Now, we understand detailed implementation as much as senior INSERT_LIBRARY engineer, the question is: *How do you write a unit test for this?* - There are two main reasons why this serializer is hard to test as a true "unit": **Dependency on Framework Classes** diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/blog.snapshot --- a/mrjunejune/test/snapshots/blog.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/blog.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -14,7 +14,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/resume.snapshot --- a/mrjunejune/test/snapshots/resume.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/resume.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -14,7 +14,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/root.snapshot --- a/mrjunejune/test/snapshots/root.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/root.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -15,7 +15,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/talk.snapshot --- a/mrjunejune/test/snapshots/talk.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/talk.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -16,7 +16,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/talk_index.html.snapshot --- a/mrjunejune/test/snapshots/talk_index.html.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/talk_index.html.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -1,7 +1,7 @@ -- --> - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/tools.snapshot --- a/mrjunejune/test/snapshots/tools.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/tools.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -14,7 +14,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/tools_file_converter.snapshot --- a/mrjunejune/test/snapshots/tools_file_converter.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/tools_file_converter.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -17,7 +17,7 @@ - + diff -r 2db6253f355d -r 1c0878eb17de mrjunejune/test/snapshots/tools_markdown_to_html.snapshot --- a/mrjunejune/test/snapshots/tools_markdown_to_html.snapshot Tue Jan 13 19:18:47 2026 -0800 +++ b/mrjunejune/test/snapshots/tools_markdown_to_html.snapshot Wed Jan 14 07:59:19 2026 -0800 @@ -17,7 +17,7 @@ - +