(c *core.Config, exts extensionConfig, content string)
| 89 | } |
| 90 | |
| 91 | func applyInlinePatterns(c *core.Config, exts extensionConfig, content string) (string, error) { |
| 92 | inline, ok := inlineDelimiters[exts.Normed] |
| 93 | if !ok { |
| 94 | return content, fmt.Errorf("ignore patterns are not supported in '%s' files", exts.Normed) |
| 95 | } |
| 96 | |
| 97 | for syntax, regexes := range c.TokenIgnores { |
| 98 | sec, err := glob.Compile(syntax) |
| 99 | if err != nil { |
| 100 | return content, err |
| 101 | } else if sec.Match(exts.Normed) || sec.Match(exts.Real) { |
| 102 | for _, r := range regexes { |
| 103 | pat, errc := regexp2.CompileStd(r) |
| 104 | if errc != nil { |
| 105 | return content, core.NewE201FromTarget( |
| 106 | errc.Error(), |
| 107 | r, |
| 108 | c.Flags.Path, |
| 109 | ) |
| 110 | } |
| 111 | content, err = pat.Replace(content, inline, 0, -1) |
| 112 | if err != nil { |
| 113 | return content, core.NewE201FromTarget( |
| 114 | err.Error(), |
| 115 | r, |
| 116 | c.Flags.Path, |
| 117 | ) |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | return content, nil |
| 123 | } |
| 124 | |
| 125 | // applyCommentPatterns replaces any custom comment delimiters with HTML comment |
| 126 | // tags based on the user configuration. This makes it possible to apply |
no test coverage detected
searching dependent graphs…