File tree Expand file tree Collapse file tree 1 file changed +13
-28
lines changed
src/resources/filters/common Expand file tree Collapse file tree 1 file changed +13
-28
lines changed Original file line number Diff line number Diff line change @@ -24,40 +24,24 @@ kBackgroundColorWarning = "fcefdc"
2424kBackgroundColorTip = " ccf1e3"
2525kBackgroundColorCaution = " ffe5d0"
2626
27- local xcolors = {
28- ' red' ,
29- ' green' ,
30- ' blue' ,
31- ' cyan' ,
32- ' magenta' ,
33- ' yellow' ,
34- ' black' ,
35- ' gray' ,
36- ' white' ,
37- ' darkgray' ,
38- ' lightgray' ,
39- ' brown' ,
40- ' lime' ,
41- ' olive' ,
42- ' orange' ,
43- ' pink' ,
44- ' purple' ,
45- ' teal' ,
46- ' violet'
47- }
48-
4927function latexXColor (color )
5028 -- remove any hash at the front
5129 color = pandoc .utils .stringify (color )
5230 color = color :gsub (" #" ," " )
5331
54- -- is if this is a named color we know, use that
55- if tcontains ( xcolors , color ) then
56- return ' {named}{ ' .. color .. ' } '
32+ local hexCount = 0
33+ for match in color : gmatch " %x%x " do
34+ hexCount = hexCount + 1
5735 end
5836
59- -- otherwise treat it as an HTML color
60- return " {HTML}{" .. color .. " }"
37+ if hexCount == 3 then
38+ -- this is a hex color
39+ return " {HTML}{" .. color .. " }"
40+ else
41+ -- otherwise treat it as a named color
42+ -- and hope for the best
43+ return ' {named}{' .. color .. ' }'
44+ end
6145end
6246
6347-- converts a hex string to a RGB
@@ -71,4 +55,5 @@ function hextoRgb(hex)
7155 green = tonumber (" 0x" .. hex :sub (3 ,4 )),
7256 blue = tonumber (" 0x" .. hex :sub (5 ,6 ))
7357 }
74- end
58+ end
59+
You can’t perform that action at this time.
0 commit comments