#Mark heading and following content as draft

1 messages · Page 1 of 1 (latest)

wide nebula
#

Continuing discussion from #quick-questions message

upbeat wind
#

I mean you can also define a draft environment to apply rules inside

#

And call #draft[ your content] with draft a function that will apply a show rule to the content

wide nebula
#

That's probably the easiest solution, but not the most ergonimic

upbeat wind
#

It's slightly less automatic in that you have to place the ] accordingly

#

Maybe some advanced context use would allow for selecting the parts anyway, though I'm really not up to date with it (especially after the last .11 update)

wide nebula
#

The thing I am coming up with is truly cursed, maybe I can get it working tho
For now I can only apply the draft status to one heading at a time

#

@craggy forge this is the best I could come up with so far

#

?r ```ts
#let styling(content) = {
// enter any styling wanted for drafting here
set text(fill: red)
content
}

// currently needed to detect stop
#let draft-stop = [#place(hide[stop]) <draft>]

#let draft(content) = {
let children = content.children
let first-heading-idx = children.position(c => c.func() == heading)
let first-heading = children.at(first-heading-idx)
let second-heading-idx = children.slice(first-heading-idx + 1).position(c => c.func() == heading and c.depth <= first-heading.depth)

let draft-stop = children.position(c => c.at("label", default: none) == <draft>)

for i in range(0, content.children.len()) {
let before-draft-stop = draft-stop == none or i < draft-stop
let before-second-heading = second-heading-idx == none or i < second-heading-idx
if before-draft-stop and before-second-heading {
show: styling
children.at(i)
} else {
children.at(i)
}
}
}

#show: draft
= heading

My paragraph

== snd level
fdjfkld
dfkjd

= next heading
fdffd

== fdfdf

#draft-stop
#show: draft
= third heading
third paragraph

= fourth

#draft-stop
#show: draft
== second level only

= fifth

wide nebula
#

To mark a heading and the following content as draft, just put

#draft-stop
#show: draft

above