Skip to content

Instantly share code, notes, and snippets.

@py
Created November 21, 2013 01:38
Show Gist options
  • Save py/7574625 to your computer and use it in GitHub Desktop.
Save py/7574625 to your computer and use it in GitHub Desktop.
Freeplane export xsl: Converts mindmap into markdown
<?xml version="1.0" encoding="UTF-8" ?>
<!--
MINDMAPEXPORTFILTER md;markdown Markdown
: This code released under the GPL. :
(http://www.gnu.org/copyleft/gpl.html)
Document : mm2markdown.xsl
Created on : 2013-11-20
Author : Peter Yates
Description: transforms freeplane mm format to markdown. Feel free to
customize it while leaving the ancient authors mentioned. thank you
Based on mm2text.xsl by joerg feuerhake ([email protected])
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no"/>
<xsl:strip-space elements="map node" />
<xsl:key name="refid" match="node" use="@ID" />
<xsl:template match="/map">
<xsl:apply-templates select="node"/>
</xsl:template>
<xsl:template match="richcontent">
<xsl:if test="@TYPE='DETAILS'">
<xsl:text>"After details"</xsl:text>
</xsl:if>
<xsl:if test="@TYPE='NOTE'">
</xsl:if>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<xsl:template match="child::text()">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="node">
<xsl:variable name ="dep" select="count(ancestor::*)" />
<xsl:value-of select="substring('###########################',1,$dep)" />
<xsl:text> </xsl:text>
<xsl:if test="@TEXT">
<xsl:value-of select="normalize-space(@TEXT)" />
<xsl:text>&#xA;</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:apply-templates select="richcontent[@TYPE='NODE']"/>
<xsl:apply-templates select="richcontent[@TYPE='DETAILS']"/>
<xsl:apply-templates select="richcontent[@TYPE='NOTE']"/>
<xsl:text>&#xA;</xsl:text>
<xsl:apply-templates select="node"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment