Update code/tests with latest functionality in Ruby markdownlint.

This commit is contained in:
David Anson 2016-09-24 16:15:54 -07:00
parent 2d8122a3be
commit fdeeddc99d
10 changed files with 57 additions and 7 deletions

View file

@ -894,6 +894,8 @@ Tags: headers, emphasis
Aliases: no-emphasis-as-header Aliases: no-emphasis-as-header
Parameters: punctuation (string; default ".,;:!?")
This check looks for instances where emphasized (i.e. bold or italic) text is This check looks for instances where emphasized (i.e. bold or italic) text is
used to separate sections, where a header should be used instead: used to separate sections, where a header should be used instead:
@ -916,8 +918,11 @@ sections:
Consectetur adipiscing elit, sed do eiusmod. Consectetur adipiscing elit, sed do eiusmod.
Note: this rule looks for paragraphs that consist entirely of emphasized text. Note: this rule looks for single line paragraphs that consist entirely of
It won't fire on emphasis used within regular text. emphasized text. It won't fire on emphasis used within regular text,
multi-line emphasized paragraphs, and paragraphs ending in punctuation.
Similarly to rule MD026, you can configure what characters are recognized as
punctuation.
## MD037 - Spaces inside emphasis markers ## MD037 - Spaces inside emphasis markers

View file

@ -781,6 +781,8 @@ module.exports = [
"tags": [ "headers", "emphasis" ], "tags": [ "headers", "emphasis" ],
"aliases": [ "no-emphasis-as-header" ], "aliases": [ "no-emphasis-as-header" ],
"func": function MD036(params, errors) { "func": function MD036(params, errors) {
var punctuation = params.options.punctuation || ".,;:!?";
var re = new RegExp("[" + punctuation + "]$");
function base(token) { function base(token) {
if (token.type === "paragraph_open") { if (token.type === "paragraph_open") {
return function inParagraph(t) { return function inParagraph(t) {
@ -788,7 +790,8 @@ module.exports = [
(t.children.length === 3) && (t.children.length === 3) &&
((t.children[0].type === "strong_open") || ((t.children[0].type === "strong_open") ||
(t.children[0].type === "em_open")) && (t.children[0].type === "em_open")) &&
(t.children[1].type === "text")) { (t.children[1].type === "text") &&
!re.test(t.children[1].content)) {
errors.push(t.lineNumber); errors.push(t.lineNumber);
} }
}; };

View file

@ -1,3 +1,3 @@
## A level 2 top level header ## A level 2 top level header
## Another one {MD025} ## Another one {MD025}

View file

@ -33,3 +33,8 @@ even though the emphasized text is on its own line.
This is another **normal** paragraph with some text in it. This also should This is another **normal** paragraph with some text in it. This also should
not trigger the rule. not trigger the rule.
**This is an entire paragraph that has been emphasized, and shouldn't be
detected as a header because it's on multiple lines**
**This also shouldn't be detected as a header as it ends in punctuation.**

View file

@ -6,4 +6,7 @@ Some text
Some text Some text
## Header 4 {MD022} ## Header 4 {MD022}
## Header 5 ## Header 5
* This shouldn't trigger MD022, but did because of some bug where we tried to
#catch headers that kramdown didn't parse correctly.

View file

@ -6,4 +6,15 @@ Some text
=================================== ===================================
Setext style title only indented {MD023} Setext style title only indented {MD023}
========================================= =========================================
* Test situations in which MD023 shouldn't be triggered.
```rb
# This shouldn't trigger MD023 as it is a code comment.
foo = "And here is some code"
```
* This is another case where MD023 shouldn't be triggered
# Test {MD023} Valid header for CommonMark (see section 5.2)
# Test {MD023} Also valid header for CommonMark

16
test/jekyll_post.md Normal file
View file

@ -0,0 +1,16 @@
---
layout: post
title: Hello World!
category: Meta
tags:
- tag
- another tag
- one more tag
url: http://example.com
excerpt: Hello World! Vestibulum imperdiet adipiscing arcu, quis aliquam dolor condimentum dapibus. Aliquam fermentum leo aliquet quam volutpat et molestie mauris mattis. Suspendisse semper consequat velit in suscipit.
---
# header1
This is just a sample post.
### offending header3 {MD001}

View file

@ -9,6 +9,13 @@ Here is a short line in a code block.
Here is a very very very very very very very very very very very very very very very very very very very long line in a code block. Here is a very very very very very very very very very very very very very very very very very very very long line in a code block.
``` ```
```text
test
test
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
```
This is a short line. This is a short line.
| First Header | Second Header | Third Header | Fourth Header | Fifth Header | Sixth Header | | First Header | Second Header | Third Header | Fourth Header | Fifth Header | Sixth Header |

View file

@ -857,7 +857,7 @@ module.exports.readme = function readme(test) {
}; };
module.exports.doc = function doc(test) { module.exports.doc = function doc(test) {
test.expect(292); test.expect(293);
fs.readFile("doc/Rules.md", shared.utf8Encoding, fs.readFile("doc/Rules.md", shared.utf8Encoding,
function readFile(err, contents) { function readFile(err, contents) {
test.ifError(err); test.ifError(err);