Skip to content

Commit 2f60278

Browse files
author
Michael Whapples
committed
Process inline page breaks.
1 parent 3bc731e commit 2f60278

4 files changed

Lines changed: 40 additions & 6 deletions

File tree

brailleblaster-ebraille/src/main/kotlin/org/brailleblaster/ebraille/bbx2html/blocks.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2025 American Printing House for the Blind
2+
* Copyright (C) 2025-2026 American Printing House for the Blind
33
*
44
* This program is free software: you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the Free
@@ -18,8 +18,8 @@ package org.brailleblaster.ebraille.bbx2html
1818
import nu.xom.Element
1919
import org.brailleblaster.bbx.BBX
2020
import org.brailleblaster.ebraille.asciiToEbraille
21-
import org.brailleblaster.utd.utils.getDescendantBrlFast
2221
import org.brailleblaster.utils.xml.UTD_NS
22+
import org.brailleblaster.utils.xom.childNodes
2323

2424
internal fun Element.processBlock(): Collection<org.jsoup.nodes.Element> = when(BBX.BLOCK.getSubType(this)) {
2525
BBX.BLOCK.STYLE -> processStyle()
@@ -29,7 +29,7 @@ internal fun Element.processBlock(): Collection<org.jsoup.nodes.Element> = when(
2929
else -> listOf(processParagraph())
3030
}
3131

32-
private fun Element.processPageNum(): org.jsoup.nodes.Element = org.jsoup.nodes.Element("span").attr("role", "doc-pagebreak").apply {
32+
internal fun Element.processPageNum(): org.jsoup.nodes.Element = org.jsoup.nodes.Element("span").attr("role", "doc-pagebreak").apply {
3333
val brl = getFirstChildElement("brl", UTD_NS)
3434
attr("aria-label", brl.getAttributeValue("printPage") ?: "")
3535
appendText(asciiToEbraille(brl.getAttributeValue("printPageBrl") ?: ""))
@@ -51,4 +51,4 @@ private fun Element.processParagraph(
5151
for ((k, v) in attributes) {
5252
attr(k, v)
5353
}
54-
}.appendText(getDescendantBrlFast().joinToString { asciiToEbraille(it.value) })
54+
}.appendChildren(childNodes.flatMap { it.processContent() })

brailleblaster-ebraille/src/main/kotlin/org/brailleblaster/ebraille/bbx2html/containers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2025 American Printing House for the Blind
2+
* Copyright (C) 2025-2026 American Printing House for the Blind
33
*
44
* This program is free software: you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the Free

brailleblaster-ebraille/src/main/kotlin/org/brailleblaster/ebraille/bbx2html/convert.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2025 American Printing House for the Blind
2+
* Copyright (C) 2025-2026 American Printing House for the Blind
33
*
44
* This program is free software: you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the Free
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2026 American Printing House for the Blind
3+
*
4+
* This program is free software: you can redistribute it and/or modify it
5+
* under the terms of the GNU General Public License as published by the Free
6+
* Software Foundation, version 3.
7+
*
8+
* This program is distributed in the hope that it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11+
* more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along
14+
* with this program. If not, see <https://www.gnu.org/licenses/>.
15+
*/
16+
package org.brailleblaster.ebraille.bbx2html
17+
18+
import nu.xom.Element
19+
import nu.xom.Node
20+
import org.brailleblaster.bbx.BBX
21+
import org.brailleblaster.ebraille.asciiToEbraille
22+
import org.brailleblaster.utd.properties.UTDElements
23+
import org.brailleblaster.utils.xom.childNodes
24+
25+
internal fun Element.processContent(): Collection<org.jsoup.nodes.Node> = when {
26+
UTDElements.BRL.isA(this) -> listOf(org.jsoup.nodes.TextNode(asciiToEbraille(this.value)))
27+
BBX.SPAN.PAGE_NUM.isA(this) -> listOf(this.processPageNum())
28+
else -> childNodes.flatMap { it.processContent() }
29+
}
30+
31+
internal fun Node.processContent(): Collection<org.jsoup.nodes.Node> = when(this) {
32+
is Element -> this.processContent()
33+
else -> listOf()
34+
}

0 commit comments

Comments
 (0)