com.github.dennisit.vplus.data.utils.MarkdUtils Maven / Gradle / Ivy
package com.github.dennisit.vplus.data.utils;
import com.github.dennisit.vplus.data.support.markdown.Html2ImageWrapper;
import com.github.dennisit.vplus.data.support.markdown.MarkDown2HtmlWrapper;
import com.github.dennisit.vplus.data.support.markdown.MarkdownEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
@Slf4j
public class MarkdUtils {
public static void markdown2Image(String fileName) {
try {
String path = FilenameUtils.getPath(fileName);
String file = FilenameUtils.getBaseName(fileName);
String image = "/" + path + file + ".jpg";
System.out.println(image);
MarkdownEntity entity = MarkDown2HtmlWrapper.ofFile(fileName);
Html2ImageWrapper.ofMd(entity).setAutoH(true).build().asFile(image);
} catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
}
}
}