-
Notifications
You must be signed in to change notification settings - Fork 6
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
Gobble not working properly #18
Comments
For now, setting |
Thanks. I have another problem: the For instance: #sourcecode(showrange: (5, 7))[```
4 spaces
4 spaces
4 spaces
4 spaces
8 spaces
8 spaces
8 spaces
4 spaces
```] Will only remove 4 spaces instead of 8. |
Good catch. Whitespace is removed before slicing the code to the desired range. This probably should be done the other way around. |
I don't understand why. Slicing the code to the range is done at line 152: Line 152 in bda9c7a
Whitespace removal is done at line 288: Line 288 in bda9c7a
I would like to propose a PR but this does not make sense 😅 |
The package needs to do several steps of pre-processing to the code. The line you reference is needed for parsing labels and acts on the code before syntax highlighting. The actual slicing happens around line 197, after highlighting (to make sure things like comments are highlighted properly, before cutting of lines). The gobbling acts on the raw text of the code, again before highlighting. |
I see. Unfortunately, if the gobbling code is moved inside the show rule, we lose ability to easily trim the string because we end up having to modify content. I'll try to see what I can do and if I end up with something usable, I'll make a PR. |
Yes, that's why I implemented it the way it is. You can remove whitespace after highlighting, but it's a bit more messy. But I think it should be possible to simply remove the whitespace from the complete code (even lines outside the range with less whitespace), because it won't mess with syntax highlighting. |
It's a lot messier, I just finished it and it's really ugly. You can see my commit if you want: SkytAsul@2f86d1e (I could have probably done it a little cleaner, but the main idea is here.) If what you meant in your above message is to gobble the whitespaces even in lines that contains less whitespaces that the desired gobbling amount, well that's clever but it could cause issue on languages relying on indentation? Idk if the syntax coloring is basing itself on indentation. |
True. It would probably not work for e.g. Python. |
I'm currently on holidays but will habe a look at your code in the next few days. |
No hurry. It works for me so take your time, enjoy your holidays :) |
Hello!
Setting
gobble: false
as a parameter tosourcecode
does not work:The text was updated successfully, but these errors were encountered: