From adaba79d769a71c763e891e41cd056cf48a38ebf Mon Sep 17 00:00:00 2001 From: Tatsunori Uchino Date: Tue, 17 Jan 2023 22:40:35 +0900 Subject: [PATCH] Version 1.5.1 --- assets/keep_link_uppercase.md | 14 ++++++++++++++ package.json | 2 +- src/prettier | 2 +- src/printer-markdown.js | 27 ++++++++++++++++++--------- 4 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 assets/keep_link_uppercase.md diff --git a/assets/keep_link_uppercase.md b/assets/keep_link_uppercase.md new file mode 100644 index 0000000..a5d5b16 --- /dev/null +++ b/assets/keep_link_uppercase.md @@ -0,0 +1,14 @@ +# Prettierについて + +Prettierのソースコードは、[GitHub]で管理されています。 + +[GitHub]: https://prettier.io/ + +お試しはこちらから。[Playground] + +[Playground]: https://prettier.io/playground/ + +このファイルは、Prettier 2.8.2での変更[Changelog] [PR]が反映されていることを確認するため追加されました。 + +[Changelog]: https://github.com/prettier/prettier/blob/main/CHANGELOG.md#282 +[PR]: https://github.com/prettier/prettier/pull/13155 diff --git a/package.json b/package.json index c7b0baa..d1bc636 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prettier-plugin-md-nocjsp", - "version": "1.5.0", + "version": "1.5.1", "description": "Prettier Markdown plugin to prevent inserting spaces between Chinese or Japanese & latin latters", "main": "dist/main.js", "repository": "https://github.com/tats-u/prettier-plugin-md-nocjsp", diff --git a/src/prettier b/src/prettier index dcc0623..c990e52 160000 --- a/src/prettier +++ b/src/prettier @@ -1 +1 @@ -Subproject commit dcc0623911f8b352eda18f60683eb1a232d6c2bd +Subproject commit c990e522ce81712e2e70527a6ce3d7a87b3f1114 diff --git a/src/printer-markdown.js b/src/printer-markdown.js index 81d30e5..d1276df 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -1,5 +1,6 @@ "use strict"; +const collapseWhiteSpace = require("collapse-white-space"); const { getLast, getMinNotPresentContinuousCount, @@ -370,7 +371,7 @@ function genericPrint(path, options, print) { printChildren(path, options, print), "]", node.referenceType === "full" - ? ["[", node.identifier, "]"] + ? printLinkReference(node) : node.referenceType === "collapsed" ? "[]" : "", @@ -378,7 +379,7 @@ function genericPrint(path, options, print) { case "imageReference": switch (node.referenceType) { case "full": - return ["![", node.alt || "", "][", node.identifier, "]"]; + return ["![", node.alt || "", "]", printLinkReference(node)]; default: return [ "![", @@ -390,9 +391,8 @@ function genericPrint(path, options, print) { case "definition": { const lineOrSpace = options.proseWrap === "always" ? line : " "; return group([ - "[", - node.identifier, - "]:", + printLinkReference(node), + ":", indent([ lineOrSpace, printUrl(node.url), @@ -408,7 +408,7 @@ function genericPrint(path, options, print) { case "footnote": return ["[^", printChildren(path, options, print), "]"]; case "footnoteReference": - return ["[^", node.identifier, "]"]; + return printFootnoteReference(node); case "footnoteDefinition": { const nextNode = path.getParentNode().children[path.getName() + 1]; const shouldInlineFootnote = @@ -419,9 +419,8 @@ function genericPrint(path, options, print) { node.children[0].position.start.line === node.children[0].position.end.line)); return [ - "[^", - node.identifier, - "]: ", + printFootnoteReference(node), + ": ", shouldInlineFootnote ? printChildren(path, options, print) : group([ @@ -899,6 +898,16 @@ function clamp(value, min, max) { return value < min ? min : value > max ? max : value; } +// `remark-parse` lowercase the `label` as `identifier`, we don't want do that +// https://github.com/remarkjs/remark/blob/daddcb463af2d5b2115496c395d0571c0ff87d15/packages/remark-parse/lib/tokenize/reference.js +function printLinkReference(node) { + return `[${collapseWhiteSpace(node.label)}]`; +} + +function printFootnoteReference(node) { + return `[^${node.label}]`; +} + module.exports = { preprocess, print: genericPrint,