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

How do i escape an @ char in a code example block? #209

Open
DigitalBrainJS opened this issue Mar 24, 2020 · 4 comments
Open

How do i escape an @ char in a code example block? #209

DigitalBrainJS opened this issue Mar 24, 2020 · 4 comments
Labels

Comments

@DigitalBrainJS
Copy link

DigitalBrainJS commented Mar 24, 2020

I need to document a decorator with an example, but this breaks the parser because jsdoc2md trying to parse decorators in the example block as jsdoc tag.

    /**
     * type decorator
     * @param {BasicType} type
     * @returns {MethodDecorator}
     * @alias module:define-accessor2#type
     * @example
     * class Cat {
     *   @string
     *   name = '';
     *   @type(string|number)
     *   foo= 123;
     * }
     */

Since jsdoc2md render an example block as a markdown code block I can't use & commat; to avoid this problem.

@75lb
Copy link
Member

75lb commented Mar 25, 2020

Does this comment block render correctly using jsdoc? Jsdoc2md sits downstream of jsdoc, so if it's broken in jsdoc it will be broken in jsdoc2md..

@DigitalBrainJS
Copy link
Author

DigitalBrainJS commented Mar 25, 2020

Yes, JSDoc has the same behavior (I thought the package has its own parser because of jsoc-parser in the dependencies), but since it renders docs as html it's possible to use html entries chars to avoid this issue. Unfortunately, since jsdoc2md renders examples as markdown code blocks without the ability to use html entries inside, I can't use this workaround.
So, is there really no way to do post-processing of comments data after jsdoc parser? Does this package fully rely on parsed jsdoc data and has no access to raw data to make some fix? For example, just render commat; html entry to @ before render it to a code block.

@75lb
Copy link
Member

75lb commented Mar 25, 2020

I've looked into a workaround but unfortunately there's nothing I can do to stop jsdoc parsing the @ character in example blocks. It's a known issue.

Generally, you can use @ anywhere in jsdoc comments except within a code block, where github's markdown parser will print it literally as @ instead of @.

@75lb 75lb added the upstream label Mar 25, 2020
@DigitalBrainJS
Copy link
Author

DigitalBrainJS commented Mar 25, 2020

But this package could just replace @ to @ and then output it to a markdown block of code. This would not be an ideal solution, but acceptable to have at least some workaround for this issue.

     /**
     * type decorator
     * @param {BasicType} type
     * @returns {MethodDecorator}
     * @alias module:define-accessor2#type
     * @example
     * class Cat {
     *   @string
     *   name = '';
     *   @type(string|number)
     *   foo= 123;
     * }
     */

It doesn't look so bad ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants