61 | 61 |
argparser.add_argument('--input-refdexes', metavar='FILENAME', type=str,
|
62 | 62 |
help='Load these JSON files as the reference-style links index before processing'
|
63 | 63 |
)
|
|
64 |
argparser.add_argument('--input-refdex-filename-prefix', type=str, default=None,
|
|
65 |
help='After loading refdexes, prepend this to filename of each refdex'
|
|
66 |
)
|
64 | 67 |
argparser.add_argument('--output-refdex', action='store_true',
|
65 | 68 |
help='Construct reference-style links index from the entries and write it to stdout as JSON'
|
66 | 69 |
)
|
67 | |
argparser.add_argument('--input-refdex-filename-prefix', type=str, default=None,
|
68 | |
help='After loading refdexes, prepend this to filename of each refdex'
|
|
70 |
argparser.add_argument('--output-refdex-index', action='store_true',
|
|
71 |
help='Construct a Markdown document from resulting refdex and write it to stdout'
|
69 | 72 |
)
|
70 | 73 |
|
71 | 74 |
argparser.add_argument('--limit', metavar='COUNT', type=int, default=None,
|
|
106 | 109 |
sys.exit(1)
|
107 | 110 |
|
108 | 111 |
### processing: collect refdex phase
|
109 | |
# NOTE: we only run this if we were asked to output a refdex -
|
|
112 |
# NOTE: we only run this if we were asked to output a refdex or an index-
|
110 | 113 |
# this is to prevent scurrilous insertion of refdex entries when rewriting.
|
111 | 114 |
|
112 | |
if options.output_refdex:
|
|
115 |
if options.output_refdex or options.output_refdex_index:
|
113 | 116 |
for document in documents:
|
114 | 117 |
for section in document.sections:
|
115 | 118 |
refdex[section.title] = {
|
|
127 | 130 |
|
128 | 131 |
if options.output_refdex:
|
129 | 132 |
sys.stdout.write(json.dumps(refdex, indent=4, sort_keys=True))
|
|
133 |
|
|
134 |
if options.output_refdex_index:
|
|
135 |
from feedmark.formats.markdown import generate_index_from_refdex
|
|
136 |
index_contents = generate_index_from_refdex(refdex)
|
|
137 |
sys.stdout.write(index_contents)
|
130 | 138 |
|
131 | 139 |
if options.dump_entries:
|
132 | 140 |
for document in documents:
|