HTML to Markdown with Java?

Use this XSLT If you need help using XSLT and Java here's a 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)); }.

Use this XSLT. If you need help using XSLT and Java here's a 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)); }.

1 +1, that's brilliant. – Ninefingers Sep 6 '10 at 21:49 IMPORTANT : this XSLT is distributed under a CC-share-alike license, that means : "If you ... build upon this work, you may distribute the resulting work only under the same or similar license to this one" – cx42net May 3 at 15:10.

I am working on the same issue, and experimenting with a couple different techniques. The answer above could work. You could use the jTidy library to do the initial cleanup work and convert from HTML to XHTML.

You use the XSLT stylesheet linked above. Unfortunately there is no library that has a one-stop function to do this in Java. You could try using the Python script html2text with Jython, but I haven't yet tried this!

If you are using WMD editor and want to get the markdown code on the server side, just use these options before loading the wmd. Js script: wmd_options = { // format sent to the server. Can also be "HTML" output: "Markdown", // line wrapping length for lists, blockquotes, etc.LineLength: 40, // toolbar buttons.

Undo and redo get appended automatically. Buttons: "bold italic | link blockquote code image | ol ul heading hr", // option to automatically add WMD to the first textarea found. Autostart: true }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions