Take the most famous group of lines of them all:
Hamlet: To be, or not to be: that is
the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, 'tis a consummation Devoutly to be wish'd. To die, to sleep; To sleep: perchance to dream: ay, there's the rub; For in that sleep of death what dreams may come
How would you mark that up in a semantic way, preserving space for a) line number (e.g., 1.1.1), b) chara开发者_运维技巧cter name, and c) of course, the text?
As the HTML 4 spec explicitly suggests using dl
for dialogue, I think I'd use that.
Either:
<dl>
<dt>Hamlet</dt>
<dd id="line-1.1.1">To be, or not to be: that is</dd>
<dd id="line-1.1.2">the question: Whether 'tis nobler in</dd>
...
...or, if contiguous prose is semantically important (it probably is):
<dl>
<dt>Hamlet</dt>
<dd>
<span id="line-1.1.1">To be, or not to be: that is</span>
<span id="line-1.1.2">the question: Whether 'tis nobler in</span>
...
The styling of this (leaving "space" for things) is separate from the semantic markup; however, the above gives you sufficient handles to likely achieve what you need, including possibly using generated CSS content.
I'm going to have to disappoint you there, but it is not possible. See this A List Apart article for more information.
To summarise, because HTML is a markup language designed specifically to mark up a certain type of document, not all documents can be represented with HTML's limited set of elements:
Some documents cannot be published using HTML. In many cases, we shouldn’t even bother trying. In other cases, we have to radically change the appearance and structure of the document.
They even used a screenplay as an example of one such document. I will recommend you to read the entire article in full to see the rationale, as well other methods for marking up documents.
"HTML" and "semantic markup" in the same sentence seems a bit like a contradiction in terms. Unless, of course, you count labelling things as <span class="line-of-poetry">
.
If you want to do this properly you need to think about overlap: in a play, dividing the text into lines of poetry gives different/overlapping boundaries as when you divide it according to who is speaking. there's a vast literature on how to handle overlapping markup - but I don't think any of it mentions HTML!
精彩评论