highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

(gherkin) highlight wrongly for unclosed '<' #3638

Open pkufranky opened 1 year ago

pkufranky commented 1 year ago

Describe the issue

When there is a '<' in someline, but without a '>', the line and following lines are highlighted wrongly

Which language seems to have the issue?

gherkin

Are you using highlight or highlightAuto? highlight

Sample Code to Reproduce

Feature: foo
  Scenario: test scenario <foo>
  Given a < b
  Then a is less than b

Expected behavior

Additional context

image

joshgoebel commented 1 year ago

The definition of variable likely needs to be tightened up: https://github.com/highlightjs/highlight.js/blob/fd307015164c05b191156efc378622293089c616/src/languages/gherkin.js#L34-L36

What are the exact syntax requirements for variables in Gherkin?

pkufranky commented 1 year ago

What are the exact syntax requirements for variables in Gherkin?

from https://cucumber.io/docs/gherkin/reference/#step-arguments

Scenario outlines allow us to more concisely express these scenarios through the use of a template with < >-delimited parameters

There are no accurate definition of step parameter, i think we can at least assume the < and > must be in the same line, and there aren't any '<' and '>' between the <>