changes
This commit is contained in:
+7
-10
@@ -9,11 +9,10 @@ import cm "vendor:commonmark"
|
||||
MD_SUFFIX :: ".md"
|
||||
|
||||
UTF8_PREFIX :: "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
|
||||
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n"
|
||||
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n<title>Simon Kellet</title>"
|
||||
FAVICON_PREFIX :: "<link rel=\"icon\" type=\"image\\x-icon\" href=\"/imgs/favicon.ico\">\n"
|
||||
MASTODON_PREFIX :: "<a rel=me href=https://linuxrocks.online/@simonkellet></a>\n"
|
||||
|
||||
|
||||
write_prefixs_to_html_file :: proc(file: ^os.File) {
|
||||
os.write_string(file, UTF8_PREFIX)
|
||||
os.write_string(file, CSS_PREFIX)
|
||||
@@ -28,25 +27,23 @@ walk_tree_and_get_md_names :: proc(path: string, allocator := context.allocator)
|
||||
defer os.walker_destroy(&w)
|
||||
|
||||
for info in os.walker_walk(&w) {
|
||||
//handle errors
|
||||
if path, err := os.walker_error(&w); err != nil {
|
||||
fmt.eprintfln("failed walking %s: %s", path, err)
|
||||
continue
|
||||
}
|
||||
|
||||
//Skip a dir
|
||||
// Skip the Git dir
|
||||
if strings.has_suffix(info.fullpath, ".git") {
|
||||
os.walker_skip_dir(&w)
|
||||
continue
|
||||
}
|
||||
|
||||
if !strings.has_suffix(info.name, MD_SUFFIX) {
|
||||
continue //skip
|
||||
}
|
||||
// Skip files that are NOT .md files
|
||||
if !strings.has_suffix(info.name, MD_SUFFIX) { continue }
|
||||
|
||||
append(&files, strings.clone(info.fullpath, allocator))
|
||||
|
||||
}
|
||||
|
||||
// Handle error if one happened during iteration at the end:
|
||||
if path, err := os.walker_error(&w); err != nil {
|
||||
fmt.eprintfln("failed walking %s: %v", path, err)
|
||||
@@ -67,7 +64,6 @@ walk_tree :: proc(path: string) -> []u8 {
|
||||
fmt.eprintfln("failed walking %s: %s", path, err)
|
||||
continue
|
||||
}
|
||||
//lets play around
|
||||
filename = info.name
|
||||
if !strings.has_suffix(info.name, MD_SUFFIX) {
|
||||
continue
|
||||
@@ -80,7 +76,8 @@ walk_tree :: proc(path: string) -> []u8 {
|
||||
|
||||
parse_file_md_to_html :: proc(filename: string, allocator := context.allocator) -> (parsed: string, err: os.Error) {
|
||||
str := os.read_entire_file_from_path(filename, allocator) or_return
|
||||
root := cm.parse_document(raw_data(str), len(str), cm.DEFAULT_OPTIONS)
|
||||
root := cm.parse_document_from_string(string(str), cm.DEFAULT_OPTIONS)
|
||||
//root := cm.parse_document(raw_data(str), len(str), cm.DEFAULT_OPTIONS)
|
||||
defer cm.node_free(root)
|
||||
|
||||
html := cm.render_html(root, cm.DEFAULT_OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user