Fix image names

This commit is contained in:
Alexander Nozik 2023-07-03 13:38:07 +03:00
parent da6ba9ab01
commit 683f46435f

View File

@ -76,7 +76,7 @@ internal suspend fun SpaceClient.processMarkdownDocument(path: Path) = coroutine
val newText = documentBody.replace(regex) { val newText = documentBody.replace(regex) {
val id = it.groups["id"]?.value ?: error("Unexpected reference format: ${it.value}") val id = it.groups["id"]?.value ?: error("Unexpected reference format: ${it.value}")
val alt = it.groups["alt"]?.value val alt = it.groups["alt"]?.value
val imageName = alt ?: id val imageName = alt?.let { "$id-$alt" } ?: id
logger.info("Downloading image $id as images/$imageName") logger.info("Downloading image $id as images/$imageName")
launch(Dispatchers.IO) { launch(Dispatchers.IO) {
extractImage(path.parent, id, imageName) extractImage(path.parent, id, imageName)