There is a problem of lacking the character "!" When outputting in Markdown format after parsing the syntax of ImageRef which refers to ID.
This problem can be confirmed with the following test case.
import org.junit.Assert;
import org.junit.Test;
import com.vladsch.flexmark.ast.Node;
import com.vladsch.flexmark.formatter.internal.Formatter;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.options.MutableDataSet;
public class MarkdownFormatterTest {
@Test
public void testImageRefID() {
final MutableDataSet parseOptions = new MutableDataSet();
final MutableDataSet formatOptions = new MutableDataSet();
formatOptions.set(Parser.EXTENSIONS, parseOptions.get(Parser.EXTENSIONS));
final String markdownText = "![Alt text][id]\n\n[id]: https://www.example.com/img.png \"test\"\n";
final Parser parser = Parser.builder(parseOptions).build();
final Formatter renderer = Formatter.builder(formatOptions).build();
final Node document = parser.parse(markdownText);
final String renderedText = renderer.render(document);
final HtmlRenderer htmlRenderer = HtmlRenderer.builder(formatOptions).build();
final String renderedHtml = htmlRenderer.render(document);
System.out.println(renderedText);
System.out.println(renderedHtml);
Assert.assertTrue(renderedHtml.contains("<img "));
Assert.assertTrue(renderedText.contains("![Alt text]"));
}
}
There is a problem of lacking the character "!" When outputting in Markdown format after parsing the syntax of ImageRef which refers to ID.
This problem can be confirmed with the following test case.