From 1a545faba17020e0ece1f9e54486ad7180ec94ea Mon Sep 17 00:00:00 2001 From: the-dg04 Date: Fri, 11 Oct 2024 21:19:41 +0530 Subject: [PATCH 1/5] potential fix for issue#4134 --- src/languages/dos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/dos.js b/src/languages/dos.js index fe14cae6a4..00b8b3b1aa 100644 --- a/src/languages/dos.js +++ b/src/languages/dos.js @@ -148,7 +148,7 @@ export default function(hljs) { { 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 From 168c421036ed869768ace3f4663381e04881dccd Mon Sep 17 00:00:00 2001 From: the-dg04 Date: Sat, 12 Oct 2024 11:54:11 +0530 Subject: [PATCH 2/5] updated dos.js to not misidentify disk change as a label --- src/languages/dos.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languages/dos.js b/src/languages/dos.js index 00b8b3b1aa..59baa68de3 100644 --- a/src/languages/dos.js +++ b/src/languages/dos.js @@ -148,7 +148,8 @@ export default function(hljs) { { className: 'function', begin: LABEL.begin, - end: '\n', + end: /\n/, + illegal: LABEL.begin + /\s*$/, contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*' }), COMMENT From 29b7c2496c3a9991f0955a6ee8b4f281fe1f37ee Mon Sep 17 00:00:00 2001 From: the-dg04 Date: Sat, 12 Oct 2024 12:17:57 +0530 Subject: [PATCH 3/5] updated dos.js to now only match labels and not comments --- src/languages/dos.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/dos.js b/src/languages/dos.js index 59baa68de3..ed91125de9 100644 --- a/src/languages/dos.js +++ b/src/languages/dos.js @@ -14,7 +14,7 @@ export default function(hljs) { ); const LABEL = { className: 'symbol', - begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)', + begin: '^:', relevance: 0 }; const KEYWORDS = [ @@ -149,7 +149,7 @@ export default function(hljs) { className: 'function', begin: LABEL.begin, end: /\n/, - illegal: LABEL.begin + /\s*$/, + 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 From cab894b4e947b19309076ba015e0f929355c9d4b Mon Sep 17 00:00:00 2001 From: the-dg04 Date: Sat, 12 Oct 2024 12:17:57 +0530 Subject: [PATCH 4/5] updated dos.js to now only match labels and not comments --- src/languages/dos.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/languages/dos.js b/src/languages/dos.js index 59baa68de3..4c368a1448 100644 --- a/src/languages/dos.js +++ b/src/languages/dos.js @@ -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: '^:', relevance: 0 }; const KEYWORDS = [ @@ -141,6 +147,8 @@ export default function(hljs) { built_in: BUILT_INS }, contains: [ + COMMENT, + COMMENT_2, { className: 'variable', begin: /%%[^ ]|%[^ ]+?%|![^ ]+?!/ @@ -149,7 +157,7 @@ export default function(hljs) { className: 'function', begin: LABEL.begin, end: /\n/, - illegal: LABEL.begin + /\s*$/, + 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 @@ -160,7 +168,6 @@ export default function(hljs) { begin: '\\b\\d+', relevance: 0 }, - COMMENT ] }; } From 428e5f36071b995ceac38977841044a1dc14fa2f Mon Sep 17 00:00:00 2001 From: the-dg04 Date: Mon, 14 Oct 2024 21:37:18 +0530 Subject: [PATCH 5/5] added some match cases in dos.js --- src/languages/dos.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/languages/dos.js b/src/languages/dos.js index 4c368a1448..aae5220cae 100644 --- a/src/languages/dos.js +++ b/src/languages/dos.js @@ -15,14 +15,27 @@ export default function(hljs) { // for matching comments starting with :: const COMMENT_2 = hljs.COMMENT( - /^::/, /$/, + /^::.*$/, /$/, { relevance: 10 } ); const LABEL = { className: 'symbol', - begin: '^:', + begin: '^:[A-Za-z._?][A-Za-z0-9_$#@~.?]*', relevance: 0 }; + + const DISK_CHANGE = { + className: 'symbol', + begin: '^[A-Za-z]:\\?$', + relevance: 0 + }; + + const OUTPUT_REDIRECT = { + className: 'symbol', + begin: '[1-2]?[>]>{1}\s*[^&\s]+', + relevance: 0 + }; + const KEYWORDS = [ "if", "else", @@ -157,12 +170,24 @@ export default function(hljs) { className: 'function', begin: LABEL.begin, 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 + 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*' }) ] + }, + { + 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*' }) ] + }, { className: 'number', begin: '\\b\\d+',