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 all 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
41 changes: 37 additions & 4 deletions src/languages/dos.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,30 @@ export default function(hljs) {
/^\s*@?rem\b/, /$/,
{ relevance: 10 }
);

// for matching comments starting with ::
const COMMENT_2 = hljs.COMMENT(
/^::.*$/, /$/,
Copy link
Member

Choose a reason for hiding this comment

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

The begin should start and the end should end, so I think you want:

start: /^::/
end : /$/

The end shouldn't be included in the begin.

{ relevance: 10 }
);
const LABEL = {
className: 'symbol',
begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)',
begin: '^:[A-Za-z._?][A-Za-z0-9_$#@~.?]*',
relevance: 0
};

const DISK_CHANGE = {
className: 'symbol',
begin: '^[A-Za-z]:\\?$',
Copy link
Member

Choose a reason for hiding this comment

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

This should be a literal regex, not a string.

relevance: 0
};

const OUTPUT_REDIRECT = {
className: 'symbol',
begin: '[1-2]?[>]>{1}\s*[^&\s]+',
Copy link
Member

Choose a reason for hiding this comment

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

Please add a markup test or two for this so I can understand what exactly you're trying to match. This looks a bit overly complex to me, but maybe I don't understand the goal.

relevance: 0
};

const KEYWORDS = [
"if",
"else",
Expand Down Expand Up @@ -141,25 +160,39 @@ 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/,
contains: [
hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }),
COMMENT
COMMENT,
COMMENT_2
]
},
{
className: 'function',
begin: DISK_CHANGE.begin,
end: /\n/,
contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }) ]
Copy link
Member

Choose a reason for hiding this comment

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

Please explain what this is attempting to do. Are you trying to highlight all path names?

},
{
className: 'function',
begin: OUTPUT_REDIRECT.begin,
end: /\n/,
contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }) ]
Copy link
Member

Choose a reason for hiding this comment

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

Same question, is this another attempt to highlight pathname?

},
{
className: 'number',
begin: '\\b\\d+',
relevance: 0
},
COMMENT
]
};
}