Created
April 23, 2014 15:38
-
-
Save vladistan/6be48779c762ca6c1f7b to your computer and use it in GitHub Desktop.
OPML to Markdown Transform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
declare namespace nm = "http://dblfuzzr.com/opml2md/"; | |
declare option saxon:output 'omit-xml-declaration=yes'; | |
declare function nm:lvlText($x) | |
{ | |
xs:string($x/@text) | |
}; | |
declare function nm:dumpLevel($lvl) | |
{ | |
for $x in $lvl/outline | |
return fn:concat("=! ",nm:lvlText($x)," !="," ", nm:dumpLevel("*",$x)," ") | |
}; | |
declare function nm:dumpLevel($prefix,$lvl) as xs:string | |
{ | |
fn:string-join( | |
for $x in $lvl/outline | |
return | |
("==== ", nm:lvlText($x) ,"====", | |
" "," ", | |
nm:dumpLevel($prefix," ",$x), | |
" "," " | |
) | |
) | |
}; | |
declare function nm:dumpLevel($prefix, $spc, $lvl) as xs:string | |
{ | |
if (fn:empty($lvl/outline)) then "" | |
else | |
fn:string-join( | |
for $x in $lvl/outline | |
return fn:concat( | |
$prefix, $spc, nm:lvlText($x)," ", | |
nm:dumpLevel(fn:concat($prefix,"*"),fn:concat($spc," "),$x) | |
)) | |
}; | |
nm:dumpLevel(.//body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just needed a quick transform script to convert outlines generated by OmniOutliner to MarkDown slide deck. The markdown is specific to Wiki2Beamer flavour.
http://www.omnigroup.com/omnioutliner
https://github.com/vladistan/wiki2beamer