sync: Exercice headline can be in a dedicated file
This commit is contained in:
parent
7cc076b31e
commit
ec3f818c30
2 changed files with 49 additions and 10 deletions
|
|
@ -140,8 +140,25 @@ func BuildTheme(i Importer, tdir string) (th *fic.Theme, exceptions *CheckExcept
|
|||
th.Authors = strings.Join(authors, ", ")
|
||||
}
|
||||
|
||||
var intro string
|
||||
var err error
|
||||
if i.Exists(path.Join(tdir, "headline.txt")) {
|
||||
th.Headline, err = GetFileContent(i, path.Join(tdir, "headline.txt"))
|
||||
} else if i.Exists(path.Join(tdir, "headline.md")) {
|
||||
th.Headline, err = GetFileContent(i, path.Join(tdir, "headline.md"))
|
||||
}
|
||||
if err != nil {
|
||||
errs = append(errs, NewThemeError(th, fmt.Errorf("unable to get theme's headline: %w", err)))
|
||||
}
|
||||
if th.Headline != "" {
|
||||
// Call checks hooks
|
||||
for _, h := range hooks.mdTextHooks {
|
||||
for _, err := range h("headline.md", th.Language, exceptions.GetFileExceptions("headline.md", "headline.txt")) {
|
||||
errs = append(errs, NewThemeError(th, fmt.Errorf("headline.md: %w", err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var intro string
|
||||
if i.Exists(path.Join(tdir, "overview.txt")) {
|
||||
intro, err = GetFileContent(i, path.Join(tdir, "overview.txt"))
|
||||
} else if i.Exists(path.Join(tdir, "overview.md")) {
|
||||
|
|
@ -160,10 +177,12 @@ func BuildTheme(i Importer, tdir string) (th *fic.Theme, exceptions *CheckExcept
|
|||
}
|
||||
|
||||
// Split headline from intro
|
||||
ovrvw := strings.Split(fixnbsp(intro), "\n")
|
||||
th.Headline = ovrvw[0]
|
||||
if len(ovrvw) > 1 {
|
||||
intro = strings.Join(ovrvw[1:], "\n")
|
||||
if th.Headline == "" {
|
||||
ovrvw := strings.Split(fixnbsp(intro), "\n")
|
||||
th.Headline = ovrvw[0]
|
||||
if len(ovrvw) > 1 {
|
||||
intro = strings.Join(ovrvw[1:], "\n")
|
||||
}
|
||||
}
|
||||
|
||||
// Format overview (markdown)
|
||||
|
|
|
|||
Reference in a new issue