-
-
Notifications
You must be signed in to change notification settings - Fork 939
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
List item markers excluded from hiding and styling #619
Comments
So, after doing some experiments, I believe (part of) the cause is located here, in typst/library/src/layout/mod.rs Lines 553 to 600 in 085282c
When the individual list items are iterated over, for bulleted and enumerated lists, their styles (which seem to be the This is because bulleted and enumerated list items only hold their own body, not their markers - markers are created by the Perhaps this could be solved by letting the individual items hold their styles in some way. I'm willing to create a PR to fix this (I found out this info while trying to do so, actually, hehe). |
So, the questions left are: Is this approach correct and/or appropriate? Should we use another name for that 'styles' field? Should we store the styles somewhere else (instead of the item structs themselves)? I'll gladly make a PR once there is a better idea of the best way to do this. |
How does your change behave if you have |
Any styles applied directly to the body do not affect the marker, as seen below (upon applying my patch) - the marker is only affected when the entire list item is:
|
Instead of having the styles field, it might be cleaner to just apply the styles to the whole list item (with |
I see. The difference here seems to be that So, maybe the solution is to have |
Alright, I got a working fix with that approach. Worth saying, though, that, when the list/enum items aren't provided using the shorthand syntax ( |
That's true, I didn't think of that. Changing to content seems okay, in principle. Note that you don't even have to construct the enum item / list item in the children loop since they are immediately deconstructed into their parts anyway. |
Oh wow, I don't know how I missed that, haha! I'll work on it, thank you 👍 I guess the only significant change then will be to allow children other than ListItem/EnumItem for lists/enums, but that shouldn't be that bad of an issue anyway (since they are only used for shorthand-syntax lists, and all they do is hold their bodies) |
Purely for styling purposes my work-around for now is to create separate lists without any space between them:
It would be great if I could do this through the |
(Possibly related to #520 and #587)
Lists (bulleted and enumerated, but not term-lists) seem to not be hiding/styling correctly. More specifically, you can't hide/style list items directly fully - styling their parent element (
list
orenum
) seems to work (which styles/hides all items), but not when the listitem itself is affected (that is, attempting to style just one item), as the list item marker remains unaffected. For example, typing#hide[- b]
among other elements in the same list will produce a hiddenb
, but the marker stays there. Likewise,#text(blue)[- b]
only makes the "b" blue, but not the marker. However,#hide[#list[b]]
will work, as that creates a separate list. (The same applies for enumerated lists, but not for term lists.)I believe this is due to the fact that the
list
andenum
types handle all markers by themselves, while term lists let their items handle their own markers (the term labels). I will attempt to elaborate further in another comment below (first, I'll show a reproducible example).Here's sample typst code to reproduce this issue:
This will produce (on latest main (at commit 085282c)): (notice how markers were unaffected when they were supposed to be, when attempting to hide/style individual items)
The text was updated successfully, but these errors were encountered: