mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update code/tests with latest functionality in Ruby markdownlint.
This commit is contained in:
parent
2d8122a3be
commit
fdeeddc99d
10 changed files with 57 additions and 7 deletions
|
@ -894,6 +894,8 @@ Tags: headers, emphasis
|
|||
|
||||
Aliases: no-emphasis-as-header
|
||||
|
||||
Parameters: punctuation (string; default ".,;:!?")
|
||||
|
||||
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:
|
||||
|
||||
|
@ -916,8 +918,11 @@ sections:
|
|||
|
||||
Consectetur adipiscing elit, sed do eiusmod.
|
||||
|
||||
Note: this rule looks for paragraphs that consist entirely of emphasized text.
|
||||
It won't fire on emphasis used within regular text.
|
||||
Note: this rule looks for single line paragraphs that consist entirely of
|
||||
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
|
||||
|
||||
|
|
|
@ -781,6 +781,8 @@ module.exports = [
|
|||
"tags": [ "headers", "emphasis" ],
|
||||
"aliases": [ "no-emphasis-as-header" ],
|
||||
"func": function MD036(params, errors) {
|
||||
var punctuation = params.options.punctuation || ".,;:!?";
|
||||
var re = new RegExp("[" + punctuation + "]$");
|
||||
function base(token) {
|
||||
if (token.type === "paragraph_open") {
|
||||
return function inParagraph(t) {
|
||||
|
@ -788,7 +790,8 @@ module.exports = [
|
|||
(t.children.length === 3) &&
|
||||
((t.children[0].type === "strong_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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
## A level 2 top level header
|
||||
|
||||
## Another one {MD025}
|
||||
## Another one {MD025}
|
|
@ -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
|
||||
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.**
|
||||
|
|
|
@ -6,4 +6,7 @@ Some text
|
|||
Some text
|
||||
## 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.
|
||||
|
|
|
@ -6,4 +6,15 @@ Some text
|
|||
===================================
|
||||
|
||||
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
16
test/jekyll_post.md
Normal 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}
|
|
@ -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.
|
||||
```
|
||||
|
||||
```text
|
||||
test
|
||||
test
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
||||
```
|
||||
|
||||
This is a short line.
|
||||
|
||||
| First Header | Second Header | Third Header | Fourth Header | Fifth Header | Sixth Header |
|
||||
|
|
|
@ -857,7 +857,7 @@ module.exports.readme = function readme(test) {
|
|||
};
|
||||
|
||||
module.exports.doc = function doc(test) {
|
||||
test.expect(292);
|
||||
test.expect(293);
|
||||
fs.readFile("doc/Rules.md", shared.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue