Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TextContentRenderer: ListItem renders too many spaces #413

Copy link
Copy link
@sperol69

Description

@sperol69
Issue body actions

Steps to reproduce the problem (provide example Markdown if applicable):

List:
1. 2) 2026.
end

Expected behavior:

List:
1. 2) 2026.
end

Actual behavior: (too many spaces, increasing times after times)

List:
1.    2)       2026. 
end

(Also see what the reference implementation does: https://spec.commonmark.org/dingus/)


import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.text.LineBreakRendering;
import org.commonmark.renderer.text.TextContentRenderer;
import org.junit.jupiter.api.Test;

public class CommonMarkTest {

    String parse(String markdown) {
        Parser parser = Parser.builder() //
                .build();

        Node document = parser.parse(markdown);
        TextContentRenderer renderer = TextContentRenderer.builder() //
                .lineBreakRendering(LineBreakRendering.COMPACT) //
                .build();
        return renderer.render(document);
    }

    @Test
    void listTest_inline_ko() {
        assertAll( //
                () -> assertThat(parse("""
                        List:
                        1. 2) 2026.
                        end""")) //
                        .isEqualTo("""
                                List:
                                1. 2) 2026.
                                end"""),
                () -> assertThat(parse("""
                        List:
                        1. first
                        2. 2025. 2026. 2027.
                        end""")) //
                        .isEqualTo("""
                                List:
                                1. first
                                2. 2025. 2026. 2027.
                                end""") //
        );
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.