Preserve information about leading whitespace in paragraphs
还没有人认领这个 Issue。
评估
调研方向
从失败的 ParserTest.noBlockTypes 场景开始,在禁用所有块类型的情况下检查 Parser.builder(),然后跟踪输入行如何变成 Text 节点。使用示例输入运行测试,并确认第二个 Text 节点保留其开头的两个空格。
由索引模型根据 Issue 内容生成。
描述
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());
}
}
- 主要语言
- Java
- 星标
- 2.7k
- 派生
- 336
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
commonmark/commonmark-java 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 74/100
commonmark/commonmark-java#457 ·
-
难度 3/5 1-2 天 新手友好度 48/100
commonmark/commonmark-java#443 · 4 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
commonmark/commonmark-java#428 · 4 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
commonmark/commonmark-java#414 · 1 条评论 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
commonmark/commonmark-java#411 · 2 条评论 ·
查看 commonmark/commonmark-java 的全部 Issue
相似的 Issue
-
Bug Java Platform: Java
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-java#6138 · 1 条评论 ·
-
bug needs triage p2
难度 2/5 1-3 小时 新手友好度 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 条评论 ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/rocketmq-dashboard#4654 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100