diff --git a/src/parser.v b/src/parser.v index d6aaec9..65fd56f 100644 --- a/src/parser.v +++ b/src/parser.v @@ -8,10 +8,10 @@ fn parse_header(line string) (int, string) { } mut lvl := 0 - for line[lvl] == '!'[0] { // Jestem geniuszem programowania + for lvl < line.len && line[lvl] == '!'.bytes()[0] { lvl++ } - if line[lvl + 1] != ' '[0] { // String to u8 converter xd + if lvl == 0 || lvl >= line.len || line[lvl] != ' '.bytes()[0] { return 0, line } return lvl, line[lvl + 1..] @@ -20,21 +20,35 @@ fn parse_header(line string) (int, string) { fn parse(lines []string) string { mut output := '
'
for line in lines {
- lvl, text := parse_header(line)
+ mut trimmed := line.trim_space()
+
+ if trimmed.len == 0 {
+ output += '
\n'
+ continue
+ }
+
+ lvl, mut text := parse_header(trimmed)
+
if lvl > 0 {
output += '
\n'
+ text = replace(text, idx, 1, 'foferk')
}
if lvl > 0 {
- output += '
\n'
+ if lvl == 0 {
+ output += '
'
+ }
+ output += '\n'
}
+
output += '