Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

potential fix for issue#4134 #4136

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/languages/dos.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ export default function(hljs) {
/^\s*@?rem\b/, /$/,
{ relevance: 10 }
);

// for matching comments starting with ::
const COMMENT_2 = hljs.COMMENT(
/^::/, /$/,
{ relevance: 10 }
);
const LABEL = {
className: 'symbol',
begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)',
begin: '^:',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be something more like:

/^:[A-Za-z._?][A-Za-z0-9_$#@~.?]*/

Or whatever value characters for a label are?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to take a closer look to see how this is currently working. This grammar pattern is pretty old... I think we could have a much simpler rule here, or perhaps a multi-match if we truly want the : to be different than the name of the label.

relevance: 0
};
const KEYWORDS = [
Expand Down Expand Up @@ -141,14 +147,17 @@ export default function(hljs) {
built_in: BUILT_INS
},
contains: [
COMMENT,
COMMENT_2,
{
className: 'variable',
begin: /%%[^ ]|%[^ ]+?%|![^ ]+?!/
},
{
className: 'function',
begin: LABEL.begin,
end: 'goto:eof',
end: /\n/,
illegal: '[::].+', // to ignore lines starting with "::" [COMMENTS]
contains: [
hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }),
COMMENT
Expand All @@ -159,7 +168,6 @@ export default function(hljs) {
begin: '\\b\\d+',
relevance: 0
},
COMMENT
]
};
}