Skip to content

Instantly share code, notes, and snippets.

@vladistan
Created April 23, 2014 15:38
Show Gist options
  • Save vladistan/6be48779c762ca6c1f7b to your computer and use it in GitHub Desktop.
Save vladistan/6be48779c762ca6c1f7b to your computer and use it in GitHub Desktop.
OPML to Markdown Transform
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)
@vladistan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment