Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Issue #109: basic markdown support with txtmark
Browse files Browse the repository at this point in the history
  • Loading branch information
thradec committed Mar 14, 2013
1 parent 3a8ce40 commit 94328f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions app/util/JavaExtensions.java
Expand Up @@ -23,6 +23,9 @@
import play.templates.BaseTemplate.RawData;
import play.utils.HTML;

import com.github.rjeschke.txtmark.Configuration;
import com.github.rjeschke.txtmark.Processor;

public class JavaExtensions extends play.templates.JavaExtensions {

public static final String DATE_FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss.SSS";
Expand Down Expand Up @@ -94,18 +97,19 @@ public static long countFiles(File file){
}

public static Object md(String mdString) {
// TODO removing play markdown module
// try {
// String html = Markdown.transformMarkdown(HTML.htmlEscape(mdString));

String html = HTML.htmlEscape(mdString);

// workaround https://github.com/ceylon/ceylon-herd/issues/74
html = html.replaceAll("&((\\w+)|(x?[0-9a-fA-F]+));", "&$1;");
return new BaseTemplate.RawData(html);
// } catch (ParseException e) {
// return e.toString();
// }
String escaped = HTML.htmlEscape(mdString);

Configuration config = Configuration.builder()
.forceExtentedProfile()
// .setCodeBlockEmitter(...) TODO
// .setSpecialLinkEmitter(...) TODO
.build();
String html = Processor.process(escaped, config);

// workaround https://github.com/ceylon/ceylon-herd/issues/74
html = html.replaceAll("&((\\w+)|(x?[0-9a-fA-F]+));", "&$1;");

return new BaseTemplate.RawData(html);
}

public static String toISO8601(Date date) throws DatatypeConfigurationException{
Expand Down
Binary file added lib/txtmark-0.8-c0dcd373ce.jar
Binary file not shown.

0 comments on commit 94328f6

Please sign in to comment.