[task] Markdown transformation TODO

Description

mdt is markdown transformer task that allow to:

Markdownt task parameters

Attribute Description Value Required
file input file .markdown yes
tofile output file . yes
template freemarker template .ftl yes
overwrite overwrite output file true by default no

Examples

Rewrite markdown file

file.md

  • input file
# Title1

## Title2

Content

build.xml

  • ant file:
<project name="bidji-mdt" xmlns:bj="antlib:org.bidji.taskdefs">
<target name="rewrite" description="rewrite markdown">		
	<bj:mdt file="file.md" tofile="res.markdown" template="rewrite.ftl" overwrite="true"/>
</target>
</project>

rewrite.ftl

  • freemarker file
{
[#foreach property in markdown?api.properties()]
[#if property.is_string()]
  "${property.key()}": "${property.as_string()}"[#if !property?is_last],[/#if]
[#elseif property.is_number()]
  "${property.key()}": ${property.as_number()}[#if !property?is_last],[/#if]
[#elseif property.is_boolean()]
  "${property.key()}": ${property.as_boolean()?c}[#if !property?is_last],[/#if] [#-- or myBool?string('yes', 'no') --]
[#elseif property.is_object()]
  "${property.key()}": ${property.as_object()}[#if !property?is_last],[/#if]   
[#elseif property.is_array()]
  "${property.key()}": ${property.as_array()}[#if !property?is_last],[/#if]    
[/#if]
[/#foreach]
}