Skip to content
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

feature: Center & Padding for text body #200

Closed
varo6 opened this issue Oct 6, 2024 · 3 comments
Closed

feature: Center & Padding for text body #200

varo6 opened this issue Oct 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@varo6
Copy link

varo6 commented Oct 6, 2024

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

I was wondering if it is possible to center the written text (not codeblock or something, just normal paragraphs), not as much as center align but some padding on the left and right. The header is centered perfectly, but this adds readability for quick notes.

Describe the solution you'd like

A good enclosure could be this one, having a margin on the left and right:
web

Describe alternatives you've considered

Maybe handling terminal padding or in neovim config works, but I don't know if it's possible enabling this only on markdown files.

Additional information

No response

@varo6 varo6 added the enhancement New feature or request label Oct 6, 2024
MeanderingProgrammer added a commit that referenced this issue Oct 7, 2024
## Details

Request: #200

Adds a new paragraph configuration which has 2 properties in addition to
the standard `enabled` field.

- `min_width`: allows you to specify a minimum width for each paragraph
  to improve general alignment when using long and short paragraphs
- `left_margin`: this functions in the same way as heading and code
  block margin where a value < 1 is treated as a fraction of the
  available window space and values >= 1 are just then number of cells
  to use for margin.

We use margin rather than padding since paragraphs do not support a
background so padding would not have any visual distenction.

Includes a minor refactor to allow `list.clamp` to resolve either a
single value or an array of values rather than only having this availble
in the heading module. That's still the only place that it's used but in
general I think it makes sense to have it more available.
@MeanderingProgrammer
Copy link
Owner

Added the feature here under a new paragraph configuration: d20d19f

You can try something like:

require('render-markdown').setup({
  paragraph = {
    left_margin = 0.5,
    min_width = 100,
  },
})

To center paragraphs.

Paragraphs are centered individually, so if you don't set a min_width single line paragraphs will end up not looking great.

@varo6
Copy link
Author

varo6 commented Oct 8, 2024

Thanks! it did work, adding a paragraph render is nice too, I guess I can play with similar attributes as in the header.
As a support, texts that are longer than one line without a break don't get the margin added, but it's not something I would need.

@varo6 varo6 closed this as completed Oct 8, 2024
@MeanderingProgrammer
Copy link
Owner

Yeah, I'm not sure how to apply inline virtual text across wrapped lines. Currently I don't think it's possible, at least not easily.

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