Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

HTML Tags not closing with markdown extension #1598

Open

Description

@natsch93

Describe the issue

HTML Tags are not closing automatically with markdown() extension.

<div> seems to work fine, and closes automatically.

But trying other elements like <b>, <a>, <label>, etc. does not work, unless a <div></div> is present above.

Reproduction steps:

  • Open the reproduction link
  • Enter <b>, notice how doesn't auto-close
  • Delete <b> and enter <div>, <div> auto-closes successfully
  • Go below the <div></div> and enter <b> again, this time auto-close is successful for <b>
codemirror-markdown-html-auto-close-tag-issue.mp4

Browser and platform

Chrome

Reproduction link

https://codemirror.net/try/#c=aW1wb3J0IHsgYmFzaWNTZXR1cCwgRWRpdG9yVmlldyB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7IG1hcmtkb3duIH0gZnJvbSAiQGNvZGVtaXJyb3IvbGFuZy1tYXJrZG93biIKCmxldCB2aWV3ID0gbmV3IEVkaXRvclZpZXcoewogIGRvYzogIiIsCiAgZXh0ZW5zaW9uczogWwogICAgYmFzaWNTZXR1cCwKICAgIG1hcmtkb3duKCksCiAgXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSk=

Activity

  1. marijnh commented on Aug 1, 2025

    @marijnh
    Member

    What's happening is that the Markdown parser isn't yet parsing <b as an HTML tag, whereas it is <div (or <p or any block tag). As such, HTML-specific behavior like the auto-closing isn't firing when a > is typed. This parsing behavior matches the CommonMark spec (compare this and this example), but I agree that the outcome isn't great in this situation.

    It seems kind of hard to work around, though. The closing logic is implemented with an input handler, which runs before the > is in the document (and thus in the parse).

  2. marijnh commented on Apr 15, 2026

    @marijnh
    Member

    This issue has been moved to issue #1598 on the repository's new home.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions