Add support for [[wiki-style]] links in markdown (#9275)

* Add support for [[wiki-style]] links in markdown

1.  Support for [[wiki-style]] links ensures that they do not get broken
    by the prettier formatting by being wrapped over multiple lines.
2.  The contents of the link (between the `[[]]` brackets) are treated
    as raw text. This is because the various tools that rely on the
    `[[]]` syntax do not agree on what is allowable between them.

* Add a changelog document

* Update pr-9275.md

* Add additional tests as requested

* Add a fix for AST tests

* Fix issues with prose-wrap: "preserve"

* Lint

* Add a clean action for wikiLinks

Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
Ara Adkinsandfisker Cheung authored and GitHub committed 2020-10-08 21:51:01 +08:00
1 parent bba196abc8
commit 42c1ff3fcf
18 files changed
+862 -1

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#### Add support for [[wiki-style]] links in markdown (#9275 by @iamrecursion)
1. Support for `[[wiki-style]]` links ensures that they do not get broken by
the prettier formatting by being wrapped over multiple lines.
2. The contents of the link (between the `[[]]` brackets) are treated as raw
text. This is because the various tools that rely on the `[[]]` syntax do not
agree on what is allowable between them.
<!-- prettier-ignore -->
```markdown
<!-- Input -->
If I have a prose that forces a wiki link to end up crossing the [[line width limit]] like this. It's wrapped into an invalid state.
<!-- Prettier stable -->
If I have a prose that forces a wiki link to end up crossing the [[line width
limit]] like this. It's wrapped into an invalid state.
<!-- Prettier master -->
If I have a prose that forces a wiki link to end up crossing the
[[line width limit]] like this. It's wrapped into an invalid state.
```
+27
View File
@@ -36,6 +36,7 @@ function createParse({ isMDX }) {
.use(isMDX ? mdx.esSyntax : identity)
.use(liquid)
.use(isMDX ? htmlToJsx : identity)
.use(wikiLink)
.use(looseItems);
return processor.runSync(processor.parse(text));
};
@@ -96,6 +97,32 @@ function liquid() {
};
}
function wikiLink() {
const entityType = "wikiLink";
const wikiLinkRegex = /^\[\[(?<linkContents>.+?)]]/s;
const proto = this.Parser.prototype;
const methods = proto.inlineMethods;
methods.splice(methods.indexOf("link"), 0, entityType);
proto.inlineTokenizers.wikiLink = tokenizer;
function tokenizer(eat, value) {
const match = wikiLinkRegex.exec(value);
if (match) {
const linkContents = match.groups.linkContents.trim();
return eat(match[0])({
type: entityType,
value: linkContents,
});
}
}
tokenizer.locator = function (value, fromIndex) {
return value.indexOf("[", fromIndex);
};
}
function looseItems() {
const proto = this.Parser.prototype;
const originalList = proto.blockTokenizers.list;
+15 -1
View File
@@ -40,7 +40,7 @@ const {
} = require("./utils");
const TRAILING_HARDLINE_NODES = new Set(["importExport"]);
const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link", "wikiLink"];
const SIBLING_NODE_TYPES = new Set([
"listItem",
"definition",
@@ -179,6 +179,16 @@ function genericPrint(path, options, print) {
const gap = backtickCount && !/^\s/.test(node.value) ? " " : "";
return concat([style, gap, node.value, gap, style]);
}
case "wikiLink": {
let contents = "";
if (options.proseWrap === "preserve") {
contents = node.value;
} else {
contents = node.value.replace(/[\t\n]+/g, " ");
}
return concat(["[[", contents, "]]"]);
}
case "link":
switch (options.originalText[node.position.start.offset]) {
case "<": {
@@ -962,6 +972,10 @@ function clean(ast, newObj, parent) {
newObj.value = ast.value.replace(/[\t\n ]+/g, " ");
}
if (ast.type === "wikiLink") {
newObj.value = ast.value.trim().replace(/[\t\n]+/g, " ");
}
if (ast.type === "definition" || ast.type === "linkReference") {
newObj.label = ast.label
.trim()
+1
View File
@@ -13,6 +13,7 @@ const INLINE_NODE_TYPES = [
"emphasis",
"strong",
"delete",
"wikiLink",
"link",
"linkReference",
"image",
@@ -0,0 +1,776 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`additional-spacing.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
[[Additional spacing within the link should be preserved]]
=====================================output=====================================
[[Additional spacing within the link should be preserved]]
================================================================================
`;
exports[`additional-spacing.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
[[Additional spacing within the link should be preserved]]
=====================================output=====================================
[[Additional spacing within the link should be preserved]]
================================================================================
`;
exports[`additional-spacing.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
[[Additional spacing within the link should be preserved]]
=====================================output=====================================
[[Additional spacing within the link should be preserved]]
================================================================================
`;
exports[`additional-spacing.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
[[Additional spacing within the link should be preserved]]
=====================================output=====================================
[[Additional spacing within the link should be preserved]]
================================================================================
`;
exports[`end-of-line.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
=====================================output=====================================
If I have some markdown text, it should be wrapped properly at the character
limit for markdown. However, if I have a link that overflows the end of line it
should be [[wrapped as a single entity]] like this.
================================================================================
`;
exports[`end-of-line.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
=====================================output=====================================
If I have some markdown text, it should be wrapped properly at the character
limit for markdown. However, if I have a link that overflows the end of line it
should be [[wrapped as a single entity]] like this.
================================================================================
`;
exports[`end-of-line.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
=====================================output=====================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown. However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
================================================================================
`;
exports[`end-of-line.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
=====================================output=====================================
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
================================================================================
`;
exports[`exceeds-line-length.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
=====================================output=====================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
================================================================================
`;
exports[`exceeds-line-length.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
=====================================output=====================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
================================================================================
`;
exports[`exceeds-line-length.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
=====================================output=====================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
================================================================================
`;
exports[`exceeds-line-length.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
=====================================output=====================================
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
================================================================================
`;
exports[`exceeds-line-length-in-prose.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that
[[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that
[[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose-broken.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that
[[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose-broken.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that
[[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose-broken.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`exceeds-line-length-in-prose-broken.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
=====================================output=====================================
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
================================================================================
`;
exports[`extra-brackets.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over the
[[[end like this]]].
================================================================================
`;
exports[`extra-brackets.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over the
[[[end like this]]].
================================================================================
`;
exports[`extra-brackets.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
================================================================================
`;
exports[`extra-brackets.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
================================================================================
`;
exports[`extra-brackets-leading.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over
[[[the end like this]].
================================================================================
`;
exports[`extra-brackets-leading.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over
[[[the end like this]].
================================================================================
`;
exports[`extra-brackets-leading.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
================================================================================
`;
exports[`extra-brackets-leading.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
================================================================================
`;
exports[`extra-brackets-trailing.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over
[[the end like this]]].
================================================================================
`;
exports[`extra-brackets-trailing.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over
[[the end like this]]].
================================================================================
`;
exports[`extra-brackets-trailing.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
================================================================================
`;
exports[`extra-brackets-trailing.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
=====================================output=====================================
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
================================================================================
`;
exports[`multi-line.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
[[a
b]]
=====================================output=====================================
[[a b]]
================================================================================
`;
exports[`multi-line.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
[[a
b]]
=====================================output=====================================
[[a b]]
================================================================================
`;
exports[`multi-line.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
[[a
b]]
=====================================output=====================================
[[a b]]
================================================================================
`;
exports[`multi-line.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
[[a
b]]
=====================================output=====================================
[[a
b]]
================================================================================
`;
exports[`nested-link.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
=====================================output=====================================
Here's some text to ensure that the link and wiki link break the line
[[a[b](http://www.example.com/)]]
================================================================================
`;
exports[`nested-link.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
=====================================output=====================================
Here's some text to ensure that the link and wiki link break the line
[[a[b](http://www.example.com/)]]
================================================================================
`;
exports[`nested-link.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
=====================================output=====================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
================================================================================
`;
exports[`nested-link.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
=====================================output=====================================
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
================================================================================
`;
exports[`simple.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
[[A simple wiki link on a single line]]
=====================================output=====================================
[[A simple wiki link on a single line]]
================================================================================
`;
exports[`simple.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
[[A simple wiki link on a single line]]
=====================================output=====================================
[[A simple wiki link on a single line]]
================================================================================
`;
exports[`simple.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
[[A simple wiki link on a single line]]
=====================================output=====================================
[[A simple wiki link on a single line]]
================================================================================
`;
exports[`simple.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
[[A simple wiki link on a single line]]
=====================================output=====================================
[[A simple wiki link on a single line]]
================================================================================
`;
exports[`with-whitespace.md - {"proseWrap":"always","singleQuote":true} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
singleQuote: true
| printWidth
=====================================input======================================
[[ Here is a link with leading and trailing whitespace. ]]
=====================================output=====================================
[[Here is a link with leading and trailing whitespace.]]
================================================================================
`;
exports[`with-whitespace.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
[[ Here is a link with leading and trailing whitespace. ]]
=====================================output=====================================
[[Here is a link with leading and trailing whitespace.]]
================================================================================
`;
exports[`with-whitespace.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
[[ Here is a link with leading and trailing whitespace. ]]
=====================================output=====================================
[[Here is a link with leading and trailing whitespace.]]
================================================================================
`;
exports[`with-whitespace.md - {"proseWrap":"preserve"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "preserve"
| printWidth
=====================================input======================================
[[ Here is a link with leading and trailing whitespace. ]]
=====================================output=====================================
[[Here is a link with leading and trailing whitespace.]]
================================================================================
`;
@@ -0,0 +1 @@
[[Additional spacing within the link should be preserved]]
+2
View File
@@ -0,0 +1,2 @@
If I have some markdown text, it should be wrapped properly at the character limit for markdown.
However, if I have a link that overflows the end of line it should be [[wrapped as a single entity]] like this.
@@ -0,0 +1,2 @@
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I
continue it into an obscenely long wiki-style link thingy]].
@@ -0,0 +1 @@
I have some markdown prose here, with a horrible run-on sentence that [[makes little sense at all as I continue it into an obscenely long wiki-style link thingy]].
@@ -0,0 +1 @@
[[Here is an incredibly long wiki-style link that overflows the standard wrap width for markdown]].
@@ -0,0 +1,2 @@
A very long line of markdown with additional brackets as it wraps over [[[the end like this]].
@@ -0,0 +1,2 @@
A very long line of markdown with additional brackets as it wraps over [[the end like this]]].
@@ -0,0 +1,2 @@
A very long line of markdown with additional brackets as it wraps over the [[[end like this]]].
+4
View File
@@ -0,0 +1,4 @@
run_spec(__dirname, ["markdown"], { proseWrap: "always" });
run_spec(__dirname, ["markdown"], { proseWrap: "always", singleQuote: true });
run_spec(__dirname, ["markdown"], { proseWrap: "never" });
run_spec(__dirname, ["markdown"], { proseWrap: "preserve" });
+2
View File
@@ -0,0 +1,2 @@
[[a
b]]
+1
View File
@@ -0,0 +1 @@
Here's some text to ensure that the link and wiki link break the line [[a[b](http://www.example.com/)]]
+1
View File
@@ -0,0 +1 @@
[[A simple wiki link on a single line]]
@@ -0,0 +1 @@
[[ Here is a link with leading and trailing whitespace. ]]