You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In bash, you can specify the base of a number in an arithmetic expression with the construct B#n where the value of that construct is n is base B (B can be anything from 2 to 32, or can be specified with a $variable).
The issue is that in highlight.js, in this configuration, # is considered as the start of a comment. Here are three examples use cases:
echo$((16#deadbeef/1003))
yumi=deadbeef
echo$((16#$yumi/1003))
B=20
yumi=deadbeef
echo$(($B#$yumi/1003))
What I see in hightlight js: everything after the # is a comment.
What I expect: 16# and $B# should be considered as a numeric literal or something similar (at least when inside the $((...)) arithmetic expression construct); And stuff after it should not be considered a comment. Typically, I expect normal syntax highlight to work after 16#.
Note: this is the original snippet of code that prompted me to open this issue:
#!/bin/sh#Sets the current system date to one hour before now.#WARNING!! don't use after midnight.
curhour=$(date +'%H')
curdate=$((10#$curhour-1)):$(date +'%M:%S')
date --set="$curdate"
The text was updated successfully, but these errors were encountered:
Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result. The format for arithmetic expansion is:
$((expression))
The expression is treated as if it were within double quotes, but a double quote inside the parentheses is not treated specially. All tokens in
the expression undergo parameter and variable expansion, command substitution, and quote removal. The result is treated as the arithmetic expres‐
sion to be evaluated. Arithmetic expansions may be nested.
As the expression "is treated as if it were within double quotes", comments can't be allowed in it.
In bash, you can specify the base of a number in an arithmetic expression with the construct B#n where the value of that construct is
n
is baseB
(B can be anything from 2 to 32, or can be specified with a$variable
).The issue is that in highlight.js, in this configuration, # is considered as the start of a comment. Here are three examples use cases:
What I see in hightlight js: everything after the # is a comment.
What I expect:
16#
and$B#
should be considered as a numeric literal or something similar (at least when inside the$((...))
arithmetic expression construct); And stuff after it should not be considered a comment. Typically, I expect normal syntax highlight to work after16#
.Some tests gives me:
Note: this is the original snippet of code that prompted me to open this issue:
The text was updated successfully, but these errors were encountered: