public String markdown ( String txt ) { if ( txt == null ) { txt = "" ; } TextEditor text = new TextEditor ( txt ) ; // Standardize line endings: text . replaceAll ( "\\r\\n" , "\n" ) ; // DOS to Unix text . replaceAll ( "\\r" , "\n" ) ; // Mac to Unix text . replaceAll ( "^[ \\t]+$" , "" ) ; // Make sure $text ends with a couple of newlines: text . append ( "\n\n" ) ; text . detabify ( ) ; text . deleteAll ( "^[ ]+$" ) ; hashHTMLBlocks ( text ) ; stripLinkDefinitions ( text ) ; text = runBlockGamut ( text ) ; unEscapeSpecialChars ( text ) ; text . append ( "\n" ) ; return text . toString ( ) ; }
Perform the conversion from Markdown to HTML .