Skip to content

Commit 2a9f92b

Browse files
cyksivakumar-kailasam
authored andcommitted
Failing test for bad line breaks in markdown
1 parent 2d97641 commit 2a9f92b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/helpers/getBadLineBreaks.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs');
2+
3+
module.exports = function findBadLineBreaks(filepath) {
4+
const markdown = fs.readFileSync(filepath).toString();
5+
6+
return [
7+
// urls that have a newline between the ] and (
8+
/\]\n\(/.test(markdown),
9+
10+
// to be safe, also search where \s is a whitespace
11+
/\]\n\s\(/.test(markdown),
12+
/\]\s\n\s\(/.test(markdown),
13+
].filter(Boolean);
14+
};

test/link-checker.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
const { expect } = require('chai');
22

3-
const { getBadRelativeUrlsForFile, findMarkdownLinks, getBadImageUrls } = require('./helpers');
3+
const {
4+
findMarkdownLinks,
5+
getBadRelativeUrlsForFile,
6+
getBadLineBreaks,
7+
getBadImageUrls,
8+
} = require('./helpers');
49

510
/**
611
* Autogenerate some mocha tests
@@ -29,6 +34,9 @@ describe('check all links in markdown files', function () {
2934

3035
expect(badLinks, printBadLinks(badLinks)).to.be.empty;
3136

37+
const badLineBreaks = getBadLineBreaks(filepath);
38+
expect(badLineBreaks, printBadLinks(badLineBreaks)).to.be.empty;
39+
3240
const badImageLinks = getBadImageUrls({
3341
filepath,
3442
links,

0 commit comments

Comments
 (0)