From 58e5d1b83d8162be287c8756b70612a34436cd32 Mon Sep 17 00:00:00 2001 From: ske087 Date: Thu, 24 Jul 2025 19:06:21 +0300 Subject: [PATCH] feat: Improve adventure story text parsing and keyword extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Text Processing Improvements: - Better separation of keywords from actual story text - Extract standalone keywords before

patterns - Remove keywords from main text display to show only story content - Handle both **keyword** patterns and standalone keyword lines - Clean up multiple
tags for better formatting User Experience: - Keywords now display as tags above story sections - Story text shows only the narrative content without keyword clutter - Example: 'Transalpina Ciungetu Stana lui stefan

Așa am pornit...' now shows keywords as tags and only 'Așa am pornit...' as story text - Better visual separation between metadata and story content Technical: - Improved Jinja2 template logic for text parsing - Added text length and word count heuristics for keyword detection - Enhanced text cleaning and formatting - Fixed template syntax errors from previous edits --- app/templates/community/post_detail.html | 46 +++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/app/templates/community/post_detail.html b/app/templates/community/post_detail.html index a29ecab..c65a3e7 100644 --- a/app/templates/community/post_detail.html +++ b/app/templates/community/post_detail.html @@ -108,33 +108,61 @@
{% set section_text = section.strip() %} - + {% set keywords = [] %} {% set clean_text = section_text %} - + {% if '**' in section_text %} {% set parts = section_text.split('**') %} {% set clean_parts = [] %} {% for i in range(parts|length) %} {% if i % 2 == 1 %} - {% set _ = keywords.append(parts[i]) %} - {% set _ = clean_parts.append(parts[i]) %} + + {% set _ = keywords.append(parts[i].strip()) %} {% else %} + {% set _ = clean_parts.append(parts[i]) %} {% endif %} {% endfor %} - {% set clean_text = clean_parts|join('') %} + {% set clean_text = clean_parts|join(' ')|trim %} {% endif %} + + {% if '
' in clean_text %} + {% set text_parts = clean_text.split('
') %} + {% set first_part = text_parts[0].strip() %} + + + {% if first_part and first_part|length < 100 and ' ' in first_part %} + {% set potential_keywords = first_part.split() %} + {% if potential_keywords|length <= 5 %} + + {% for kw in potential_keywords %} + {% if kw.strip() %} + {% set _ = keywords.append(kw.strip()) %} + {% endif %} + {% endfor %} + + {% set remaining_parts = text_parts[1:] %} + {% set clean_text = remaining_parts|join('
')|trim %} + {% endif %} + {% endif %} + {% endif %} + + + {% set clean_text = clean_text.replace('


', '

').replace('

', '

').strip() %} + {% if keywords %}
{% for keyword in keywords %} - - - {{ keyword }} - + {% if keyword.strip() %} + + + {{ keyword.strip() }} + + {% endif %} {% endfor %}
{% endif %}