You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please allow to generate complete HTML files too, not just the content of
the HTML body, so that other tools can use directly the output of MarkdownJ.
Example of such a method to MarkdownProcessor that works pretty well:
/**
* Perform the conversion from Markdown to HTML, generating a
"complete" file,
* and trying to put as title the first h1 element.
*
* @param txt input in markdown format
* @param complete if it should generate a complete HTML
* @return HTML complete file corresponding to txt passed in.
*/
public String markdown(String txt, boolean complete) {
String body =this.markdown(txt);
if(!complete)
return body;
String result = "<html>\n <head>\n <title>";
String title="NO TITLE";
// try to extract the first h1 as a title
// startsWith should be replaced with "startsWithIgnoreWhiteSpace"
if(body.startsWith("<h1")) {
int end = body.indexOf("</h1>");
int start = 4; //body.indexOf("<h1>")+4;
title = body.substring(start,end);
}
result+=title;
result+="</title>\n </head>\n<body>\n";
result+=body;
result+="\n</body>\n</html>";
return result;
}
This method could be than used by the ANT filter and the command line too
(with the according parameter).
Having so as a separate method, is also backward compatible.
From [email protected] on April 30, 2009 21:19:45
Please allow to generate complete HTML files too, not just the content of
the HTML body, so that other tools can use directly the output of MarkdownJ.
Example of such a method to MarkdownProcessor that works pretty well:
/**
* Perform the conversion from Markdown to HTML, generating a
"complete" file,
* and trying to put as title the first h1 element.
*
* @param txt input in markdown format
* @param complete if it should generate a complete HTML
* @return HTML complete file corresponding to txt passed in.
*/
public String markdown(String txt, boolean complete) {
String body =this.markdown(txt);
if(!complete)
return body;
This method could be than used by the ANT filter and the command line too
(with the according parameter).
Having so as a separate method, is also backward compatible.
Thank you,
A.
Original issue: http://code.google.com/p/markdownj/issues/detail?id=9
The text was updated successfully, but these errors were encountered: