package com.lanyuanxiaoyao.leopard.strategy;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.commonmark.ext.gfm.tables.TablesExtension;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

/**
 * Markdown Render
 *
 * @author lanyuanxiaoyao
 * @version 20250918
 */
public class TestMarkdown {
  public static void main(String[] args) throws IOException {
    var extensions = List.of(TablesExtension.create());
    var parser = Parser.builder()
      .extensions(extensions)
      .build();
    var render = HtmlRenderer.builder()
      .extensions(extensions)
      .build();
    var result = render.render(parser.parse(
      // language=Markdown
      """
        ### Hello
        
        ```echarts
        System.out.println("go");
        ```
        
        > I am iron man
        
        |      |    |
        |------|----|
        | Tony | 12 |
        """
    ));
    Files.writeString(Path.of("result.html"), result);
  }
}
