From 2426dbb9b84aeb5e31f206a19f487c8dc9444357 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 25 Aug 2023 19:06:15 +0200 Subject: [PATCH] Updates --- sourcing/edl.py | 7 +++++-- sourcing/model.py | 6 +++++- sourcing/templates/navbar-pale-fire.html | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sourcing/edl.py b/sourcing/edl.py index f5949c3..830f7e1 100644 --- a/sourcing/edl.py +++ b/sourcing/edl.py @@ -2,6 +2,7 @@ from .url import get_url, get_text from .parse import get_span, parse_span, parse_link, parse_sourcedoc_facet, xanapage_span_html, span_html, get_urls from collections import defaultdict from html import escape +from pprint import pprint from .utils import protect_start_spaces import re @@ -119,14 +120,16 @@ def fulfil_edl_with_links(edl, doc_num='', links=None, hide_all_transclusions=Fa 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 = [(start, length, num, 'transclusion', 0) 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: + pprint(source_spans) + + for start, length, num, span_type, _ in source_spans: end = start + length new_text += (escape(text[pos:start]) + span_html(span_type, num) + diff --git a/sourcing/model.py b/sourcing/model.py index ca13387..08775aa 100644 --- a/sourcing/model.py +++ b/sourcing/model.py @@ -348,7 +348,11 @@ class XanaLink(Item): link_type, _, ident = facet1[0].partition(': ') item = Item.from_external(ident, home) - ident2, start, length = parse_span(facet2[0]) + try: + ident2, start, length = parse_span(facet2[0]) + except TypeError: + return + source_of_title = SourceDoc.from_external(ident2, home) if source_of_title: return(item, source_of_title.text[start:length + start]) diff --git a/sourcing/templates/navbar-pale-fire.html b/sourcing/templates/navbar-pale-fire.html index 715a618..a2addfe 100644 --- a/sourcing/templates/navbar-pale-fire.html +++ b/sourcing/templates/navbar-pale-fire.html @@ -3,7 +3,7 @@ - Xanaflight: Three pages + Xanaflight: Pale Fire, by Nabokov