From 5cf27a876fc24f5b14b4fc8bdf851331910a2edb Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 26 Apr 2019 14:08:07 +0100 Subject: [PATCH] Restore xanaviewer source doc transclusions. --- sourcing/edl.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sourcing/edl.py b/sourcing/edl.py index a3a8b7f..f5949c3 100644 --- a/sourcing/edl.py +++ b/sourcing/edl.py @@ -112,7 +112,34 @@ def fulfil_edl_with_links(edl, doc_num='', links=None, hide_all_transclusions=Fa doc = ''.join(doc_spans) + for s in source: + text = protect_start_spaces(s.pop('text')) + if s['length'] > max_sourcedoc_size: + # print('{} > {}'.format(s['length'], max_sourcedoc_size)) + continue + if s['url'] in hide_transclusions: + continue + source_spans = [(start, length, num, 'transclusion') for num, (url, start, length) in spans if url == s['url']] + source_spans += source_doc_links[s['url']] + source_spans.sort() + + new_text = '' + pos = 0 + + for start, length, num, span_type in source_spans: + end = start + length + new_text += (escape(text[pos:start]) + + span_html(span_type, num) + + escape(text[start:end]) + + '') + pos = end + new_text += escape(text[pos:]) + new_text = new_text.replace('\n', '
\n') + + s['text'] = new_text + return { + 'source': source, 'doc': doc.replace('\n', '
\n'), 'span_count': len(spans), 'link_count': len(two_facet_links),