refactor(parser): translate comments from Italian to English

This commit is contained in:
2025-11-24 23:40:31 +01:00
parent 76f33f281c
commit 20e327d9dd

View File

@@ -65,7 +65,7 @@ var (
completedHead = regexp.MustCompile(`^x\s+`)
spaceRe = regexp.MustCompile(`\s+`)
dateLayout = "2006-01-02"
// Protocols da escludere come chiave dei metadati
// Protocols to exclude as metadata keys
protocols = map[string]struct{}{
"http": {},
"https": {},
@@ -74,7 +74,7 @@ var (
}
)
// isProtocolKey controlla se la chiave è un protocollo standard.
// isProtocolKey checks if the key is a standard protocol.
func isProtocolKey(k string) bool {
_, found := protocols[strings.ToLower(k)]
return found
@@ -165,13 +165,12 @@ func ParseLine(line string) (Task, error) {
t.Contexts = append(t.Contexts, tok[1:])
continue
}
// Nuova logica per metadati: nessuno spazio, almeno un ':', chiave non protocollo
if !strings.ContainsAny(tok, " \t") && strings.Contains(tok, ":") {
parts := strings.SplitN(tok, ":", 2)
k, v := parts[0], parts[1]
if k != "" && v != "" && !isProtocolKey(k) {
t.Metadata[k] = v
// Se il campo è due:YYYY-MM-DD, parsalo anche come DueDate
// If the field is due:YYYY-MM-DD, also parse it as DueDate
if k == "due" && dateRe.MatchString(v) {
if dt, err := time.Parse(dateLayout, v); err == nil {
t.DueDate = &dt