mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
feat: Added commonmark parser.
This commit is contained in:
+5
-1
@@ -1,5 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import cm "vendor:commonmark"
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
@@ -19,6 +21,7 @@ Page :: struct {
|
|||||||
is_starred: bool,
|
is_starred: bool,
|
||||||
menu: string,
|
menu: string,
|
||||||
body: string,
|
body: string,
|
||||||
|
body_html: string,
|
||||||
bundle_dir: string,
|
bundle_dir: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +138,8 @@ load_page :: proc(
|
|||||||
page.draft = fm.draft
|
page.draft = fm.draft
|
||||||
page.is_starred = fm.isStarred
|
page.is_starred = fm.isStarred
|
||||||
page.menu = fm.menu
|
page.menu = fm.menu
|
||||||
page.body = strings.clone(body)
|
page.body = strings.clone(body)
|
||||||
|
page.body_html = cm.markdown_to_html_from_string(body, {.Unsafe})
|
||||||
|
|
||||||
switch page_type {
|
switch page_type {
|
||||||
case .Post:
|
case .Post:
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.git
|
pkgs.git
|
||||||
|
pkgs.cmark
|
||||||
];
|
];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
@@ -109,6 +110,7 @@
|
|||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
odin
|
odin
|
||||||
ols
|
ols
|
||||||
|
cmark
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
unstable.helix
|
unstable.helix
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import "core:fmt"
|
|||||||
import "core:os"
|
import "core:os"
|
||||||
|
|
||||||
Options :: struct {
|
Options :: struct {
|
||||||
base_url: string `args:"name=base-url"`,
|
base_url: string `args:"name=base-url" usage:"hostname (and path) to the root, e.g. https://example.com/"`,
|
||||||
content_dir: string `args:"name=content"`,
|
content_dir: string `args:"name=content" usage:"where to look for content files"`,
|
||||||
output_dir: string `args:"name=output"`,
|
output_dir: string `args:"name=output" usage:"where to export the completed site"`,
|
||||||
drafts: bool `args:"name=drafts"`,
|
drafts: bool `args:"name=drafts" usage:"Whether to render draft posts"`,
|
||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
@@ -55,12 +55,13 @@ print_summary :: proc(pages: []Page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.printfln(
|
fmt.printfln(
|
||||||
" [%-11s] %-30s %s %s%s",
|
" [%-11s] %-30s %s %s%s (%d bytes html)",
|
||||||
type_label,
|
type_label,
|
||||||
page.title,
|
page.title,
|
||||||
date_short,
|
date_short,
|
||||||
page.permalink,
|
page.permalink,
|
||||||
badge,
|
badge,
|
||||||
|
len(page.body_html),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user