🛠️ Parse <image> tag as well
* Added <image> tag to Images, which is used to display cover images Part-of: #69
This commit is contained in:
parent
8f9d849e3e
commit
98a0f30c0c
1 changed files with 18 additions and 1 deletions
|
|
@ -63,7 +63,7 @@ class DocumentParser @Inject constructor(
|
|||
element.append("]($link)")
|
||||
}
|
||||
|
||||
// Image
|
||||
// Image (<img>)
|
||||
select("img").forEach { element ->
|
||||
val src = element.attr("src")
|
||||
.trim()
|
||||
|
|
@ -81,6 +81,23 @@ class DocumentParser @Inject constructor(
|
|||
|
||||
element.append("\n[[$src|$alt]]\n")
|
||||
}
|
||||
|
||||
// Image (<image>)
|
||||
select("image").forEach { element ->
|
||||
val src = element.attr("xlink:href")
|
||||
.trim()
|
||||
.substringAfterLast("/")
|
||||
.lowercase()
|
||||
.takeIf {
|
||||
it.containsVisibleText() && imageEntries?.any { image ->
|
||||
it == image.name.substringAfterLast('/').lowercase()
|
||||
} == true
|
||||
} ?: return@forEach
|
||||
|
||||
val alt = src.substringBeforeLast(".")
|
||||
|
||||
element.append("\n[[$src|$alt]]\n")
|
||||
}
|
||||
}.wholeText().lines().forEach { line ->
|
||||
yield()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue