Second code span not recognised after an unclosed backtick string and another code span
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with the Java Parser and HtmlRenderer example in the issue and reproduce the three input strings against current main. Add regression coverage for the unclosed double-backtick input alongside the neighbouring code spans, and verify that the rendered HTML matches the expected output.
Written by the indexing model from the issue text.
Description
Steps to reproduce the problem (provide example Markdown if applicable):
`` `a` `c`
The same through the API, with two neighbouring inputs that render correctly, to show the trigger:
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
public class Main {
public static void main(String[] args) {
Parser parser = Parser.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder().build();
for (String md : new String[] {"`` `a` `c`", "`` `a`", "`a` `c`"}) {
System.out.print(md + " -> " + renderer.render(parser.parse(md)));
}
}
}
Expected behavior:
<p>`` <code>a</code> <code>c</code></p>
This is what the reference implementation, commonmark.js 0.31.2, gives for all three inputs: the `` has no
closing double backtick and stays literal, and both `a` and `c` are code spans (spec 0.31.2, Code spans).
Actual behavior:
<p>`` <code>a</code> `c`</p>
The full output of the program above:
`` `a` `c` -> <p>`` <code>a</code> `c`</p>
`` `a` -> <p>`` <code>a</code></p>
`a` `c` -> <p><code>a</code> <code>c</code></p>
The second code span, `c`, is left as text. It takes all three parts: with only the unclosed `` and one
code span, or with the two code spans and no unclosed string, the output is correct. Text between the parts changes
nothing, and every further code span of the same length stays text too: `a` `c` `e` after the unclosed string
gives <code>a</code> `c` `e`.
Tested on commonmark 0.30.0 from Maven Central and on current main (b89e72f).
BTW, this was found by an automated program that writes property-based tests for various open source projects using hegel (but it has been reviewed by hand before reporting). We've also potentially found (but not yet hand validated) 51 other bugs in commonmark-java. You can see the tests at https://github.com/hegeldev/hegel-zoo/tree/main/targets/java/commonmark-java. Let us know if you would like us to file the other bugs found and/or contribute the tests. NB the tests are currently LLM generated and probably not yet suitable for inclusion as is, but we're happy to help get them into a better state if you want them.
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 337
- Avg merge
- 15d 9h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from commonmark/commonmark-java
-
Unclosed link reference definition title keeps the partial title and the following paragraph's source spans (0.30.0)Possibly taken @sean0407 claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
commonmark/commonmark-java#460 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 74/100
commonmark/commonmark-java#457 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
commonmark/commonmark-java#443 · 4 comments ·
-
Option to define custom flanking/canOpen/canClose rules for delimitersMay be free again @abhiramaab claimed this 68 days ago, and no pull request is open. Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
commonmark/commonmark-java#428 · 4 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
commonmark/commonmark-java#414 · 1 comment · 1 reaction ·
All issues in commonmark/commonmark-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
[Bug] dubbo.protocol.triple.max-message-size is only read from OS environment variablesPossibly taken @CCCLL claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
youngyangyang04/leetcode-master#3026 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
hierynomus/sshj#1070 ·
-
Typo in ExecutorTemplate.cacelAllFuturesPossibly taken @xgx2025 claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100