diff --git a/etpgrf_site/typograph/templates/typograph/index.html b/etpgrf_site/typograph/templates/typograph/index.html index e7e3ad8..503a57c 100644 --- a/etpgrf_site/typograph/templates/typograph/index.html +++ b/etpgrf_site/typograph/templates/typograph/index.html @@ -10,7 +10,6 @@ {# ГЛАВНОЕ ПОЛЕ ВВОДА: ТЕКСТ ДЛЯ ФОТОГРАФИРОВАНИЯ #}
- {# Блок настроек (Collapse) #}
{# Описание с отступом, чтобы было под текстом #}
- {# ========= #}
+ {# ========== #}
{# Группа "Кавычки" #}
{# Описание (видно, когда выключено) #}
- Прямые кавычки (") не будут заменяться на типографские («…ёлочки…» или “…лапки…”). + Прямые кавычки (") не будут заменяться на типографские («…ёлочки…» или “…лапки…”).
- {# ========= #}
+ {# ========== #}
{# Группа "Компоновка и отбивка" (Layout) #}
- {# Настройки (видны, когда включено) #}
+ {# Настройки группы "Компоновка и отбивка" (видны, когда включено) #}
@@ -85,7 +84,7 @@ не будет произведена.
-
+
{# КОЛОНКА 2 #}
{# Группа "Неразрывные пробелы" #}
@@ -96,14 +95,14 @@ Если отключено, то предлоги, союзы и артикли могут оставаться в конце строки, частицы (бы, же…) могут отрываться от слов.
- {# ========= #}
+ {# ========== #}
{# Группа "Переносы" #}
{# Настройки переносов #}
- +
{# Описание (видно, когда выключено) #}
- Замена псевдографики (стрелочки, копирайты) на спецсимволы отключена. + Замена псевдографики (стрелочки, копирайты) и обработка числовых диапазонов (10-20 → 10–20) отключена.
{# КОЛОНКА 3 #}
- {# Группа "Висячая пунктуация" #}
Висячая пунктуация
- - {# ========= #}
- {# Группа "Санитайзер" #}
- - + {# Группа "Висячая пунктуация" #}
+
+ + +
+ {# Настройки группы "Висячая пунктуация" (видны, когда включено) #}
+ +
+ {# Описание (видно, когда выключено) #}
+ Кавычки, скобки, точки и запятые не будут выноситься за границы текстового блока. +
- {# ========= #}
- {# Группа "Режим вывода" #}
+ {# ========== #}
+ {# Группа "Санитайзер" #}
+
+ + +
+ {# Настройки группы "Санитайзер" (видны, когда включено) #}
+ +
+ {# Описание группы "Санитайзер" (видно, когда выключено) #}
+ Текст будет обработан «как есть», без предварительной очистки от тегов или старой разметки. +
+
+ {# ========== #}
+ {# Режим вывода (Alpine.js) #}
@@ -154,16 +169,16 @@
diff --git a/etpgrf_site/typograph/views.py b/etpgrf_site/typograph/views.py index 8712180..75b13c0 100644 --- a/etpgrf_site/typograph/views.py +++ b/etpgrf_site/typograph/views.py @@ -15,30 +15,30 @@ def process_text(request): langs = request.POST.get(key='langs', default='ru') # 2. Собираем LayoutProcessor - layout_enabled = request.POST.get('layout') == 'on' + layout_enabled = request.POST.get(key='layout') == 'on' layout_option = False if layout_enabled: - process_units = request.POST.get('layout_units') == 'on' + process_units = request.POST.get(key='layout_units') == 'on' if process_units: - custom_units = request.POST.get('layout_units_custom', '').strip() + custom_units = request.POST.get(key='layout_units_custom', default='').strip() if custom_units: process_units = custom_units.split() layout_option = LayoutProcessor( langs=langs, - process_initials_and_acronyms=request.POST.get('layout_initials') == 'on', + process_initials_and_acronyms=request.POST.get(key='layout_initials') == 'on', process_units=process_units ) # 3. Собираем Hyphenator - hyphenation_enabled = request.POST.get('hyphenation') == 'on' + hyphenation_enabled = request.POST.get(key='hyphenation') == 'on' hyphenation_option = False if hyphenation_enabled: - max_len = request.POST.get('hyphenation_len', '15') + max_len = request.POST.get(key='hyphenation_len', default='12') try: max_len = int(max_len) except (ValueError, TypeError): - max_len = 15 # Дефолтное значение, если пришло что-то не то + max_len = 12 hyphenation_option = Hyphenator( langs=langs, @@ -46,30 +46,30 @@ def process_text(request): ) # 4. Читаем Sanitizer - sanitizer_val = request.POST.get('sanitizer', '') - sanitizer_option = None - if sanitizer_val: - sanitizer_option = sanitizer_val + sanitizer_enabled = request.POST.get(key='sanitizer_enabled', default='') + sanitizer_option = request.POST.get(key='sanitizer', default='etp') + if sanitizer_enabled and sanitizer_option not in ['etp', 'html']: + sanitizer_option = 'etp' - # 5. Собираем общие опции + # 5. Читаем Hanging Punctuation + hanging_enabled = request.POST.get(key='hanging_enabled') == 'on' + hanging_option = None + if hanging_enabled: + hanging_option = request.POST.get(key='hanging_punctuation', default='both') + + # 6. Собираем общие опции options = { 'langs': langs, 'process_html': True, - 'quotes': request.POST.get('quotes') == 'on', 'layout': layout_option, - 'unbreakables': request.POST.get('unbreakables') == 'on', + 'unbreakables': request.POST.get(key='unbreakables') == 'on', 'hyphenation': hyphenation_option, - 'symbols': request.POST.get('symbols') == 'on', - - 'hanging_punctuation': request.POST.get(key='hanging_punctuation', default='none'), + 'symbols': request.POST.get(key='symbols') == 'on', + 'hanging_punctuation': hanging_option, 'mode': request.POST.get(key='mode', default='mixed'), - 'sanitizer': sanitizer_option } - - if options['hanging_punctuation'] == 'none': - options['hanging_punctuation'] = None # Создаем экземпляр типографа typo = Typographer(**options)