mcanouil / quarto-highlight-text

Quarto extension that allows to highlight text in a document for various formats: HTML, LaTeX, Typst, and Docx.
https://m.canouil.dev/quarto-highlight-text/
MIT License
5 stars 1 forks source link

Add corner radius #14

Open apcamargo opened 2 weeks ago

apcamargo commented 2 weeks ago

Just a small suggestion to improve aesthetics. The highlight boxes could have a small radius in the corners, like this:

image


image

If subtle, this can improve the visuals. I found this snipped that can be useful (although I think the radius is way to big in the example).

mcanouil commented 2 weeks ago

Thanks for the suggestion although this will create discrepancies with other format.

I'll see what can be done.

apcamargo commented 2 weeks ago

By "other format" you mean everything that is not HTML? If that's the case, I don't see any problems in having discrepancies, as we don't expect all the formats to be 100% visually consistent. Having a modern-looking highlight in the HTML would just be an extra.

apcamargo commented 13 hours ago

Just a quick update, I ended up implemented this locally. For now, I couldn't find any negative consequences.

Here's the modified highlight_html function:

local function highlight_html(span, colour, bg_colour)
    if span.attributes['style'] == nil then
        span.attributes['style'] = ''
    elseif span.attributes['style']:sub(-1) ~= ";" then
        span.attributes['style'] = span.attributes['style'] .. ";"
    end

    if colour ~= nil then
        span.attributes['colour'] = nil
        span.attributes['color'] = nil
        span.attributes['style'] = span.attributes['style'] .. 'color: ' .. colour .. ';'
    end

    if bg_colour ~= nil then
        span.attributes['bg-colour'] = nil
        span.attributes['bg-color'] = nil
        span.attributes['style'] = span.attributes['style'] .. 'background-color: ' .. bg_colour ..
                                       ';border-radius: 3.5px;'
    end

    return span
end