Hello.
I’m confronted with a challenge. For revision purposes, I would like to find out if someone managed to or if it is possible to add the first sentence of each paragraph into an outline ?
The goal is to get an overview of the logical structure of a text’s arguments. As a method, that’s also called “Reverse Outline” and often suggested for academic writing. 
I don’t know what’s the best approach for this goal. First, I wonder if it could be done by transforming the first sentence into a header. But I guess, the best is to write a custom function from ground up without relying on the built-in outline function. Page numbers are not necessary anyway for this.
Thanks for your help.
1 Like
Hey! As very quick and dirty solution, this might get you on the right path:
#let to-string(it) = {
if it == none {
none
}
else if type(it) == str {
it
} else if type(it) != content {
str(it)
} else if it.has("text") {
it.text
} else if it.has("children") {
it.children.map(to-string).join()
} else if it.has("body") {
to-string(it.body)
} else if it == [ ] {
""
}
}
#context{
let pars = query(selector(par).after(<beginning>))
for p in pars {
let s = to-string(p.body)
if s != none {
let sentences = s.split(".")
sentences.first() + box(width: 1fr, repeat(".")) + counter(page).display(at: p.location()) + linebreak()
}
}
}
<beginning>
Hello.
This is the first sentence. This is the second one.
This. Is. Many. Sentences
#pagebreak()
This is on a new page. Not on the old one.
#set page(numbering: "i")
Romanes eunt domus
Some notes: I added the <beginning> tag so that the query does not include itself, if your outline is somewhere else, your strategy will have to differ.
If the sentence includes any formatting, it won’t be included, you will need a more robust “to-string” function for that.
This includes everything that types considers a paragraph, including headings and so on.
The outline itself is obviously very basic.
Does this go in the direction of what you need?
1 Like