Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert an OPML outline to Markdown
$ pip install opml
$ python some_outline.opml
import codecs
import opml
import sys
INPUT = sys.argv[1]
OUTPUT = '.'.join(INPUT.split('.')[:-1] + ['md'])
with, 'r', 'utf-8') as f:
outline = opml.from_string(
blocks = []
def _extractBlocks(node):
for child in node:
if len(child) > 0:
output_content = '\n\n'.join(blocks)
with, 'w', 'utf-8') as f:
print '->', OUTPUT

This comment has been minimized.

Copy link

@domdavis domdavis commented Apr 5, 2014

I found this didn't work on my Mac (didn't like line 14 setting utf-8, despite the file being UTF-8). With the OPML files I was using this was also just output the files as plain text. I've updated the code to produce a nested markdown list here:

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