Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use FlexmarkHtmlConverter ,html to markdown,# no escape #616

Open
wanli-x opened this issue Jul 1, 2024 · 1 comment
Open

use FlexmarkHtmlConverter ,html to markdown,# no escape #616

wanli-x opened this issue Jul 1, 2024 · 1 comment

Comments

@wanli-x
Copy link

wanli-x commented Jul 1, 2024

The last two lines of output are the same, ### should become \###

    public static String htmlToMarkdown(String html) {
        FlexmarkHtmlConverter converter = FlexmarkHtmlConverter.builder().build();
        return converter.convert(html);
    }
    public static void main(String[] args) {
        System.out.println(htmlToMarkdown("<h1>Add: live templates starting with </h1>" +
                "<h2>Add: live templates starting with </h2>" +
                "<h3>Add: live templates starting with </h3>" +
                "<p>### Add: live templates starting with</p>"));
    }
@wanli-x
Copy link
Author

wanli-x commented Jul 1, 2024

I saw this piece of code

public @NotNull String escapeSpecialChars(@NotNull String text) {
            if (!myHtmlConverterOptions.skipCharEscape) {
                text = text.replace("\\", "\\\\");
                text = text.replace("*", "\\*");
                text = text.replace("~", "\\~");
                text = text.replace("^", "\\^");
                text = text.replace("&", "\\&");
                text = text.replace("<", "\\<").replace(">", "\\>");
                text = text.replace("[", "\\[").replace("]", "\\]");
                text = text.replace("|", "\\|").replace("`", "\\`");
                text = text.replace("\u00A0", myHtmlConverterOptions.nbspText);
            }
       return text;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant