hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

Markdown links are being removed #158

Closed Dan503 closed 2 years ago

Dan503 commented 2 years ago

I recently upgraded from v0.3.12 to v0.3.33.

In one of the versions after v0.3.12 it has started removing the markdown links in my Type-Doc comments :(

Input

interface Test {
    /**
     * Name of something.
     *
     * See [documentation][1] for more details.
     *
     * [1]: https://www.documentation.com
     */
    name?: string
}

Output (Unwanted removal of link markdown)

interface Test {
    /**
     * Name of something.
     *
     * See documentation for more details.
     */
    name?: string
}

The output should be retaining the markdown link.

hosseinmd commented 2 years ago

That comment isn't md standard. Change your comment to this

Name of something.
See [documentation](1) for more details.
# 1: https://www.documentation.com
Dan503 commented 2 years ago

Are you sure?

Your syntax appears to be the non-standard one to me.

https://www.markdownguide.org/basic-syntax/#reference-style-links

Or if there is a flavour of markdown that works with your style, you should also support this style.

hosseinmd commented 2 years ago

GitHub's comment is markdown, you can test your link with github

hosseinmd commented 2 years ago

It is hard to support Reference-style Links. But I will work on it.

Dan503 commented 2 years ago

This is a test link to test it works in GitHub

This is a [test link][1] to test it works in GitHub

[1]: https://www.google.com/
hosseinmd commented 2 years ago

Ok, That is a [test link](https://www.google.com/) to test it works in GitHub

is correct, and work in GitHub but
This is a [test link][1] to test it works in GitHub not working

Dan503 commented 2 years ago

My comment here proves that it is accepted by GitHub.

https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/158#issuecomment-1083796423

It is a reference-link-only syntax. [test link][1] on it's own doesn't work without a reference.

If you copy the sample text I posted in that comment you will see that GitHub does understand it.

hosseinmd commented 2 years ago

Fixed: v0.3.35

Thank you.

Dan503 commented 2 years ago

I installed v0.3.35 into my project.

It isn't quite providing the correct output.

input

/**
 * This is a [link][1] test.
 *
 * [1]: https://www.google.com/
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}

current output

/**
 * This is a [link][1] test.
 *
 * [1]: [https://www.google.com/]
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}

expected output

/**
 * This is a [link][1] test.
 *
 * [1]: https://www.google.com/
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}

Notice that it is adding square brackets around the URL.

Also every time you save, it adds more and more brackets.

// save 1
 * [1]: [https://www.google.com/]

// save 2
 * [1]: [[https://www.google.com/]]

// save 3
 * [1]: [[[https://www.google.com/]]]

There shouldn't be any brackets, the brackets are breaking the link.

HOWEVER

When I hover over the generated link in VS code, VS code seems to be interpreting it as a link to a local file.

So on top of the expectation above, this also needs to be considered:

input

/**
 * This is a [link][1] test.
 *
 * [1]: [local/path/to/file.js]
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}

current output

/**
 * This is a [link][1] test.
 *
 * [1]: [[local/path/to/file.js]]
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}

expected output

/**
 * This is a [link][1] test.
 *
 * [1]: [local/path/to/file.js]
 *
 * @param value - Any value you want
 */
function test(value) {
    return true
}
hosseinmd commented 2 years ago

Fixed v0.3.36