Skip to content

Bug: lexical/markdown's $convertFromMarkdownString is hardcoded to transform code with a transformer and does not emit <pre> tags #5424

@sherrellbc

Description

@sherrellbc
  1. $convertFromMarkdownString and an empty transformer list, CODE blocks are still converted
  2. $convertFromMarkdownString does not emit <code> tags wrapped in <pre> as it usually done for preformatted code blocks. If nothing else this is useful to distinguish inline code from block code.

Lexical version: 0.12.5

Steps To Reproduce

  1. Use $convertFromMarkdownString with a transformers argument as an empty array or with e.g. QUOTE
$convertFromMarkdownString("this is text\n> this is a quote\n```c\nint main(int argv, char **argv)\n{\n    return -1;\n}\n```\n> this is a quote", [QUOTE])
  1. Observe forced transformations on code blocks

If an empty transformer array is given then no QUOTE transformations occur as expected, but CODE transforms still do.

Link to code example: https://codesandbox.io/p/sandbox/awesome-goldberg-vgj4s2

The current behavior

  1. The function $convertFromMarkdownString implicitly transforms CODE blocks with internal logic despite passing no CODE transformer that would otherwise match the blocks.
  2. <code> tags are not wrapped in <pre> tags

The expected behavior

  1. Calling $convertFromMarkdownString with an empty array of transformers should effectively be a no-op.
  2. <code> tags are wrapped in <pre> tags, or at least conditionally through some config

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions