DTBook to OBFL for braille (sv_SE)

	Description
	DTBook to Flow stylesheet for Swedish braille.

	Parameters
		page-width (inherited)
		page-height (inherited)
		inner-margin (inherited)
		outer-margin (inherited)
		row-spacing (inherited)
		duplex (inherited)

	Format (input -> output)
		DTBook -> OBFL

	Author: Joel HÃ¥kansson

Summary

Element Category Category description Action summary Default action
bodymatter Sequence New sequence, restart pagination
frontmatter Sequence New sequence, restart pagination
rearmatter Sequence New sequence, continue pagination
level Block (type 1) no text New block
level1 Block (type 1) no text New block, break page before, margin top = 3 unless h1
level2 Block (type 1) no text New block, margin top = 2 unless h2
level3 Block (type 1) no text New block, margin top = 1 unless h3
level4 Block (type 1) no text New block, margin top = 1 unless h4
level5 Block (type 1) no text New block, margin top = 1 unless h5
level6 Block (type 1) no text New block, margin top = 1 unless h6
list Block (type 2) text sibling [complex]
blockquote Block (type 2) text sibling New block, margin left = 2, margin top = 1, margin bottom = 1
linegroup Block (type 2) text sibling New block, if preceeded by linegroup margin top = 1
poem Block (type 2) text sibling New block, margin top = 1, margin bottom = 1
div Block (type 2) text sibling New block, margin bottom = 1
annotation Block (type 2) text sibling New block
dl Block (type 2) text sibling New block
imggroup Block (type 2) text sibling New block
note Block (type 2) text sibling Create "collection"
bridgehead Block (type 3) text child New block
caption Block (type 3) text child Surround block with delimiters
covertitle Block (type 3) text child New block
docauthor Block (type 3) text child Ignore (generated on title page instead)
doctitle Block (type 3) text child Ignore (generated on title page instead)
li Block (type 3) text child Processing depends on type-attribute
h1 Block (type 3) text child New block, margin top = 3 (margin bottom = 1 unless directly followed by level2)
h2 Block (type 3) text child New block, margin top = 2 (margin bottom = 1 unless directly followed by level3)
h3 Block (type 3) text child New block, margin top = 1 (margin bottom = 1 unless directly followed by level4)
h4 Block (type 3) text child New block, margin top = 1 (margin bottom = 1 unless directly followed by level5)
h5 Block (type 3) text child New block, margin top = 1 (margin bottom = 1 unless directly followed by level6)
h6 Block (type 3) text child New block, margin top = 1, margin bottom = 1
author Block (type 4) text sibling and/or text child New block
address Block (type 4) text sibling and/or text child New block
hd Block (type 4) text sibling and/or text child New block
line Block (type 4) text sibling and/or text child New block, text indent = 2
p Block (type 4) text sibling and/or text child New block, layout depends on class-attribute
sidebar Block (type 4) text sibling and/or text child New block
byline Block (type 4) text sibling and/or text child New block
dateline Block (type 4) text sibling and/or text child New block
epigraph Block (type 4) text sibling and/or text child New block
prodnote Block (type 4) text sibling and/or text child Surround block with delimiters New block
title Block (type 4) text sibling and/or text child New block
a Inline/Block New block, if block context
cite Inline/Block New block, if block context
kbd Inline/Block New block, if block context
samp Inline/Block New block, if block context
code Inline Continue
bdo Inline Continue
em Inline Add braille markers for emphasis
strong Inline Add braille markers for strong
span Inline Continue
sub Inline Add braille markers for subscript
sup Inline Add braille markers for superscript
abbr Inline Continue
acronym Inline Continue
dfn Inline Continue
q Inline Continue
noteref Inline Continue
annoref Inline Continue
sent Inline Continue
w Inline Continue
linenum Inline Continue
lic Inline If inline and in toc, align right, fill space with ...
dd Inline New block, text indent = 2, prefix with braille markers
dt Inline New block
br Special Break line
pagenum Special Add pagenum marker
book No-op Continue
col No-op Continue
colgroup No-op Continue
dtbook No-op Continue
head No-op Continue
meta No-op Continue
link No-op Continue
img No-op Continue
table Table As matrix table
tbody Table As table body (with tfoot)
td Table New table cell
tfoot Table As table body
th Table New table cell
thead Table As table header
tr Table New table row

Table rendering

Tables can be rendered either as a normal table ("matrix") or as a stair case, depending on which is more effective in a particular case. Efficiency is calculated by evaluating:

 (100 * $forced-break-count) + 
 $total-height + 
 (($page-width - $min-block-width) / $page-width)
 

This expression says that forced breaks are very expensive (= inefficient). If they occur in one solution, but not the other, the latter will be chosen. If the number of forced breaks are equal, then the solution with the smallest total height will win. Finally, if the total height is equal for both solutions, the solution with biggest minimum block width is selected.

Additional requirements

Special case: Matrix table with a legend

When a table has th elements and more than two columns, a legend is used with the matrix table solution. The elements in the legend are listed in the order of the th elements in the table (ordered by row, then column), for example:

Legend
n1 [value of th]
n2 [value of th]
...

In addition, hyphenations are not allowed in this solution. Consequently, the cost expression above is replaced by the following in these cases:

 (100 * $forced-break-count) +
 (10 * $hyphenation-count) + 
 $total-height + 
 (($page-width - $min-block-width) / $page-width)