py / mm2markdown

An XSLT file to transform Freeplane mindmaps into Pandoc Markdown.
28 stars 2 forks source link

mm2markdown with heading numbering #5

Closed boulderalf closed 10 years ago

boulderalf commented 10 years ago

Hello,

I found your mm2markdown.xsl for Freeplane very helpful. Up until today I was using Freemind and some Javascript hacks and a lot of copy/paste to export a Freemind map to Markdown. I am using MarkdownPad 2 for converting markdown to PDF. Unfortunately that application does not support numbered headings so I made a small tweak to your mm2markdown.xsl file to allow Freeplane to export Markdown with automatic heading numbering. I did not want to change your existing mm2markdown.xsl so I created a new one called mm2markdown-numbering.xsl so that Freeplane users have the option of exporting numbered or non-numbered headings.

The changes are...

--- C:\personal\github_projects\mm2markdown\xslt\mm2markdown.xsl    2014-03-07 13:45:32.000000000 -0700   
+++ C:\personal\github_projects\mm2markdown\xslt\mm2markdown-numbering.xsl  2014-03-07 13:52:39.000000000 -0700   
@@ -1,15 +1,24 @@   
 <?xml version="1.0" encoding="UTF-8" ?>   

 <!--   

-MINDMAPEXPORTFILTER md;markdown Markdown   
+MINDMAPEXPORTFILTER md;markdown Markdown with numbering   

 v. 0.3   

 This code released under the GPL. : (http://www.gnu.org/copyleft/gpl.html)    

+Document : mm2markdown-numbering.xsl    
+Created on : 07 March, 2014   
+Authors : Alfred Sawatzky  alfred.sawatzky@gmail.com   
+Description: Transforms freeplane mm to markdown md and numbers the headings.   

+******************************************************************************   
+Based on mm2markdown.xsl, original notice appears below   
+******************************************************************************   
 Document : mm2markdown.xsl    
 Created on : 20 November, 2013    
 Authors : Lee Hachadoorian Lee.Hachadoorian@gmail.com and Peter Yates pyates@gmail.com   
 Description: Transforms freeplane mm to markdown md.    
 * Nodes become headings and subheadings, Notes become paragraphs.    
 * Attributes of root node become document metadata.    
@@ -174,12 +183,13 @@   
                 <!-- Create the headers from non-root node text using number signs -->   
                         <xsl:otherwise>   
                                 <xsl:text>&#xA;</xsl:text>   
                                 <xsl:call-template name="numberSign">   
                                         <xsl:with-param name="howMany" select="count(ancestor::*) - 1"/>   
                                 </xsl:call-template>   
+                                <xsl:number format=" 1 " level="multiple" count="node" from="/map/node"/>   
                         </xsl:otherwise>   
                 </xsl:choose>   
                 <xsl:text> </xsl:text>   
                 <!-- Node text -->   
                 <xsl:if test="@TEXT">   
                         <xsl:value-of select="normalize-space(@TEXT)" />     

Regards,

Alfred

py commented 10 years ago

Alfred, Thank you for your contribution and glad you find mm2markdown useful. I'll look at the merge this weekend. I've been using pandoc to convert my markdown to other formats. There's a sublime text 3 package ( https://github.com/tbfisher/sublimetext-Pandoc) that makes it really easy to edit and convert from markdown.

I'm not sure what markdownpad uses for conversion, but there is a pandoc option that automatically numbers headers in the output document:

-N, --number-sections

Number section headings in LaTeX, ConTeXt, HTML, or EPUB output. By default, sections are not numbered. Sections with class unnumbered will never be numbered, even if --number-sections is specified.

py commented 10 years ago

Alfred, I've been negligent here - sorry for the delay. Is there a way we could do this without having to maintain two files that are 95% identical?

Does the Node Numbering feature in Freeplane (Properties Panel > Core text > Node numbering) not accomplish the same thing? It is exported correctly as part of the header by mm2markdown as it stands today.

Let me know your thoughts and we can revisit.

boulderalf commented 10 years ago

Hi Peter,

I was not aware of the node numbering feature. I will try that out and let you know.

Alfred On Apr 3, 2014 9:35 AM, "Peter Yates" notifications@github.com wrote:

Alfred, I've been negligent here - sorry for the delay. Is there a way we could do this without having to maintain two files that are 95% identical?

Does the Node Numbering feature in Freeplane (Properties Panel > Core text > Node numbering) not accomplish the same thing? It is exported correctly as part of the header by mm2markdown as it stands today.

Let me know your thoughts and we can revisit.

Reply to this email directly or view it on GitHubhttps://github.com/py/mm2markdown/pull/5#issuecomment-39466254 .

boulderalf commented 10 years ago

Hi Peter,

I tried out the node numbering feature and that was exactly what I was looking for. Now I just need to figure out how to undo my pull request. Or maybe it is easier for you to just reject the pull request.

Thanks for letting me know about the Node Numbering feature.

Alfred