commonmark / commonmark/commonmark-java

Preserve information about leading whitespace in paragraphs

Đang mở
#301 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement help wanted
Ngôn ngữ chính
Java
Star
2.7k
Fork
336
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

When using DocumentParser with no enabled block types, the Text nodes do not include whitespaces at the beginning of a line.

For example, when we use a parser with no enabled block types and the input is:

- text 1
  - text 2

the expected result is a document containing two Text nodes:

  • Text("- text 1")
  • Text(" - text 2")

but the second Text is "- text 2" (without preceding whitespaces)

To better illustrate here is a sample test that fails:

public class ParserTest {
    
    ...
    
    @Test
    public void noBlockTypes() {
        String given = "- text 1\n  - text 2";
        Parser parser = Parser.builder().enabledBlockTypes(Collections.<Class<? extends Block>>emptySet()).build();
        Node document = parser.parse(given);

        Node child = document.getFirstChild();
        assertThat(child, instanceOf(Paragraph.class));

        child = child.getFirstChild();
        assertThat(child, instanceOf(Text.class));
        assertEquals("- text 1", ((Text) child).getLiteral());

        child = child.getNext();
        assertThat(child, instanceOf(SoftLineBreak.class));

        child = child.getNext();
        assertThat(child, instanceOf(Text.class));
        assertEquals("  - text 2", ((Text) child).getLiteral());
    }
}

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với kịch bản ParserTest.noBlockTypes đang bị lỗi và kiểm tra Parser.builder() khi tất cả các loại block đều bị vô hiệu hóa, sau đó theo dõi cách các dòng đầu vào trở thành các node Text. Chạy test với input mẫu và xác nhận rằng node Text thứ hai vẫn giữ lại hai dấu cách ở đầu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.