git @ Cat's Eye Technologies Chrysoberyl / 72a72d0
Have this work now (with the latest version of feedmark.) Chris Pressey 1 year, 10 months ago
1 changed file(s) with 3 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
00 import json
1 import sys
2 from subprocess import check_output
3 import re
41
5 from feedmark.main import read_document_from
62 from feedmark.checkers import Schema
7 from feedmark.formats.markdown import feedmark_htmlize
83 from feedmark.formats.markdown import feedmark_markdownize
4 from feedmark.loader import read_document_from, read_refdex_from
95
106
117 ARTICLES = (
4743 print("{}...".format(title))
4844 filename = document_name(title)
4945 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)
5647 if schema:
5748 schema_document = read_document_from("schema/{}.md".format(schema))
5849 schema = Schema(schema_document)
5950 results = schema.check_documents([document])
6051 if results:
6152 raise ValueError(json.dumps(results, indent=4, sort_keys=True))
62
6353 s = feedmark_markdownize(document, schema=schema)
6454 with open(document.filename, 'w') as f:
6555 f.write(s.encode('UTF-8'))
6656
6757
6858 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='../')
7360 rewrite_documents(refdex)