@@ -115,21 +115,73 @@ function initShortcodeHandlers()
115115 return { pandoc .RawInline (' quarto-internal' , quarto .json .encode (data )) }
116116 end
117117
118- local function handle_brand (args )
118+ local function handle_brand (args , _kwargs , _meta , _raw_args , context )
119119 local brand = require (" modules/brand/brand" )
120120 local brandCommand = read_arg (args , 1 )
121- if brandCommand ~= " color" then
121+
122+ local warn_bad_brand_command = function ()
122123 warn (" Unknown brand command " .. brandCommand .. " specified in a brand shortcode." )
123- return { pandoc .Strong ({pandoc .Str (" ?brand:" .. brandCommand )}) }
124+ if context == " block" then
125+ return pandoc .Blocks { pandoc .Strong ({pandoc .Str (" ?brand:" .. table.concat (args , " " ))}) }
126+ elseif context == " inline" then
127+ return pandoc .Inlines { pandoc .Strong ({pandoc .Str (" ?brand:" .. table.concat (args , " " ))}) }
128+ elseif context == " text" then
129+ return " ?brand:" .. table.concat (args , " " )
130+ else
131+ warn (" Unknown context for brand shortcode error: " .. context )
132+ return { }
133+ end
124134 end
125- local brandName = read_arg (args , 2 )
126- local brandValue = brand .get_color (brandName )
127- if brandValue ~= nil then
128- return { pandoc .Str (brandValue ) }
129- else
130- warn (" Unknown brand " .. brandName .. " specified in a brand shortcode." )
131- return { pandoc .Strong ({pandoc .Str (" ?brand:" .. brandName )}) }
135+
136+ if brandCommand == " color" then
137+ local color_name = read_arg (args , 2 )
138+ local color_value = brand .get_color (color_name )
139+ if color_value == nil then
140+ return warn_bad_brand_command ()
141+ else
142+ return pandoc .Inlines { pandoc .Str (color_value ) }
143+ end
132144 end
145+
146+ if brandCommand == " logo" then
147+ local logo_name = read_arg (args , 2 )
148+ local logo_value = brand .get_logo (logo_name )
149+ local entry = { path = nil }
150+
151+ if type (logo_value ) ~= " table" then
152+ warn (" unexpected logo value entry: " .. type (logo_value ))
153+ return warn_bad_brand_command ()
154+ end
155+
156+ quarto .utils .dump (logo_value )
157+
158+ -- does this have light/dark variants?
159+ -- TODO handle light-dark theme switching
160+ if logo_value .light then
161+ entry = logo_value .light
162+ else
163+ entry = logo_value
164+ end
165+
166+ if type (entry .path ) ~= " string" then
167+ warn (" unexpected type in logo light entry: " .. type (entry .path ))
168+ return warn_bad_brand_command ()
169+ end
170+
171+ -- TODO fix alt text handling
172+ if context == " block" then
173+ return pandoc .Blocks { pandoc .Image (pandoc .Inlines {}, entry .path ) }
174+ elseif context == " inline" then
175+ return pandoc .Inlines { pandoc .Image (pandoc .Inlines {}, entry .path ) }
176+ elseif context == " text" then
177+ return entry .path
178+ else
179+ warn (" unexpected context for logo shortcode: " .. context )
180+ return warn_bad_brand_command ()
181+ end
182+ end
183+
184+ return warn_bad_brand_command ()
133185 end
134186
135187 -- built in handlers (these override any user handlers)
0 commit comments