Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent, but blockquoted, list items are valid #284

Merged
merged 3 commits into from
Nov 22, 2019
Merged
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
2 changes: 1 addition & 1 deletion lib/mdl/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def list_style(item)
if item.type != :li
raise "list_style called with non-list element"
end
line = element_line(item).strip
line = element_line(item).strip.gsub(/^>\s+/,'')
if line.start_with?('*')
:asterisk
elsif line.start_with?('+')
Expand Down
2 changes: 1 addition & 1 deletion lib/mdl/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def check_blockquote(errors, elements)
# the items in it have multiple paragraphs/other block items.
srule = items.map { |i| i.children.length }.max > 1 ? "multi" : "single"
items.each do |i|
actual_spaces = doc.element_line(i).match(/^\s*\S+(\s+)/)[1].length
actual_spaces = doc.element_line(i).gsub(/^> /,'').match(/^\s*\S+(\s+)/)[1].length
required_spaces = params["#{list_type}_#{srule}".to_sym]
errors << doc.element_linenumber(i) if required_spaces != actual_spaces
end
Expand Down
4 changes: 4 additions & 0 deletions test/rule_tests/blockquote_spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Some text

This tests other things embedded in the blockquote:

- foo

> *Hello world*
> *foo* {MD027}
> **bar** {MD027}
Expand All @@ -15,6 +17,8 @@ This tests other things embedded in the blockquote:
> **bar** more text
> 'baz' more text
> `qux` more text
>
> - foo

Test the first line being indented too much:

Expand Down
8 changes: 7 additions & 1 deletion test/rule_tests/inconsistent_bullet_styles_asterisk.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* Item
+ Item {MD004}
- Item {MD004}
- Item {MD004}
* Item

> * Item
> + Item {MD004}
> - Item {MD004}
> * Item
8 changes: 7 additions & 1 deletion test/rule_tests/inconsistent_bullet_styles_dash.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- Item
* Item {MD004}
+ Item {MD004}
+ Item {MD004}
- Item

> - Item
> * Item {MD004}
> + Item {MD004}
> - Item
8 changes: 7 additions & 1 deletion test/rule_tests/inconsistent_bullet_styles_plus.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
+ Item
* Item {MD004}
- Item {MD004}
- Item {MD004}
+ Item

> + Item
> * Item {MD004}
> - Item {MD004}
> + Item