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

Code blocks with blank lines around the content are not handled correctly #101

Closed
daviwil opened this issue Jun 15, 2023 · 3 comments
Closed

Comments

@daviwil
Copy link

daviwil commented Jun 15, 2023

Hi all!

I've experienced an issue with org-mode file rendering on Codeberg and I found that they use your library for writing out HTML from Org files. The issue is that when one has a code block like this in an Org file:

#+begin_src sh

  guix pull

#+end_src

The output looks like this on your demo site:

2023-06-15T20:15:12,835435568+03:00

Notice that there seems to be a blank line above the line guix pull but not after it, making the padding of the code block look strange. You can see a real-world example of this issue here:

https://codeberg.org/SystemCrafters/crafted-guix#headline-3

Is there any way you could trim empty lines before and after the actual content of a begin_src block while still retaining any indentation in lines that contain real content? I think that would help make code block rendering look more consistent for a wider variety of Org files.

It appears that blocks.org does not have any examples with spacing like this, so it seems to be an untested scenario.

Thanks a lot!

@daviwil
Copy link
Author

daviwil commented Jun 15, 2023

It looks like this line needs to be expanded to do left-side trimming without eating leading whitespace on the first real line:

return strings.TrimRightFunc(out, unicode.IsSpace)

Thanks @yantar92 for finding that!

@niklasfasching
Copy link
Owner

thx everyone. will tag a release for codeberg to update to
early next week!

@daviwil
Copy link
Author

daviwil commented Jun 17, 2023

Awesome, thanks a bunch @niklasfasching and super thanks to @FikriRNurhidayat for the fix!

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

No branches or pull requests

2 participants