Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't lowercase Markdown link definition labels #13155

Merged
merged 12 commits into from Dec 15, 2022
Merged

Don't lowercase Markdown link definition labels #13155

merged 12 commits into from Dec 15, 2022

Conversation

DerekNonGeneric
Copy link
Contributor

@DerekNonGeneric DerekNonGeneric commented Jul 23, 2022

Description

Markdown link definition label normalization involved case folding
(to lowercase) with undesirable outcomes and has now been modified
to no longer perform case folding of any kind whatever.

Fixes: #7118
Fixes: #3835
Signed-off-by: Derek Lewis DerekNonGeneric@inf.is

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker fisker marked this pull request as ready for review July 23, 2022 12:57
@fisker
Copy link
Sponsor Member

fisker commented Jul 23, 2022

Clicked the wrong button, was going to run tests. Sorry.

@DerekNonGeneric DerekNonGeneric marked this pull request as draft July 23, 2022 15:52
Markdown link definition label normalization involved case folding
(to lowercase) with undesirable outcomes and has now been modified
to no longer perform case folding of any kind whatever.

Fixes: #7118
Fixes: #3835
Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
@DerekNonGeneric DerekNonGeneric marked this pull request as ready for review August 3, 2022 03:24
@DerekNonGeneric
Copy link
Contributor Author

@fisker (and everyone else), sorry for the delay on this… 😅

I think I am about done with this PR now! I am not too familiar with this project's testing strategy and am unsure what else would be expected of me to have this merged. It does indeed fix the problem and will resolve both linked issues, but it maybe seems overly trivial to include anything in the changelog regarding it unless I am mistaken.

Does anyone have any thoughts on these changes so far? I'd be glad for any feedback and can always make adjustments if necessary. (I have also allowed maintainers to make changes if so inclined.)

@DerekNonGeneric
Copy link
Contributor Author

@fisker or anyone else (maybe @sosukesuzuki), what else do we need to do for this to be merged? It is a long-standing high-priority reported multiple times and I am personally affected by it almost daily.

Do all of these failing tests showing up in CI need to be modified so that they are passing instead? It seems weird that there are tests here made to ensure the unwanted behavior of casefolding is actually occuring. This fix is not a regression, so unsure on how to proceed. Halp?

@fisker
Copy link
Sponsor Member

fisker commented Aug 19, 2022

You need run yarn test --updateSnapshot

.trim()
.replace(/[\t\n ]+/g, " ")
.toLowerCase();
newObj.label = ast.label.trim().replace(/[\t\n ]+/g, " ");
Copy link
Sponsor Member

@fisker fisker Aug 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we print label as it is now, so the value in AST won't change, this line should be removed.

@@ -0,0 +1 @@
[`AsyncGeneratorFunction`]: ./index.html
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add more tests?

@fisker
Copy link
Sponsor Member

fisker commented Aug 19, 2022

It this expected?

Prettier pr-13155
Playground link

--parser markdown

Input:

[  `AsyncGeneratorFunction`]: ./index.html

Output:

[  `AsyncGeneratorFunction`]: ./index.html

@DerekNonGeneric
Copy link
Contributor Author

It this expected?

That looks fine to me. Notice how the case is preserved.

As an example of what is currently happening, and
is unacceptable; check out https://github.com/openinf/.github/pull/10/files.

@fisker
Copy link
Sponsor Member

fisker commented Aug 19, 2022

That looks fine to me.

I don't think so, the spaces should be able to remove.

remark-parse use collapse-white-space, let use it too? Just don't lowercase.

@DerekNonGeneric
Copy link
Contributor Author

let use it too? Just don't lowercase.

Oh, you made that mistake on purpose, but that is somewhat out of scope for this PR. Notice the issues it is supposed to fix.

If you want to re-evaluate how all these link label definitions are handled by prettier at this time, I don't blame you and am willing to participate in that as well.

I agree, that whitespace sh/could have been handled by prettier nicely. 👍

@fisker
Copy link
Sponsor Member

fisker commented Aug 19, 2022

Oh, you made that mistake on purpose

I can't understand.

@DerekNonGeneric
Copy link
Contributor Author

DerekNonGeneric commented Aug 19, 2022

This code sample you provided above for input with the left-padding…

[  `Asy

… is not relevant to this issue, so not sure why you brought this up.

Do you want to see about fixing other problems related to malformed link label definitions? I am willing to participate in that as well!

The biggest problem for me is that it becomes lowercased. I would never make the mistake of adding left-padding like your example shows. That is not even a stylist concern as it relates to personal preference — it is an obvious mistake made by the author. It could/should be fixed by prettier!

@fisker
Copy link
Sponsor Member

fisker commented Aug 19, 2022

Stable version

Prettier 2.7.1
Playground link

--parser markdown
--arrow-parens avoid
--trailing-comma none

Input:

[          `AsyncGeneratorFunction`]: ./index.ht

Output:

[ `asyncgeneratorfunction`]: ./index.ht

This PR

Prettier pr-13155
Playground link

--parser markdown

Input:

[                     `AsyncGeneratorFunction`]: ./index.html

Output:

[                     `AsyncGeneratorFunction`]: ./index.html

Copy link
Contributor Author

@DerekNonGeneric DerekNonGeneric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finishing up here. 👍

@fisker
Copy link
Sponsor Member

fisker commented Dec 12, 2022

@thorn0 Can you review?

@fisker fisker merged commit 44db370 into prettier:main Dec 15, 2022
Copy link
Member

@thorn0 thorn0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@DerekNonGeneric
Copy link
Contributor Author

thanks, looking forward to the update

@DerekNonGeneric DerekNonGeneric deleted the fix/md-link-label-casefold branch December 19, 2022 07:00
smoelius added a commit to trailofbits/dylint that referenced this pull request Jan 9, 2023
`prettier`'s behavior seems to have changed. I think this may be why: prettier/prettier#13155
smoelius added a commit to trailofbits/dylint that referenced this pull request Jan 9, 2023
`prettier`'s behavior seems to have changed. I think this may be why: prettier/prettier#13155
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Jan 11, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [prettier](https://prettier.io) ([source](https://github.com/prettier/prettier)) | devDependencies | patch | [`2.8.1` -> `2.8.2`](https://renovatebot.com/diffs/npm/prettier/2.8.1/2.8.2) |

---

### Release Notes

<details>
<summary>prettier/prettier</summary>

### [`v2.8.2`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#&#8203;282)

[Compare Source](prettier/prettier@2.8.1...2.8.2)

[diff](prettier/prettier@2.8.1...2.8.2)

##### Don't lowercase link references ([#&#8203;13155](prettier/prettier#13155) by [@&#8203;DerekNonGeneric](https://github.com/DerekNonGeneric) & [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```markdown
<!-- Input -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].

[Keep a Changelog]: https://example.com/

<!-- Prettier 2.8.1 -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].

[keep a changelog]: https://example.com/
<!--
^^^^^^^^^^^^^^^^^^ lowercased
-->

<!-- Prettier 2.8.2 -->
<Same as input>
```

##### Preserve self-closing tags ([#&#8203;13691](prettier/prettier#13691) by [@&#8203;dcyriller](https://github.com/dcyriller))

<!-- prettier-ignore -->

```hbs
{{! Input }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component></Component>

{{! Prettier 2.8.1 }}
<div></div>
<div></div>
<custom-component></custom-component>
<custom-component></custom-component>
<i></i>
<i></i>
<Component />
<Component />

{{! Prettier 2.8.2 }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component />
```

##### Allow custom "else if"-like blocks with block params ([#&#8203;13930](prettier/prettier#13930) by [@&#8203;jamescdavis](https://github.com/jamescdavis))

[#&#8203;13507](prettier/prettier#13507) added support for custom block keywords used with `else`, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks.

<!-- prettier-ignore -->

```hbs
{{! Input }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading as |book|}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}

{{! Prettier 2.8.1 }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}

{{! Prettier 2.8.2 }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading as |book|}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}
```

##### Preserve empty lines between nested SCSS maps ([#&#8203;13931](prettier/prettier#13931) by [@&#8203;jneander](https://github.com/jneander))

<!-- prettier-ignore -->

```scss
/* Input */
$map: (
  'one': (
     'key': 'value',
  ),

  'two': (
     'key': 'value',
  ),
)

/* Prettier 2.8.1 */
$map: (
  'one': (
     'key': 'value',
  ),
  'two': (
     'key': 'value',
  ),
)

/* Prettier 2.8.2 */
$map: (
  'one': (
     'key': 'value',
  ),

  'two': (
     'key': 'value',
  ),
)
```

##### Fix missing parentheses when an expression statement starts with `let[` ([#&#8203;14000](prettier/prettier#14000), [#&#8203;14044](prettier/prettier#14044) by [@&#8203;fisker](https://github.com/fisker), [@&#8203;thorn0](https://github.com/thorn0))

<!-- prettier-ignore -->

```jsx
// Input
(let[0] = 2);

// Prettier 2.8.1
let[0] = 2;

// Prettier 2.8.1 (second format)
SyntaxError: Unexpected token (1:5)
> 1 | let[0] = 2;
    |     ^
  2 |

// Prettier 2.8.2
(let)[0] = 2;
```

##### Fix semicolon duplicated at the end of LESS file ([#&#8203;14007](prettier/prettier#14007) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
@&#8203;variable: {
  field: something;
};

// Prettier 2.8.1
@&#8203;variable: {
  field: something;
}; ;

// Prettier 2.8.2
@&#8203;variable: {
  field: something;
};
```

##### Fix no space after unary minus when followed by opening parenthesis in LESS ([#&#8203;14008](prettier/prettier#14008) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
.unary_minus_single {
  margin: -(@&#8203;a);
}

.unary_minus_multi {
  margin: 0 -(@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}

// Prettier 2.8.1
.unary_minus_single {
  margin: - (@&#8203;a);
}

.unary_minus_multi {
  margin: 0 - (@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}

// Prettier 2.8.2
.unary_minus_single {
  margin: -(@&#8203;a);
}

.unary_minus_multi {
  margin: 0 -(@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}
```

##### Do not change case of property name if inside a variable declaration in LESS ([#&#8203;14034](prettier/prettier#14034) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
@&#8203;var: {
  preserveCase: 0;
};

// Prettier 2.8.1
@&#8203;var: {
  preservecase: 0;
};

// Prettier 2.8.2
@&#8203;var: {
  preserveCase: 0;
};
```

##### Fix formatting for auto-accessors with comments ([#&#8203;14038](prettier/prettier#14038) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
class A {
  @&#8203;dec()
  // comment
  accessor b;
}

// Prettier 2.8.1
class A {
  @&#8203;dec()
  accessor // comment
  b;
}

// Prettier 2.8.1 (second format)
class A {
  @&#8203;dec()
  accessor; // comment
  b;
}

// Prettier 2.8.2
class A {
  @&#8203;dec()
  // comment
  accessor b;
}
```

##### Add parentheses for TSTypeQuery to improve readability ([#&#8203;14042](prettier/prettier#14042) by [@&#8203;onishi-kohei](https://github.com/onishi-kohei))

<!-- prettier-ignore -->

```tsx
// Input
a as (typeof node.children)[number]
a as (typeof node.children)[]
a as ((typeof node.children)[number])[]

// Prettier 2.8.1
a as typeof node.children[number];
a as typeof node.children[];
a as typeof node.children[number][];

// Prettier 2.8.2
a as (typeof node.children)[number];
a as (typeof node.children)[];
a as (typeof node.children)[number][];
```

##### Fix displacing of comments in default switch case ([#&#8203;14047](prettier/prettier#14047) by [@&#8203;thorn0](https://github.com/thorn0))

It was a regression in Prettier 2.6.0.

<!-- prettier-ignore -->

```jsx
// Input
switch (state) {
  default:
    result = state; // no change
    break;
}

// Prettier 2.8.1
switch (state) {
  default: // no change
    result = state;
    break;
}

// Prettier 2.8.2
switch (state) {
  default:
    result = state; // no change
    break;
}
```

##### Support type annotations on auto accessors via `babel-ts` ([#&#8203;14049](prettier/prettier#14049) by [@&#8203;sosukesuzuki](https://github.com/sosukesuzuki))

[The bug that `@babel/parser` cannot parse auto accessors with type annotations](babel/babel#15205) has been fixed. So we now support it via `babel-ts` parser.

<!-- prettier-ignore -->

```tsx
class Foo {
  accessor prop: number;
}
```

##### Fix formatting of empty type parameters ([#&#8203;14073](prettier/prettier#14073) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
const foo: bar</* comment */> = () => baz;

// Prettier 2.8.1
Error: Comment "comment" was not printed. Please report this error!

// Prettier 2.8.2
const foo: bar</* comment */> = () => baz;
```

##### Add parentheses to head of `ExpressionStatement` instead of the whole statement ([#&#8203;14077](prettier/prettier#14077) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
({}).toString.call(foo) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo);

// Prettier 2.8.1
({}.toString.call(foo) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo));

// Prettier 2.8.2
({}).toString.call(foo.forEach) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo);
```

##### Fix comments after directive ([#&#8203;14081](prettier/prettier#14081) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
"use strict" /* comment */;

// Prettier 2.8.1 (with other js parsers except `babel`)
Error: Comment "comment" was not printed. Please report this error!

// Prettier 2.8.2
<Same as input>
```

##### Fix formatting for comments inside JSX attribute ([#&#8203;14082](prettier/prettier#14082) with by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
function MyFunctionComponent() {
  <button label=/*old*/"new">button</button>
}

// Prettier 2.8.1
Error: Comment "old" was not printed. Please report this error!

// Prettier 2.8.2
function MyFunctionComponent() {
  <button label=/*old*/ "new">button</button>;
}
```

##### Quote numeric keys for json-stringify parser ([#&#8203;14083](prettier/prettier#14083) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
{0: 'value'}

// Prettier 2.8.1
{
  0: "value"
}

// Prettier 2.8.2
{
  "0": "value"
}
```

##### Fix removing commas from function arguments in maps ([#&#8203;14089](prettier/prettier#14089) by [@&#8203;sosukesuzuki](https://github.com/sosukesuzuki))

<!-- prettier-ignore -->

```scss
/* Input */
$foo: map-fn(
  (
    "#{prop}": inner-fn($first, $second),
  )
);

/* Prettier 2.8.1 */
$foo: map-fn(("#{prop}": inner-fn($first $second)));

/* Prettier 2.8.2 */
$foo: map-fn(
  (
    "#{prop}": inner-fn($first, $second),
  )
);

```

##### Do not insert space in LESS property access ([#&#8203;14103](prettier/prettier#14103) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```less
// Input
a {
  color: @&#8203;colors[@&#8203;white];
}

// Prettier 2.8.1
a {
  color: @&#8203;colors[ @&#8203;white];
}

// Prettier 2.8.2
<Same as input>
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45MC4wIiwidXBkYXRlZEluVmVyIjoiMzQuOTcuNSJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1708
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
DerekNonGeneric added a commit to OpenINF/.github that referenced this pull request Jan 21, 2023
This is still not using the latest changes needed, which
prevent the Markdown link definition label case from
being lowercased.

Refs: prettier/prettier#13155

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
DerekNonGeneric added a commit to OpenINF/.github that referenced this pull request Feb 22, 2023
This is still not using the latest changes needed, which
prevent the Markdown link definition label case from
being lowercased.

Refs: prettier/prettier#13155

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Jan 4, 2024
Co-authored-by: fisker Cheung <lionkay@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown: Link key converted to lower-case Markdown: Link text converted to lower-case
4 participants