Skip to content

feature: allow padding for inline code #274

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
mcauley-penney opened this issue Dec 29, 2024 · 5 comments
Closed

feature: allow padding for inline code #274

mcauley-penney opened this issue Dec 29, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@mcauley-penney
Copy link

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

I am bothered by the lack of space around inline code because I feel that it is harder to read. I think that padding around inline code would be easier to read.

Describe the solution you'd like

I would like the ability to specify padding around inline code such that inline blocks appear spacious without having to add space oneself. For example, this is what inline blocks in render-markdown look like by default:

image

With a padding feature, we may have something that looks like this by default:

image

This was created by adding spaces between the backticks and the text.

Describe alternatives you've considered

One may simply add extra spaces to their document. This is fine, but this requires changing the text to achieve an aesthetic.

Additional information

No response

@mcauley-penney mcauley-penney added the enhancement New feature or request label Dec 29, 2024
@MeanderingProgrammer
Copy link
Owner

Sure, will get to this soon

MeanderingProgrammer added a commit that referenced this issue Jan 2, 2025
## Details

Request: #274

Adds `inline_pad` option to `code` component which is used to add spaces
on both sides of inline code blocks.

In order to make offset calculations work correctly needed to make some
minor adjustments to the logic:

- Marks that do not specify an end use the start as the end rather than
  being ignored when adding offset to context
- A node overlaps with a range if its start is <= the end of the range,
  not strictly <, this is because ends are inclusive for these ranges
@MeanderingProgrammer
Copy link
Owner

Done: 65b263d

Can configure it with:

require('render-markdown').setup({
    code = { inline_pad = 1 },
})

@mcauley-penney
Copy link
Author

I apologize but I can't seem to highlight the padding itself. As with the image above, I am trying to highlight the newly added space but the pads appear the same color as the Normal hl group

@MeanderingProgrammer
Copy link
Owner

Ah, gotcha, updated the highlight used for the padding to the same one as the inline code body here: c00cc1e

@mcauley-penney
Copy link
Author

It works perfectly. Thank you very much! This is slick.

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