diff --git a/src/printer-markdown.js b/src/printer-markdown.js index b610eade4..a11c7ac0e 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -104,9 +104,11 @@ function genericPrint(path, options, print) { ]); } case "link": - return options.originalText[node.position.start.offset] === "<" - ? concat(["<", node.url, ">"]) - : concat([ + switch (options.originalText[node.position.start.offset]) { + case "<": + return concat(["<", node.url, ">"]); + case "[": + return concat([ "[", printChildren(path, options, print), "](", @@ -114,6 +116,12 @@ function genericPrint(path, options, print) { node.title ? ` ${printTitle(node.title)}` : "", ")" ]); + default: + return options.originalText.slice( + node.position.start.offset, + node.position.end.offset + ); + } case "image": return concat([ "![", diff --git a/tests/markdown/__snapshots__/jsfmt.spec.js.snap b/tests/markdown/__snapshots__/jsfmt.spec.js.snap index 5a4778f03..14ccb719a 100644 --- a/tests/markdown/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown/__snapshots__/jsfmt.spec.js.snap @@ -1388,9 +1388,8 @@ There is a limitation where if you stage specific lines this approach will stage the whole file after regardless. See this [issue](https://github.com/okonet/lint-staged/issues/62) for more info. -See -[https://github.com/okonet/lint-staged#configuration](https://github.com/okonet/lint-staged#configuration) -for more details about how you can configure lint-staged. +See https://github.com/okonet/lint-staged#configuration for more details about +how you can configure lint-staged. ##### Option 2. [pre-commit](https://github.com/pre-commit/pre-commit) @@ -1834,8 +1833,7 @@ section. ### Configuration Schema If you'd like a JSON schema to validate your configuration, one is available -here: -[http://json.schemastore.org/prettierrc](http://json.schemastore.org/prettierrc). +here: http://json.schemastore.org/prettierrc. ## Editor Integration diff --git a/tests/markdown_link/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_link/__snapshots__/jsfmt.spec.js.snap index 0471c3b6d..1719b44e2 100644 --- a/tests/markdown_link/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_link/__snapshots__/jsfmt.spec.js.snap @@ -20,3 +20,10 @@ exports[`title.md 1`] = ` [hello](#world "title") `; + +exports[`url.md 1`] = ` +https://www.example.com/ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +https://www.example.com/ + +`; diff --git a/tests/markdown_link/url.md b/tests/markdown_link/url.md new file mode 100644 index 000000000..eb7d84c3e --- /dev/null +++ b/tests/markdown_link/url.md @@ -0,0 +1 @@ +https://www.example.com/ diff --git a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap index f50a52d01..4e26d910b 100644 --- a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap @@ -4466,14 +4466,14 @@ _a \`_\`_ exports[`example-452.md 1`] = ` **a ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -**a<[http://foo.bar/?q=](http://foo.bar/?q=)**> +**a `; exports[`example-453.md 1`] = ` __a ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -**a<[http://foo.bar/?q=](http://foo.bar/?q=)**> +**a `; @@ -5514,7 +5514,7 @@ exports[`example-564.md 1`] = ` exports[`example-565.md 1`] = ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -<[http://foo.bar/baz](http://foo.bar/baz) bim> + `; @@ -5556,7 +5556,7 @@ exports[`example-570.md 1`] = ` exports[`example-571.md 1`] = ` < http://foo.bar > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -< [http://foo.bar](http://foo.bar) > +< http://foo.bar > `; @@ -5577,7 +5577,7 @@ exports[`example-573.md 1`] = ` exports[`example-574.md 1`] = ` http://example.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[http://example.com](http://example.com) +http://example.com `;