kobo / gaiden

Gaiden is a tool that makes it easy to create documentation with Markdown.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filters for each a source, a rendered html and a result html applied layout

nobeans opened this issue · comments

I want to use a filter like Grails:

when:

// GaidenConfig.groovy or filters/*.groovy
def filters = {
    def before = { String text ->
        text.replaceAll(/MY_REPLACE_TEXT_1/, '**HELLO**')
    }
    def after = {
        text.replaceAll(/<h2>MY_REPLACE_TEXT_2<\/h2>/, '<i>BYE</i>')
    }
    def afterTemplates = { // afterRender
        text.replaceAll(/TITLE/, 'GOOD')
    }
}
// hello.md
# MY_REPLACE_TEXT_1

## MY_REPLACE_TEXT_2
// layout.html
<html>
  <head>
    <title>TITLE</title>
  </head>
<body>
  $content
</body>
</html>

then:

// hello.html
<html>
  <head>
    <title>GOOD</title>
  </head>
<body>
  <h1><strong>HELLO</strong></h1>
  <i>BYE</i>
</body>
</html>