Skip to content

False positive directive detection: Text with colons in parentheses incorrectly parsed #24

@DanielTowerz

Description

@DanielTowerz

Bug Report

Description

The remark-directive plugin incorrectly identifies text containing colons within parentheses as directives, causing the text to be split into separate HTML elements.

Expected Behavior

Text like (Col. 3:17) should render as normal text without being parsed as a directive.

Actual Behavior

The text (Col. 3:17) gets split and rendered as:

(Col. 3</p><div></div>)

Reproduction

  1. Use remark-directive in an Astro project with the following config:
remarkPlugins: [
  remarkDirective,
  // other plugins...
],
  1. Add markdown content:
Porque al final, la Palabra de Dios nos enseña que todo lo que hagamos, ya sea en palabra o en obra, debemos hacerlo en el nombre del Señor Jesús (Col. 3:17).
  1. The parenthetical reference (Col. 3:17) gets incorrectly parsed and split

Environment

  • remark-directive version: Latest
  • Framework: Astro v5.10.2
  • Context: Processing markdown with biblical references

Additional Context

This issue particularly affects content with biblical references (e.g., (Matt. 5:16), (1 Cor. 2:14), (2 Co. 10:5), etc.) where the colon is part of chapter:verse notation, not a directive indicator.

The plugin seems to interpret the : character as part of directive syntax even when it's clearly within parentheses and part of regular text content.

Possible Solutions

  • Add logic to exclude colon detection when inside parentheses
  • Provide configuration option to customize directive detection patterns
  • Allow escape sequences for text containing colons that should not be parsed as directives
  • Improve the tokenizer to better distinguish between actual directives and regular text with colons

Impact

This affects any markdown content containing parenthetical references with colons, making the plugin unsuitable for religious, academic, or technical content that uses similar notation patterns.

Workaround

Currently, the workaround is to disable remarkDirective entirely, but this removes all directive functionality including needed features like admonitions and media embeds, or to escape some way colon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions