Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html),
with the exception that 0.x versions can break between minor versions.

## Unreleased
### Fixed

- Fix rendering of image alt text to include contents of code spans (`` `code` ``). (#398)

## [0.25.1] - 2025-08-01
### Fixed
- footnotes: Fix parsing of footnote definitions containing multiple paragraphs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ public void visit(Text text) {
sb.append(text.getLiteral());
}

@Override
public void visit(Code code) {
sb.append(code.getLiteral());
}

@Override
public void visit(SoftLineBreak softLineBreak) {
sb.append('\n');
Expand Down
10 changes: 10 additions & 0 deletions commonmark/src/test/java/org/commonmark/test/HtmlRendererTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ public void imageAltTextWithEntities() {
assertThat(defaultRenderer().render(parse("![foo &auml;](/url)\n"))).isEqualTo("<p><img src=\"/url\" alt=\"foo \u00E4\" /></p>\n");
}

@Test
public void imageAltTextWithInlines() {
assertThat(defaultRenderer().render(parse("![_foo_ **bar** [link](/url)](/url)\n"))).isEqualTo("<p><img src=\"/url\" alt=\"foo bar link\" /></p>\n");
}

@Test
public void imageAltTextWithCode() {
assertThat(defaultRenderer().render(parse("![`foo` bar](/url)\n"))).isEqualTo("<p><img src=\"/url\" alt=\"foo bar\" /></p>\n");
}

@Test
public void canRenderContentsOfSingleParagraph() {
Node paragraphs = parse("Here I have a test [link](http://www.google.com)");
Expand Down