check length
This commit is contained in:
parent
7f22c025ab
commit
43f6ef96a1
1 changed files with 6 additions and 0 deletions
|
@ -18,6 +18,12 @@ function latex-color --description "Get the LaTeX color from HEX code"
|
||||||
set hex (string sub -s 2 $hex)
|
set hex (string sub -s 2 $hex)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check if the length of the hex is valid
|
||||||
|
if not contains $(string length $hex) $(string split " " "3 4 6 8")
|
||||||
|
echo "Error: Invalid HEX code"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
# Expand 3 hex to 4 hex
|
# Expand 3 hex to 4 hex
|
||||||
if test (string length $hex) -eq 3
|
if test (string length $hex) -eq 3
|
||||||
set hex $(string join "" $hex 0)
|
set hex $(string join "" $hex 0)
|
||||||
|
|
Loading…
Reference in a new issue