fix(markdown): print auto-link as-is (#3032)

master
Ika 2017-10-14 06:49:12 -05:00 committed by Lucas Azzola
parent 5c789b2dfc
commit c4118edbe7
5 changed files with 27 additions and 13 deletions

View File

@ -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([
"![",

View File

@ -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

View File

@ -20,3 +20,10 @@ exports[`title.md 1`] = `
[hello](#world "title")
`;
exports[`url.md 1`] = `
https://www.example.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://www.example.com/
`;

View File

@ -0,0 +1 @@
https://www.example.com/

View File

@ -4466,14 +4466,14 @@ _a \`_\`_
exports[`example-452.md 1`] = `
**a<http://foo.bar/?q=**>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**a<[http://foo.bar/?q=](http://foo.bar/?q=)**>
**a<http://foo.bar/?q=**>
`;
exports[`example-453.md 1`] = `
__a<http://foo.bar/?q=__>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**a<[http://foo.bar/?q=](http://foo.bar/?q=)**>
**a<http://foo.bar/?q=**>
`;
@ -5514,7 +5514,7 @@ exports[`example-564.md 1`] = `
exports[`example-565.md 1`] = `
<http://foo.bar/baz bim>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<[http://foo.bar/baz](http://foo.bar/baz) bim>
<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
`;