sync: Handle title.txt in exercice dir

This commit is contained in:
nemunaire 2022-01-20 16:16:52 +01:00
parent 63d8ae4ecd
commit 40a9078b70

View File

@ -103,6 +103,16 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
return nil, p, eid, edir, errs
}
// Overwrite title if title.txt exists
if myTitle, err := getFileContent(i, path.Join(epath, "title.txt")); err == nil {
myTitle = strings.TrimSpace(myTitle)
if strings.Contains(myTitle, "\n") {
errs = append(errs, fmt.Sprintf("%q: title.txt: Title can't contain new lines", edir))
} else {
e.Title = myTitle
}
}
e.URLId = fic.ToURLid(e.Title)
e.Title = fixnbsp(e.Title)