HTML to Markdown with Java -
is there easy way transform html markdown java?
i using java markdownj library transform markdown html.
import com.petebevin.markdown.markdownprocessor; ... public static string gethtml(string markdown) { markdownprocessor markdown_processor = new markdownprocessor(); return markdown_processor.markdown(markdown); } public static string getmarkdown(string html) { /* todo ask stackoverflow */ }
use xslt.
if need using xslt , java here's code snippet:
public static void main(string[] args) throws exception { file xsltfile = new file("mardownxslt.xslt"); source xmlsource = new streamsource(new stringreader(thehtml)); source xsltsource = new streamsource(xsltfile); transformerfactory transfact = transformerfactory.newinstance(); transformer trans = transfact.newtransformer(xsltsource); stringwriter result = new stringwriter(); trans.transform(xmlsource, new streamresult(result)); }
Comments
Post a Comment