From 7c4f3bea452ec694315b8bf5a4b5862ae310da47 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 9 Dec 2018 15:43:31 +0100 Subject: [PATCH] ignore words with > 245 characters, xapian limit --- CHANGES | 3 +++ content_plugins/shortcuts.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 65dcbf3..a388963 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.3.14 2018-12-09 +- render_page_as_text ignore words > 245 characters + 0.3.13 2018-11-15 - Helping template tags. - Footnote text as span (inline). diff --git a/content_plugins/shortcuts.py b/content_plugins/shortcuts.py index ce0b269..a5918fc 100644 --- a/content_plugins/shortcuts.py +++ b/content_plugins/shortcuts.py @@ -30,4 +30,8 @@ def render_page_as_text(page, template, context_data, css_selector=None): text = re.sub('[\t ]+', ' ', text) text = re.sub(re.compile('\n +', re.DOTALL), '\n', text) text = re.sub(re.compile('\n+', re.DOTALL), '\n', text) - return text + content = [] + for word in text.split(' '): + if len(word) <= 245: + content += [word] + return ' '.join(content)