Skip to content

Commit

Permalink
Version 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tats-u committed Jan 17, 2023
1 parent defe9e6 commit adaba79
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
14 changes: 14 additions & 0 deletions assets/keep_link_uppercase.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/prettier
Submodule prettier updated 194 files
27 changes: 18 additions & 9 deletions src/printer-markdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

const collapseWhiteSpace = require("collapse-white-space");
const {
getLast,
getMinNotPresentContinuousCount,
Expand Down Expand Up @@ -370,15 +371,15 @@ function genericPrint(path, options, print) {
printChildren(path, options, print),
"]",
node.referenceType === "full"
? ["[", node.identifier, "]"]
? printLinkReference(node)
: node.referenceType === "collapsed"
? "[]"
: "",
];
case "imageReference":
switch (node.referenceType) {
case "full":
return ["![", node.alt || "", "][", node.identifier, "]"];
return ["![", node.alt || "", "]", printLinkReference(node)];
default:
return [
"![",
Expand All @@ -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),
Expand All @@ -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 =
Expand All @@ -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([
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit adaba79

Please sign in to comment.