Skip to content

linter: Complex code block can break jsdoc parsing. #19137

@Mister-Hope

Description

@Mister-Hope

What happened?

Complex code block can break jsdoc parsing.

E.g.:

/**
 * Handle whitespace rendering based on meta string
 *
 * `` ```js :whitespace[=all|boundary|trailing] ``
 *
 * @param parser - Code parser instance
 * @param meta - Meta string
 * @param globalOption - Global whitespace option
 *
 * @example
 * ```ts
 * import { metaWhitespace } from '@vuepress/plugin-prismjs'
 *
 * metaWhitespace(parser, ':whitespace=all', true)
 * ```
 */
export const metaWhitespace = (
  parser: CodeParser,
  meta: string,
  globalOption: WhitespacePosition | true = true,
): void => {
  const position = resolveWhitespacePosition(meta, globalOption)

  if (!position) return

  parser.line((line) => {
    renderWhitespaceInLine(line, position)
  })
}
Image

If the following line is removed:

`` ```js :whitespace[=all|boundary|trailing] ``

(Note: This is a valid markdown => ```js :whitespace[=all|boundary|trailing], double `` is needed as there is a ``` inside.)

Then everything will be fine again.

Unfortunately, we need the following jsdoc:

Image

P.S.: For more details on these tricks, refer to the CommonMark spec. Markdown can express any content thanks to its complete escaping mechanism.

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions