Source

grails-markdown / MarkdownGrailsPlugin.groovy

import org.pegdown.PegDownProcessor

class MarkdownGrailsPlugin {
    // the plugin version
    def version = "1.0.0.RC1"
    // the version or versions of Grails the plugin is designed for
    def grailsVersion = "1.3.5 > *"
    // the other plugins this plugin depends on
    def dependsOn = [:]
    // resources that are excluded from plugin packaging
    def pluginExcludes = [
            "grails-app/views/error.gsp"
    ]

    def author = "Ted Naleid"
    def authorEmail = "contact@naleid.com"
    def title = "Grails Markdown Plugin"

    def developers = [
            [ name: "Ted Naleid" ],
            [ name: "Phil DeJarnett" ]
    ]
    
    def description = '''\\
A Grails plugin to provide tag library and service support for markdown.  It can be used both for converting markdown into HTML, as well as converting HTML back into markdown.

You can either use the body of the tag to hold the markdown:

<markdown:renderHtml>This is a *test* of markdown.</markdown:renderHtml>

renders: 

<p>This is a <em>test</em> of markdown.</p>

Or the "text" attribute:

<markdown:renderHtml text="Yet **another** markdown test."/>

renders:

<p>Yet <strong>another</strong> markdown test.</p>

It also adds a <code>markdownToHtml()</code> method to the String class. 

See http://daringfireball.net/projects/markdown/basics for syntax basics

Thanks to @dani_latorre for the patch adding markdownToHtml functionality on the String class and Phil DeJarnett for significant changes/upgrades to Pegdown as well as the Remark html-markdown round trip functionality.


Full documentation can be seen on <a href="https://bitbucket.org/tednaleid/grails-markdown"> the bitbucket source repo</a>.
'''

    // URL to the plugin's documentation
    def documentation = "https://bitbucket.org/tednaleid/grails-markdown"

    def issueManagement = [ system: 'bitbucket', url: 'https://bitbucket.org/tednaleid/grails-markdown/issues' ]
    
	def doWithDynamicMethods = { ctx ->
		String.metaClass.markdownToHtml = {
			ctx.markdownService.markdown(delegate)
    	}
		
		String.metaClass.htmlToMarkdown = {
			ctx.markdownService.htmlToMarkdown(delegate)
    	}
		
		// allow backwards-compatible markdownService.processor.markdown(text)
		PegDownProcessor.metaClass.markdown = { text ->
			delegate.markdownToHtml(text.toString())
		}
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.