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
For the next guy who comes here via google, here is a version of the lua script adapted to support hex-style RGB colors, and yes it also works with vanilla Pandoc:
--- copied from https://github.com/rstudio/rmarkdown-cookbook/issues/194#issuecomment-610614496--- adapted to support hex-style RGB colors by pbsdsSpan=function(span)
color=span.attributes['color']
-- if no color attribute, return unchangeifcolor==nilthenreturnspanend-- tranform to <span style="color: red;"></span>ifFORMAT:match'html' then-- remove color attributesspan.attributes['color'] =nil-- use style attribute insteadspan.attributes['style'] ='color: ' ..color..';'-- return full span elementreturnspanelseifFORMAT:match'latex' then-- remove color attributesspan.attributes['color'] =nil-- encapsulate in latex codeifstring.sub(color, 1, 1) =="#" and#color==7then-- TODO: requires xcolorlocalR=tostring(tonumber(string.sub(color, 2, 3), 16))
localG=tostring(tonumber(string.sub(color, 4, 5), 16))
localB=tostring(tonumber(string.sub(color, 6, 7), 16))
table.insert(
span.content, 1,
pandoc.RawInline('latex', '\\textcolor[RGB]{'..R..','..G..','..B..'}{')
)
elseifstring.sub(color, 1, 1) =="#" and#color==4then-- TODO: requires xcolorlocalR=tostring(tonumber(string.sub(color, 2, 2), 16) *0x11)
localG=tostring(tonumber(string.sub(color, 3, 3), 16) *0x11)
localB=tostring(tonumber(string.sub(color, 4, 4), 16) *0x11)
table.insert(
span.content, 1,
pandoc.RawInline('latex', '\\textcolor[RGB]{'..R..','..G..','..B..'}{')
)
elsetable.insert(
span.content, 1,
pandoc.RawInline('latex', '\\textcolor{'..color..'}{')
)
endtable.insert(
span.content,
pandoc.RawInline('latex', '}')
)
-- returns only span contentreturnspan.contentelse-- for other format return unchangedreturnspanendend
For the next guy who comes here via google, here is a version of the lua script adapted to support hex-style RGB colors, and yes it also works with vanilla Pandoc:
Originally posted by @pbsds in #194 (comment)
The text was updated successfully, but these errors were encountered: