Skip to content

Bug: highlightSpans fails when backtick is the first character on a line #2

@dpecos

Description

@dpecos

Description

When using highlightSpans: true, a highlighted span that starts at the very beginning of a line (i.e. the opening backtick is the first character) is not recognised and is rendered as plain text instead.

Steps to reproduce

---
highlightSpans: true
---

```js
`highlightedMethod`(arg1, arg2)
normalMethod(arg1, arg2)

The `highlightedMethod` at the start of the line is not highlighted.

## Root cause

The highlight-spans regex requires a non-backtick character immediately before the opening backtick. When the backtick is the first character on the line there is no such preceding character, so the pattern never matches.

## Expected behaviour

A backtick span should be highlighted regardless of whether it appears at the start of a line or is preceded by other characters.

---
*Ported from [gnab/remark#615](https://github.com/gnab/remark/issues/615) and fix proposed in [gnab/remark#703](https://github.com/gnab/remark/pull/703)*

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions