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
feat: add ability to center headings and code blocks
## Details
Issue: #179
This change allows `left_pad` and `right_pad` for both headings and code
blocks to interpret floating point values < 1 as a percentage of
available space. I.e. a value of 0.5 will mean 50% of the available
window space after removing the max width of the block, i.e. center it.
Integer values >= 1 continue to function as before.
- The `language_pad` option is also interpreted in this way now
The term block is used because we do not want to center every line of a
code block individually, instead we want the entire block to be centered.
This also applies to headings but these are generally one line anyway so
no real difference.
This also adds a `left_margin` option to both headings and code blocks.
The differences between padding and margin are:
- Paddings uses the highlight associated with the block
- Margin uses the overall window background color so it's "inivisible"
- It is also important to note that margin is computed after accounting for padding
As an example lets say we have a heading that occupies 40% of the
windows width. And lets say we are applying the following config:
`{ width = 'block', left_pad = 0.33, right_pad = 0.33, left_margin = 0.5 }`
- We find that 60% of the width is availble
- We add 33% of this to the left and right side, i.e. 20% of total, with
the heading background
- For margin we find that 100% - (40% + 20% + 20%) = 20% of the space is
available so we add half (10%) to the left with the background color
- Naturally this will leave the remaining 10% on the right so things
should look centered
- I find this pretty neat :)
In a general sense margin is probably not very useful for `full` widths
but you can use it if you like.
0 commit comments