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

Allow full HTML file generation. #12

Open
myabc opened this issue Nov 18, 2013 · 4 comments
Open

Allow full HTML file generation. #12

myabc opened this issue Nov 18, 2013 · 4 comments

Comments

@myabc
Copy link
Owner

myabc commented Nov 18, 2013

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;

    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.

Thank you,
A.

Original issue: http://code.google.com/p/markdownj/issues/detail?id=9

@myabc
Copy link
Owner Author

myabc commented Nov 18, 2013

From [email protected] on May 01, 2009 13:58:14

This is of course a feature request, but it looks like the googlecode issue tracker
does not allow the reporter to set this :(.

@myabc
Copy link
Owner Author

myabc commented Nov 18, 2013

From alex.coles on August 30, 2009 12:12:27

Status: Accepted

@myabc
Copy link
Owner Author

myabc commented Nov 18, 2013

From r.spilker on February 10, 2011 09:36:48

If you do this, please consider adding an encoding parameter and use something like

String.format("<meta http-equiv="Content-Type" content="text/html; charset=%s" />", encoding)

@myabc
Copy link
Owner Author

myabc commented Nov 18, 2013

From alex.coles on February 16, 2013 03:56:15

Labels: -Type-Defect Type-Enhancement

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

No branches or pull requests

1 participant