home.txt is actually _index.md
This commit is contained in:
parent
17625d6f1d
commit
f65a8b0b59
|
@ -26,14 +26,17 @@ class DokuWikiToHugo:
|
|||
def process_file(self, root, file):
|
||||
destination_dir = 'output/' + root
|
||||
source_file = root + '/' + file
|
||||
print('generating ' + destination_dir + '/' + file + '\n')
|
||||
destination_file = '_index.md' if file == 'home.txt' else os.path.splitext(file)[0] + '.md'
|
||||
|
||||
print('generating ' + destination_dir + '/' + destination_file + '\n')
|
||||
|
||||
if not os.path.exists(destination_dir):
|
||||
os.makedirs(destination_dir)
|
||||
|
||||
header = self.header_converter.create(source_file)
|
||||
converted_text = MarkdownConverter(source_file).convert()
|
||||
with open(destination_dir + '/' + file, "w") as text_file:
|
||||
|
||||
with open(destination_dir + '/' + destination_file, "w") as text_file:
|
||||
text_file.write(header)
|
||||
text_file.write('\n')
|
||||
text_file.write(converted_text)
|
||||
|
|
|
@ -13,7 +13,6 @@ class MarkdownConverter:
|
|||
|
||||
def convert(self):
|
||||
text = Path(self.file).read_text()
|
||||
# TODO solve this functional-style instead of mutating text
|
||||
for converter in MarkdownConverter.converters:
|
||||
text = converter.convert(text)
|
||||
return text
|
|
@ -0,0 +1 @@
|
|||
subdir index
|
|
@ -11,9 +11,15 @@ class TestDokuWikiToHugo(TestCase):
|
|||
def tearDown(self):
|
||||
shutil.rmtree('output')
|
||||
|
||||
def test_doku_to_hugo_converts_home_to_index_markdown_files(self):
|
||||
DokuWikiToHugo().doku_to_hugo('subdir')
|
||||
expected = Path("output/subdir/_index.md").read_text()
|
||||
|
||||
self.assertIn('subdir index', expected)
|
||||
|
||||
def test_convert_whole_dir(self):
|
||||
DokuWikiToHugo().doku_to_hugo('subdir')
|
||||
expected = Path("output/subdir/moar/dokuwiki_header_in_subdir.txt").read_text()
|
||||
expected = Path("output/subdir/moar/dokuwiki_header_in_subdir.md").read_text()
|
||||
|
||||
self.assertIn('+++', expected) # header is there, check
|
||||
self.assertIn('##### some header', expected) # some conversion done, check
|
Loading…
Reference in New Issue