sync: Handle finished.md as alternative to finished.txt

This commit is contained in:
nemunaire 2022-12-09 16:07:06 +01:00
parent 2df227c25b
commit 4b09efa9fd

View File

@ -184,19 +184,21 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
if i.exists(path.Join(epath, "finished.txt")) {
e.Finished, err = GetFileContent(i, path.Join(epath, "finished.txt"))
if err != nil {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.txt: %w", err), theme))
} else {
// Call checks hooks
for _, h := range hooks.mdTextHooks {
for _, err := range h(e.Finished, exceptions.GetFileExceptions("finished.md", "finished.txt")) {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.md: %w", err)))
}
} else if i.exists(path.Join(epath, "finished.md")) {
e.Finished, err = GetFileContent(i, path.Join(epath, "finished.md"))
}
if err != nil {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.md: %w", err), theme))
} else if len(e.Finished) > 0 {
// Call checks hooks
for _, h := range hooks.mdTextHooks {
for _, err := range h(e.Finished, exceptions.GetFileExceptions("finished.md", "finished.txt")) {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.md: %w", err)))
}
}
if e.Finished, err = ProcessMarkdown(i, e.Finished, epath); err != nil {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.txt: an error occurs during markdown formating: %w", err), theme))
}
if e.Finished, err = ProcessMarkdown(i, e.Finished, epath); err != nil {
errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.md: an error occurs during markdown formating: %w", err), theme))
}
}