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
Allow more types of sidebar body content #3
Comments
As part of #4, I forgot to mention that when setting up the sticky content stacking, I've also targeted in SCSS items that either have a See what you think—happy to rework this if we land on a different model! I haven't actually tested this with putting an image or other static content in place of the code chunks yet. |
Ah, right: if we're doing 1A, we don't need to worry about differentiating one sticky / cr-id thing from another, so we could be flagging those elements with a class instead of with an attribute with a unique value. The only awkward thing is that it seems like there's no way tag an executable code cell with a class (unless it's wrapped in a div, which seems a waste). One approach: we can move all elements with the, say Thoughts? |
I tend to like the latter approach, or something like it, where it's an attribute from the user perspective but gets mapped to a class internally. I believe the Quarto team uses that approach for layout (eg. If we went with this approach, we could
(Not sure why you'd want to make a code cell a step, though; that might be an overgeneralisation 😅) |
Hey, I like that naming convention! (and am always down for things that generalize needlessly) One thing that came up when I was fidgeting with the Lua script on the My inclination allow any block type in the list of the sidebar I can't think of any common use-cases that would break this approach. Once you're in a sidebar div, I can't think of a setting where you need to nest your sticky block element inside another block. |
Ahh, I see—you mean that I might want to stick, say, an image... but Quarto wraps it in other things (eg. a par) before it gets to the HTML. For the first part of that, can we use a nested filter to catch things regardless of depth? By which I mean:
Since the filter returns a deep copy, it could be invertable, and you could run it twice: once to extract the sticky blocks (for moving) and a second time inverted to give you the contents of the body with the sticky content removed. For the second question (how far do we back out when removing things), I suppose the problem is more, if we remove a nested element, is it a problem if we leave something like an empty All of this is to say that I think I agree with you—I think we can make this work with some minor deviations, if it's just Markdown pars ruining the party! |
Yep. Take this bit of markdown:
This gets rendered in the AST to:
I'm was reading the Pandoc docs and it looks like the reason Images get wrapped in Para is because the former is considered an Inline element and thus needs to be inside some sort of block. I've checked with Math elements and it looks like the same thing: both I don't know what'll happen if we snip those Inline elements out of their block and put them into a list of blocks, but I'd guess Pandoc will choke. So there's are two things to keep track of: what to do with orphaned Para in the sidebar and how to dress up the sticky content so that it's a block element Pandoc is ok with. I guess the solution is just to be sure we're detecting that those Para blocks are indeed sticky elements (or rather, contain them as Inlines) and thus should be moved as a block into the body. That should make Pandoc happy and solve the orphaned Para issue. I'll take a swing at this on |
An update: I was working under a mistaken notion of how It feels like there are two general approaches here: using Pandoc filters based on block type, where iteration is done through To be continued... |
You can take a look at #6 to see:
When you render the test doc, you'll see that One thing this brings up: we could set it up to only allow tags on block elements. Even though you can tag the Image as an Inline ( Feels like we even if we're only detecting block elements, we'll still need to detect them when they're nested. I'll work on that one next. |
Ah, I was mistaken. Indeed there is a catch-all function name for all blocks, regardless of size: https://pandoc.org/lua-filters.html#filters-on-element-sequences So the walk-the-blocks approach should be the way to go here. |
Mmmm, so if we're walking Blocks, we either need some additional logic to detect inline elements like images or maths, or we need user guidance to wrap them in a div (even if they do take attributes directly, as images do). |
Ah! One other thing with math is that the following form ("Display Math") is actually a block...
... because there is also an explicitly inline form of math, which looks like Like you, I couldn't add attributes directly to either form of math. Here's my test on inline:
|
It looks like this possibility for maths elements has been discussed and rejected in favour of a more general proposal that is pretty far down the priority list (it's been discussed for a decade): jgm/pandoc#5286, jgm/pandoc#684 |
I suppose for our case you could walk both Blocks and Inlines! You would absolutely need to have the user explicitly supply the sticky ID then, though (rather than inferring by position), because there'd be no way to work out which Inlines came before which Blocks, and vice-versa. |
If I'm reading this right, it looks like when wrapped in
Goes to:
This puts Math in the same category as Images in that they get nested in Para to become a block. The lack of an attribute syntax for Math is a bummer, but wrapping it in a Div should work with this walk-block approach. Very similar to your original outline...
For the math setting, the Div > Para > Math outer block will get put into the body-col because of the ID on Div but the inner Para > Math will not. I'm not sure what will happen to the sidebar; if it will include Para > Math or if that branch of the tree will get snipped off when it's upstream block Div > Para > Math gets set to nil. We'll see... |
Haha, oh no—I didn't actually check that the display math was a block 🤣 |
The other big types of native content we should probably check (to confirm the yare indeed blocks and not inlines) are mermaid.js and other similar diagram blocks! |
Ah, good idea. I'll add those to the doc I'm testing on. |
Alright, when you have moment, feel free to play around with. A few things..
|
Sounds good! I'll see if I can have a crack at this tonight after work 😊 |
Sorry, quick update before work on the third issue here! The fundamental problem is that the grid stack layout used by There is a new CSS selector coming down the pipe that lets you target something based on its children (as opposed to targeting the children themselves). But it only has partial browser support. The modification in #7 works in most modern browsers, but not in Firefox unless you turn a setting on (once Firefox adds it, it'll have about the same support as most modern web features). I think in the mean time, the safer thing (if possible) is to move |
Gotcha - I'm glad you've got a pulse of all the development and implementation of css! It's not clear to me if we can get away with stripping off the |
There was a bit of a blip here: I'm inclined to merge #9 then #6 then PR What are good next steps? I'm quite certain that you'd be quicker (and better) at figuring out how to get The other thing that I can start working on is how to give users some flexibility with, say, column widths and gaps between paragraphs in the sidebar, both by overriding defaults for the doc in the yaml and overriding doc settings on a block by block basis. |
(also @jimjam-slam , since I'm realizing its 8 am your time, if you're free for a quick chat right now, let me know!) |
Yeah, can do! I'll drop you an email in a tic? |
Right now, only code cell content can be dropped into the body. Let's see what it'll take to get working for other block types such images and arbitrary divs.
In code cells, hashpipe options are available to the filter as Div attributes. For images and arbitrary divs, think through whether it'll make sense to flag body content using id prefixes or classes.
The text was updated successfully, but these errors were encountered: