Commit 1243850e authored by Glen Mével's avatar Glen Mével
Browse files

fix numbering of poems; simpler CSS selectors for drop caps; add a list type for dialogs

parent 3ee11f59
......@@ -83,4 +83,4 @@ use_directory_urls: True
# + <header> / <footer> inside the main <article>: include author info?
# + <section> or <article> instead of <div> for poems?
# - more metadata? rel="author/license/pingback/tag"
# - GIT GIT GIT!
# - markdown: citation for poems
......@@ -63,6 +63,17 @@ def poem_processor(list_root, list_bullets):
xml.SubElement(stanza, 'span').attrib['class'] = 'poem-verse-start'
merge_into_xml_node(stanza, verse, block=False)
def dialog_processor(list_root, list_bullets):
# replace the list node with a <div> node representing the dialog:
list_root.tag = 'div'
list_root.attrib['class'] = 'dialog'
# each line will be a <p> node:
for line in list_root:
line.tag = 'p'
line.attrib['class'] = 'dialog-line'
# prepend the introducing dash:
line.text = '— ' + (line.text or '')
################################################################################
class Blockiness(Enum):
......@@ -91,6 +102,7 @@ class Config:
# the bullet `.` for poems must be followed by either one space
# or the end of line (for empty verses which serve to separate stanzas):
(r'\.(?: |(?=\n|$))', Blockiness.INLINE, poem_processor),
(r'— ', Blockiness.INLINE, dialog_processor),
]
# options offered to the user:
......
......@@ -385,19 +385,18 @@ main dd > p {
text-indent: 0;
}
/* Style a drop cap on the first paragraph that follows the first <h1>.
/* Style a drop cap on the first paragraph that follows a <h1>.
* NOTE: there exists a norm which defines the properties `initial-letter` and
* `initial-letter-align` for proper sizing and alignment of the drop cap but,
* as of 2021, only Safari has implemented it! So here we try our best…
* NOTE: it looks like these selectors do not work on Firefox for Android… */
main h1 ~ p:not(h1 ~ p ~ p) {
* as of 2021, only Safari has implemented it! So here we try our best… */
main h1 + p {
/* Move the first line closer to the drop cap than following wrapped lines: */
text-indent: -1ex;
}
main h1 ~ p:not(h1 ~ p ~ p)::first-letter {
main h1 + p::first-letter {
float: left;
text-transform: capitalize;
font-family: Georgia;
font-family: "Georgia", serif;
padding: 0;
margin-left: 0;
margin-right: .33ex; /* relative to the new font-size, so 1ex at the font size of the paragraph */
......@@ -417,7 +416,7 @@ main h1 ~ p:not(h1 ~ p ~ p)::first-letter {
* letters are misaligned. There is not much we can do; at least, we have
* checked with Firefox 87 that neither 'É' nor 'Ç' make the third line wrap. */
@supports (-moz-appearance:none) {
main h1 ~ p:not(h1 ~ p ~ p)::first-letter {
main h1 + p::first-letter {
margin-top: .16em; /* align baselines by pushing the letter down quite a bit */
margin-bottom: -.16em; /* avoid wrapping one more line while doing so */
}
......@@ -425,7 +424,7 @@ main h1 ~ p:not(h1 ~ p ~ p)::first-letter {
/* Style distinctly the paragraphs which are in the main area but not after <h1>
* (should be some paratext).
* NOTE: does not work on Firefox for Android */
* NOTE: this selector does not work on Firefox for Android. */
main p:not(h1 ~ p):not(h1 ~ * p) {
/* TODO */
font-style: italic;
......@@ -448,6 +447,11 @@ main li > ol {
margin-left: 0;
}
/* Dialogs. */
.dialog { margin-bottom: 1.5em; }
p.dialog-line { margin-bottom: 0; }
p.dialog-line { font-style: italic; }
/* Poems.
* A poem is a <div> with class .poem ; it is a succession of stanzas.
* A stanza is a <p> with class .poem-stanza ; it is a succession of verses.
......@@ -487,15 +491,19 @@ p.poem-stanza > .poem-verse-start::before {
margin-left: -12ex; /* = - (3ex + 3ex + 3ex) / 75% */
color: gray;
}
/* Only display the numbering every two verses. */
/* Only display the numbering every two verses.
* Unfortunately, that doesn’t work as expected because the :nth-of-type is per
* stanza instead of per poem. */
/*
p.poem-stanza > .poem-verse-start:not(:nth-of-type(2n))::before {
/* we hide the number by setting it a fully transparent color
* (with display:none, the counter would not be incremented;
* with display:none or visibility:hidden, the number would be removed from
* the Accessibility Tree; since the latter would still contain even numbers,
* that would be very confusing). */
* that would be very confusing). * /
color: #00000000;
}
*/
/**
** Links and colors.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment