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

Use specified indent token with codeblock #299

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

jahvon
Copy link
Contributor

@jahvon jahvon commented May 5, 2024

Specifying an indent token in the code block style currently has no impact. This change incorporates the specified token when rendering code blocks.

@jahvon jahvon marked this pull request as ready for review May 5, 2024 02:49
@jahvon jahvon requested a review from muesli as a code owner May 5, 2024 02:49
@caarlos0 caarlos0 merged commit 32712ff into charmbracelet:master Jul 9, 2024
@caarlos0
Copy link
Member

caarlos0 commented Jul 9, 2024

thanks!

@bashbunni
Copy link
Member

Hey sorry, we ended up removing this from the master branch as it was demonstrating some buggy behaviour where it would print the token twice. I do still think this would be a great feature to include in Glamour, we just need to get it ironed out more :)

Here's how to reproduce this bug:

  • Change DarkStyle in styles.go to include IndentToken: stringPtr("| "), in the codeblock
  • Either switch the dep of glow to use that version of glamour or use the stdin-stdout example that meowgorithm added and do cat ../../README.md | go run . from that example's dir
    image

@jahvon
Copy link
Contributor Author

jahvon commented Aug 1, 2024

@bashbunni I think I identified that the problem here is this line https://github.com/charmbracelet/glamour/pull/299/files#diff-96fb8876f058be101f28d9c59be65222e96af85b60b4f9aaf90080ef16b756f7R125

The default margin in that style is set to 2. When I change the margin value for the code block style to 1 or replace margin with Indent: unintptr(1) I no longer see the duplicated tokens. I can reopen this with a fix for this but just want to verify that it's safe to remove the addition of the margin when rendering the indent token. Ideally, just the ident sizing is used (with maybe a default of 1?)

@bashbunni
Copy link
Member

@jahvon It would be great if you would be willing to re-open with a fix. I do think this would be a great feature to have in glamour

jahvon added a commit to jahvon/glamour that referenced this pull request Aug 3, 2024
This change incorporates the specified indentation token when rendering
code blocks. It includes fixes to how the margin and indentation tokens
are rendered globally. When both are specified, the margin is rendered
first as an empty space.

This PR is another attempt at adding the functionality from
charmbracelet#299
jahvon added a commit to jahvon/glamour that referenced this pull request Sep 10, 2024
This change incorporates the specified indentation token when rendering
code blocks. It includes fixes to how the margin and indentation tokens
are rendered globally. When both are specified, the margin is rendered
first as an empty space.

This PR is another attempt at adding the functionality from
charmbracelet#299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants