Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/lint/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ func (l *Linter) lintHTMLTokens(f *core.File, raw []byte, offset int) error { //
open = append(open, inlineCapture{tag: txt, scope: scope, masked: skip, begin: buf.Len()})
}
walker.addTag(txt, class, getAttribute(tok, markAttr))
// A void element has no end tag, so it leaves the history at once.
// Left there, a hard line break, `<br>`, reads as an open inline
// element. A nested list after it then joins the list item above,
// and an enclosing `</em>` cannot pop its own tag (#1225).
if core.StringInSlice(txt, voidTags) {
walker.popTag(txt)
}
} else if tokt == html.EndTagToken && isInline {
walker.popTag(txt)
walker.activeTag = ""
Expand Down
42 changes: 42 additions & 0 deletions testdata/e2e/scopes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,48 @@ cases:
test.md:1:22:T.Text:text: after
test.md:3:27:T.Text:text: after

- name: list-item-with-hard-break
about: "#1225 -- a hard line break, `<br>`, has no end tag. It stayed in the
tag history and joined the nested list to the item above, also inside
emphasis"
files:
.vale.ini: |
StylesPath = styles
MinAlertLevel = suggestion

[*.md]
BasedOnStyles = T
styles/T/Item.yml: |
extends: metric
message: "item: %s words"
level: error
scope: list
formula: words
condition: "> 3"
break.md: |
- Lead line.\
Second line.
- One two three four five six seven.
- One two three four five six seven.
- One two three four five six seven.
emphasis.md: |
- *Lead line.\
second* line.
- One two three four five six seven.
- One two three four five six seven.
- One two three four five six seven.
args: break.md emphasis.md
exit: 1
want: |
break.md:2:1:T.Item:item: 4.00 words
break.md:3:1:T.Item:item: 7.00 words
break.md:4:1:T.Item:item: 7.00 words
break.md:5:1:T.Item:item: 7.00 words
emphasis.md:2:1:T.Item:item: 4.00 words
emphasis.md:3:1:T.Item:item: 7.00 words
emphasis.md:4:1:T.Item:item: 7.00 words
emphasis.md:5:1:T.Item:item: 7.00 words

- name: table
args: .
requires: asciidoctor, rst2html
Expand Down
Loading