Have this work now (with the latest version of feedmark.)
Chris Pressey
2 years ago
0 | 0 | import json |
1 | import sys | |
2 | from subprocess import check_output | |
3 | import re | |
4 | 1 | |
5 | from feedmark.main import read_document_from | |
6 | 2 | from feedmark.checkers import Schema |
7 | from feedmark.formats.markdown import feedmark_htmlize | |
8 | 3 | from feedmark.formats.markdown import feedmark_markdownize |
4 | from feedmark.loader import read_document_from, read_refdex_from | |
9 | 5 | |
10 | 6 | |
11 | 7 | ARTICLES = ( |
47 | 43 | print("{}...".format(title)) |
48 | 44 | filename = document_name(title) |
49 | 45 | document = read_document_from(filename) |
50 | ||
51 | # TODO FIXME! | |
52 | document.reference_links = rewrite_reference_links(refdex, document.reference_links) | |
53 | for section in document.sections: | |
54 | section.reference_links = rewrite_reference_links(refdex, section.reference_links) | |
55 | ||
46 | document.rewrite_reference_links(refdex) | |
56 | 47 | if schema: |
57 | 48 | schema_document = read_document_from("schema/{}.md".format(schema)) |
58 | 49 | schema = Schema(schema_document) |
59 | 50 | results = schema.check_documents([document]) |
60 | 51 | if results: |
61 | 52 | raise ValueError(json.dumps(results, indent=4, sort_keys=True)) |
62 | ||
63 | 53 | s = feedmark_markdownize(document, schema=schema) |
64 | 54 | with open(document.filename, 'w') as f: |
65 | 55 | f.write(s.encode('UTF-8')) |
66 | 56 | |
67 | 57 | |
68 | 58 | if __name__ == '__main__': |
69 | ||
70 | with codecs.open('refdex.json', 'r', encoding='utf-8') as f: | |
71 | refdex = json.loads(f.read()) | |
72 | ||
59 | refdex = read_refdex_from(['refdex.json'], input_refdex_filename_prefix='../') | |
73 | 60 | rewrite_documents(refdex) |