sync: automatically add before ponctuation
This commit is contained in:
parent
0075bdeb52
commit
0d8505131e
3 changed files with 13 additions and 5 deletions
|
@ -11,6 +11,10 @@ import (
|
|||
"gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
func fixnbsp(s string) string {
|
||||
return strings.Replace(strings.Replace(strings.Replace(s, " ?", " ?", -1), " !", " !", -1), " :", " :", -1)
|
||||
}
|
||||
|
||||
// getExercices returns all exercice directories existing in a given theme, considering the given Importer.
|
||||
func getExercices(i Importer, theme fic.Theme) ([]string, error) {
|
||||
var exercices []string
|
||||
|
@ -90,12 +94,14 @@ func SyncExercice(i Importer, theme fic.Theme, epath string, dmap *map[int64]fic
|
|||
}
|
||||
|
||||
e.URLId = fic.ToURLid(e.Title)
|
||||
e.Title = fixnbsp(e.Title)
|
||||
|
||||
// Texts to format using Markdown
|
||||
e.Overview, err = getFileContent(i, path.Join(epath, "overview.txt"))
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: overview.txt: %s", edir, err))
|
||||
} else {
|
||||
e.Overview = fixnbsp(e.Overview)
|
||||
e.Headline = string(blackfriday.Run([]byte(strings.Split(e.Overview, "\n")[0])))
|
||||
if e.Overview, err = ProcessMarkdown(i, e.Overview, epath); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: overview.txt: an error occurs during markdown formating: %s", edir, err))
|
||||
|
@ -106,7 +112,7 @@ func SyncExercice(i Importer, theme fic.Theme, epath string, dmap *map[int64]fic
|
|||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: statement.txt: %s", edir, err))
|
||||
} else {
|
||||
if e.Statement, err = ProcessMarkdown(i, e.Statement, epath); err != nil {
|
||||
if e.Statement, err = ProcessMarkdown(i, fixnbsp(e.Statement), epath); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: statement.txt: an error occurs during markdown formating: %s", edir, err))
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue