repochecker/grammalecte: Overload grammar paragraph in some situations

This commit is contained in:
nemunaire 2022-11-06 22:21:55 +01:00
parent cd07bec05b
commit 7c2e97740f
2 changed files with 9 additions and 9 deletions

View file

@ -119,7 +119,7 @@ var (
mdimg = regexp.MustCompile(`!\[([^\]]+)\]\([^)]+\)`)
)
func grammalecte(name string, text string, exceptions *sync.CheckExceptions, options *GrammalecteOptions) (errs []error) {
func grammalecte(name string, text string, paragraph int, exceptions *sync.CheckExceptions, options *GrammalecteOptions) (errs []error) {
// Remove Markdown elements
text = mdimg.ReplaceAllString(text, "Image : ${1}")
@ -187,11 +187,11 @@ func grammalecte(name string, text string, exceptions *sync.CheckExceptions, opt
continue
}
if gerror.RuleId == "mc_mot_composé" && gerror.End+1 < len(data.Text) && gerror.Start+1 < len(data.Text) && exceptions.HasException(fmt.Sprintf(":spelling:%s", data.Text[gerror.Start+1:gerror.End+1])) {
if gerror.RuleId == "mc_mot_composé" && ((gerror.End+1 < len(data.Text) && gerror.Start+1 < len(data.Text) && exceptions.HasException(fmt.Sprintf(":spelling:%s", data.Text[gerror.Start+1:gerror.End+1]))) || exceptions.HasException(fmt.Sprintf(":spelling:%s", data.Text[gerror.Start:gerror.End]))) {
continue
}
if exceptions.HasException(fmt.Sprintf(":%d:%s", data.Paragraph, gerror.RuleId)) {
if (paragraph == 0 && exceptions.HasException(fmt.Sprintf(":%d:%s", data.Paragraph, gerror.RuleId))) || (paragraph < 0 && exceptions.HasException(fmt.Sprintf(":%s", gerror.RuleId))) || (paragraph > 0 && exceptions.HasException(fmt.Sprintf(":%d:%s", paragraph, gerror.RuleId))) {
continue
}