dokuwiki-to-hugo/src/markdown_converter.py

20 lines
451 B
Python
Raw Normal View History

from pathlib import Path
2017-01-30 16:09:23 +01:00
2017-01-12 16:48:09 +01:00
class MarkdownConverter:
converters = []
@classmethod
2017-01-30 16:09:23 +01:00
def register(cls, converter_class):
cls.converters.append(converter_class())
return converter_class
2017-01-12 16:48:09 +01:00
2017-01-12 21:45:49 +01:00
def __init__(self, file):
self.file = file
def convert(self):
text = Path(self.file).read_text()
for converter in MarkdownConverter.converters:
text = converter.convert(text)
2017-01-30 16:09:23 +01:00
return text