Skip to content

feature: Different colors in Nested Quotes #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ABlueDruid opened this issue Apr 20, 2025 · 5 comments
Closed

feature: Different colors in Nested Quotes #404

ABlueDruid opened this issue Apr 20, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@ABlueDruid
Copy link

ABlueDruid commented Apr 20, 2025

Is your feature request related to a problem? Please describe.

Nested Quotes don't have different colors from the parent nested quote (It will be nice to have a feature like this).

And Also the parent quote inherit the color of the 2nd nested quote (2nd onwards there is no different color).

Here is what I said

Image

Describe the solution you'd like

If nested quotes have different color while nested and does not affect the parent quote icon color it'll be nice (I guess).

Describe alternatives you've considered

I only use this for markdown rendering, hence I could not find any alternative what so ever.

Additional information

No response

@ABlueDruid ABlueDruid added the enhancement New feature or request label Apr 20, 2025
MeanderingProgrammer added a commit that referenced this issue Apr 22, 2025
## Details

Request: #404

While the request seems to be about using the parent color across the
board, I've instead implemented this in a slightly more complex but
hopefully more pretty way.

Rather than highlighting entire sets of `block quote` markers, i.e.
`> > >`, with a single highlight we now associate colors based on the
level of the block quote.

What this means is if we're into a triple nested block quote where:

- Level 1: `[!IMPORTANT]` callout
- Level 2: no callout
- Level 3:  `[!BUG]` callout

We'll use highlight as follows:

- `>` 1: `[!IMPORTANT]` callout highlight
- `>` 2: default `quote` highlight
- `>` 3: `[!BUG]` callout highlight

This applies throughout the `block quote` on all lines. To handle the
`lazy` provision of the `markdown` spec we simply go front to back one
level at a time. So if on some line `> >` is added even though the level
is still technically 3, we only highlight the first 2 according to the
first 2 levels.

So as not to limit the usage to callouts `quote.icon` and `quote.highlight`
now both support taking a list of strings in addition to a single string
value. When a list is provided it is indexed into using a `cycle` access
pattern based on the nesting of the current `block quote`. This allows
users to change both the color and the icon used based on how deeply
nested the block quote is.

Add unit tests for updated quote logic since it's not trivial.
@MeanderingProgrammer
Copy link
Owner

Added support for this here: 7f75b16

Unsure if it's what you were looking for but nested colors should be handled a lot better for block quotes in general.

Please update and LMK what you think!

@ABlueDruid
Copy link
Author

This is cool and good. But I was asking for something more (sorry for being kinda rude).

Here is what I think would be even better (Totally a personal opinion).

The Quote 0 is fine with what color text color it has (block --> Blue, text --> red).
But if the Q1 (in the reference picture) has a dimmer shade of the previous color (here block --> blue, text--> red). And Q2 has a little more dimmer color that Q1 it would be nice.
It will be more than enough to have this dim color support to Q3. And From Q4 to Q(n) the same dim color as Q3. (I don't think anybody does quote to More than 4 nesting.)

First I was thinking of having different color for all the nested blocks (i.e. Q0 blue, Q1 Pink, Q2 green), but that will be more distracting to look and other type of quotes has different colors ([!EXAMPLE] has kind of greenish teal color.) to look distinct.

And as the nested blocks are red in color that's why the labels like [!Bug] Can have the issue of having the same color throughout. But making the nested colors dim solves that problem (I guess).

Either way thank you for this feature. It looks more nicer than before.

Image

@MeanderingProgrammer
Copy link
Owner

I think I see what you're getting at but lmk if I'm not understanding something.

In the commit with this change I also enabled the quote.highlight value to be a list which gets indexed based on the nesting level of the block quote. This was pretty easy after figuring out how to link the icons to the associated callout.

Out of the box I still just set the single color but on your end you can create whatever highlight groups you like and set them in the configuration. Or you can use some rainbow highlights plugin, completely up to you. Would look something like:

{
    'MeanderingProgrammer/render-markdown.nvim',
    dependencies = {
        'nvim-treesitter/nvim-treesitter',
        'echasnovski/mini.nvim',
    },
    config = function()
        vim.api.nvim_set_hl(0, 'MarkdownQuote1', { fg = 'some-dark-red' })
        vim.api.nvim_set_hl(0, 'MarkdownQuote2', { fg = 'some-lighter-red' })
        vim.api.nvim_set_hl(0, 'MarkdownQuote3', { fg = 'some-other-red' })
        require('render-markdown').setup({
            quote = {
                highlight = {
                    'MarkdownQuote1',
                    'MarkdownQuote2',
                    'MarkdownQuote3',
                },
            },
        })
    end,
}

LMK if that's what you were looking for!

@ABlueDruid
Copy link
Author

Yeah Done it. Looks Sick.
Thank You. Really Needed it.

Preview. (Don't mind the my terrible color choice, just arbitrary colors lol :) )

Image

But you should consider making it default at least upto Nested Q3 in the upcoming releases.

@MeanderingProgrammer
Copy link
Owner

There's not a good set of values to set out of the box, since it depends entirely on your colorscheme.

I did however make a change that'll let color scheme authors set this up out of the box here: 7051859.

So within each color scheme you can now set whatever values make sense for the highlight groups RenderMarkdownQuote1 -> RenderMarkdownQuote6 and it'll change the highlight of the marker at that level.

By default all of these still link to RenderMarkdownQuote, so if no custom values are set all of the levels will appear the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants