문제
는 쉬운 방법이 있을 변환하는 HTML 으로 인하 JAVA?
나는 현재 사용하여 Java MarkdownJ 라이브러리를 변환하는 인하여 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 */
}
해결책
이 XSLT.
를 사용하는 데 도움이 필요한 경우 XSLT 및 자바 여기에는 코드:
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));
}
다른 팁
나는 말로 변환하 HTML Markdown 보: http://remark.overzealous.com/manual/index.html 에 따라 달라집 JSoup,강력한 자바 라이브러리 작업을 위해 실제 세계의 HTML.
나는 작업에 동일한 문제,실험과 함께 몇 가지 다른 기술입니다.
답상 일할 수 있습니다.사용할 수 있습니다 jTidy 라이브러리 을 초기 정리 작업 및 변환에서 HTML XHTML.당신은 사용 XSLT 스타일 시트 연결된다.
불행하게도 없는 라이브러리는 one-stop 기능이 있습니다.당신이 시도할 수 있었을 사용하여 Python 스크립트 html2text 와 Jython,하지만 나는 아직 해보지 않은 이것!
사용하는 경우에는 대량살상무기 편집기를 얻고 싶 markdown 코드 서버 측에서,단지 사용하기 전에 이 옵션을 로드 wmd.js
스크립트:
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
};
제휴하지 않습니다 StackOverflow