Edit (forgot to start with an overview of the question): Is there a sensible way to use the <$list />
widget that would allow me to start a element (<p>
) inside one item and close it (</p>
) inside a subsequent one?
In a recent thread (King James Bible Wiki), I describe a new experiment. Creating the tiddlers worked as hoped; most everything else went well. But I’m really unhappy with the technique of one of my templates.
$:/_/bible/templates/chapter is a simple-enough ViewTemplate, checking if the tiddler has the correct tag, calling the procedure $:/_/bible/procedures/chapter, and then wikifying the results.
That feels ridiculous. That procedure generates text like this:
^^[[1|Genesis 1:1]]^^ In the beginning God created the heaven and the
earth. ^^[[2|Genesis 1:2]]^^ And the earth was without form, and void;
and darkness //was// upon the face of the deep. And the Spirit of God
moved upon the face of the waters.
^^[[3|Genesis 1:3]]^^ And God said, Let there be light: and there was
light. ^^[[4|Genesis 1:4]]^^ And God saw the light, that //it was// good:
and God divided the light from the darkness. ^^[[5|Genesis 1:5]]^^
And God called the light Day, and the darkness he called Night. And t
he evening and the morning were the first day.
(line breaks added for readability.)
and then I pass the result to wikify
,
This all works, but I feel I should have been able to generate the output HTML/DOM directly and not needed to wikify. I usually can do so, but there was a problem here: The output markup needed to span list items. My basic tiddlers are the verses. To create a chapter, I need to combine them. That’s easy enough to do with a <$list />
of course. If I wanted each verse to start on its own line, this would be trivial, as it would be if I wanted them all run together. But I want something in between.
Each verse has an field new-para
which reports whether it’s the start of a new paragraph. In the sample above verses 1 and 3 are “yes”, verses (do you know how hard it is not to type “versus”?) are “no”. So 1 and 2 should be wrapped in their own <p>
tag and verses 3. 4. and 5 in another one. (There should probably be an exception for—at least—Psalms, but I haven’t thought that through yet.)
I can do this sort of control-break logic easily enough—if wordily— in TW, but it seems that a widget like <$list />
wants to generate complete DOM nodes. It’s not acceptable that <p>
is output in one list item and the corresponding </p>
is in a later one. (If that’s not the case, please let me know; perhaps I was misinterpreting the symptoms.)
But if I’m generating plain text, it doesn’t care. So I can add my <p>
, <sup>
, and <i>
and their closing partners wherever it makes sense. So I do so and then wikify the results. And since its slightly easier, I use blank lines ^^
and //
instead of their HTML counterparts. But I don’t want to be doing this at all, and I’m wondering if anyone can offer suggestions.
I do have one possibility that I’ve mostly discarded, but maybe someone can suggest a good reason to recycle it: I could add another layer to my tiddler hierarchy to cover paragraphs. If I had tiddlers tagged Paragraph
nested inside each Chapter
and had the Verse
s inside those, this would be almost trivial, just one more layer of nested lists. But that feels really wrong. The data should contain Books, Chapters, and Verses, and nothing else. If would feel like the tail wagging the dog.
And as I wrote up that last bit, I thought of a reasonable compromise. I should be able to replace my new-para: yes/no
with a simple para
with the paragraph number. That should let me create my list directly. I will go try that. But that only works because I have great control over the structure of my data. I would still like to know if there’s a good way to create lists where an HTML element starts in one list item and finishes in another – a way that doesn’t involve wikifying my text output. Any suggestions?