Added: convert md paths to html paths

This commit is contained in:
zztkm 2022-08-03 22:34:35 +09:00
parent b1405723cc
commit dff40184d7

20
vss.v
View file

@ -3,6 +3,7 @@ module main
import os
import cli
import toml
import regex
import markdown
import template
@ -57,12 +58,21 @@ fn get_html_filename(md_path string) string {
// pre_proc_md_to_html convert markdown relative links to html relative links
fn pre_proc_md_to_html(contents string) string {
lines := contents.split_into_lines()
mut parsed_lines := []string{len: lines.len}
for i, iine in contents.split_into_lines() {
println(line)
parsed_lines[i] = line
mut parsed_lines := []string{len: lines.len}
for i, line in contents.split_into_lines() {
mut re := regex.regex_opt(r'\[.+\]\(.+\.md\)') or {
eprintln('error: $err')
continue
}
start, end := re.find(line)
if start >= 0 && end > start {
parsed_lines[i] = line.replace('.md', '.html')
} else {
parsed_lines[i] = line
}
}
return parsed_lines.join("\n")
return parsed_lines.join('\n')
}
fn generate_pages() ? {