aboutsummaryrefslogtreecommitdiff
path: root/internal/ini/ini.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 12:58:31 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 12:58:31 +0200
commit27911b8f2574563ddd5d0de75f708503067069c9 (patch)
tree22c79052b00852f9f42d4f8f745e7cb8b073b176 /internal/ini/ini.go
parent809a47a227540ad8b8b2ac28a1bbbc2f115b7406 (diff)
downloadlectio-27911b8f2574563ddd5d0de75f708503067069c9.tar.gz
lectio-27911b8f2574563ddd5d0de75f708503067069c9.zip
fix(ini,calendar): full-line-only comments (preserve ';' in citations); drop superseded ferial from Others
Diffstat (limited to 'internal/ini/ini.go')
-rw-r--r--internal/ini/ini.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/internal/ini/ini.go b/internal/ini/ini.go
index b4fc955..36277e0 100644
--- a/internal/ini/ini.go
+++ b/internal/ini/ini.go
@@ -1,7 +1,10 @@
// Package ini is a tiny dependency-free reader for the boring INI files lectio
// uses for config and calendar data: [sections] (including "a/b" subsections),
-// "key = value" pairs (keys may be dotted, e.g. name.pl), and "#"/";" comments.
-// It preserves order and never interprets values beyond trimming.
+// "key = value" pairs (keys may be dotted, e.g. name.pl), and full-line
+// "#"/";" comments. Comments are FULL-LINE only (a line whose first non-blank
+// character is # or ;); values are kept verbatim so scripture citations may
+// contain ";" and "#". It preserves order and never interprets values beyond
+// trimming surrounding whitespace.
package ini
import (
@@ -27,10 +30,9 @@ func Parse(data []byte) ([]Section, error) {
line := 0
for sc.Scan() {
line++
- raw := stripComment(sc.Text())
- s := strings.TrimSpace(raw)
- if s == "" {
- continue
+ s := strings.TrimSpace(sc.Text())
+ if s == "" || strings.HasPrefix(s, "#") || strings.HasPrefix(s, ";") {
+ continue // blank or full-line comment
}
if strings.HasPrefix(s, "[") {
if !strings.HasSuffix(s, "]") {
@@ -45,24 +47,13 @@ func Parse(data []byte) ([]Section, error) {
return nil, fmt.Errorf("ini: line %d: expected key = value, got %q", line, s)
}
key := strings.TrimSpace(s[:eq])
- val := strings.TrimSpace(s[eq+1:])
+ val := strings.TrimSpace(s[eq+1:]) // verbatim (may contain ';' or '#')
cur := &secs[len(secs)-1]
cur.Pairs = append(cur.Pairs, Pair{key, val})
}
return secs, sc.Err()
}
-// stripComment removes a trailing "#" or ";" comment (our values never contain
-// an unescaped # or ;).
-func stripComment(line string) string {
- for i := 0; i < len(line); i++ {
- if line[i] == '#' || line[i] == ';' {
- return line[:i]
- }
- }
- return line
-}
-
// List splits a comma-separated value, trimming spaces and dropping empties.
func List(val string) []string {
var out []string