Skip to content

Conversation

@JTS-FIN
Copy link

@JTS-FIN JTS-FIN commented Jun 25, 2025

Many (most?) markdown parsers don't support multiline img alt-texts (Hugo for example). So this is a fix for that.

Replacing from html img multiline alt-texts to single line. Replacing newlines with " - ". Multiple newlines will be replaced by only one " - ".

Replacing from html img multiline alt-texts to single line.
Replacing newlines with " - ". Multiple newlines will be
replaced by only one " - ".
@JTS-FIN
Copy link
Author

JTS-FIN commented Jun 25, 2025

Here is also how I tested it:

// test-multiline-img-alt-text.js
const TurndownService = require('./lib/turndown.cjs.js')

const turndownService = new TurndownService()
const markdown = turndownService.turndown(`<img src="example.jpg" alt="Example Image
with

multiline alt text" />`)
console.log(markdown)

Resulted in:

![Example Image - with - multiline alt text](example.jpg)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant