Groovy Documentation

griffon.plugins.markdown
[Groovy] Class MarkdownProcessor

java.lang.Object
  griffon.plugins.markdown.MarkdownProcessor

class MarkdownProcessor
extends Object

Authors:
Ted Naleid
Andres Almiray


Field Summary
private String baseUri

private static int pegdownExtensions

private org.pegdown.PegDownProcessor processor

private ReentrantLock processorLock

private com.overzealous.remark.Remark remark

private static com.overzealous.remark.Options remarkOptions

 
Constructor Summary
MarkdownProcessor()

 
Method Summary
private static Map getConfigurations(Map conf)

org.pegdown.PegDownProcessor getProcessor(Map conf = null)

Returns or creates the Pegdown processor instance used for conversion

com.overzealous.remark.Remark getRemark(Map conf = [:])

Returns or creates the Remark instance used for conversion

String htmlToMarkdown(String text, String customBaseUri = '', Map conf = null)

Converts the provided HTML back to Markdown

String markdownToHtml(String text, Map conf = null)

Converts the provided Markdown into HTML

String sanitize(String text, Map conf = null)

Utility method to strip untrusted HTML from markdown input.

private void setupConfigurations()

 
Methods inherited from class Object
notify, notifyAll, wait, wait, wait, equals, toString, hashCode, getClass
 

Field Detail

baseUri

private String baseUri


pegdownExtensions

private static int pegdownExtensions


processor

private org.pegdown.PegDownProcessor processor


processorLock

private final ReentrantLock processorLock


remark

private com.overzealous.remark.Remark remark


remarkOptions

private static com.overzealous.remark.Options remarkOptions


 
Constructor Detail

MarkdownProcessor

MarkdownProcessor()


 
Method Detail

getConfigurations

private static Map getConfigurations(Map conf)


getProcessor

org.pegdown.PegDownProcessor getProcessor(Map conf = null)
Returns or creates the Pegdown processor instance used for conversion
Parameters:
conf - Optional configuration Map to create a custom processor
Returns:
PegdownProcessor instance


getRemark

com.overzealous.remark.Remark getRemark(Map conf = [:])
Returns or creates the Remark instance used for conversion
Parameters:
conf - Optional configuration Map to create a custom remark.
Returns:
Remark instance


htmlToMarkdown

String htmlToMarkdown(String text, String customBaseUri = '', Map conf = null)
Converts the provided HTML back to Markdown

By default this method uses the shared configuration. However, the default configuration can be overridden by passing in a map or map-like object as the second argument. With a custom configuration, a new Remark is created every call to this method!

Parameters:
text - HTML-formatted text
customBaseUri - Override the default base URL
conf - If provided, creates a custom remark with unique settings just for this instance
Returns:
Markdown-formatted text


markdownToHtml

String markdownToHtml(String text, Map conf = null)
Converts the provided Markdown into HTML

By default this method uses the shared configuration. However, the default configuration can be overridden by passing in a map or map-like object as the second argument. With a custom configuration, a new Pegdown processor is created every call to this method!

Parameters:
text - Markdown-formatted text
conf - If provided, creates a custom pegdown with unique settings just for this instance
Returns:
HTML-formatted text


sanitize

String sanitize(String text, Map conf = null)
Utility method to strip untrusted HTML from markdown input.

Works by simply running the text through pegdown and back through remark.

By default this method uses the shared configuration. However, the default configuration can be overridden by passing in a map or map-like object as the second argument. With a custom configuration, new processing engines are created every call to this method!

Parameters:
text - Markdown-formatted text
conf - If provided, creates custom remark and pegdown with unique settings for this instance
Returns:
Sanitized Markdown-formatted text


setupConfigurations

private void setupConfigurations()


 

Groovy Documentation