Skip to content

Commit c5293c1

Browse files
Add support for Markdown formatting too
As well as clean up some ruff related warnings...
1 parent fbe3d1c commit c5293c1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

conversion/indico_conversion/plugin.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from indico.modules.attachments.models.attachments import AttachmentType
2222
from indico.modules.events.views import WPSimpleEventDisplay
2323
from indico.util.date_time import now_utc
24+
from indico.util.string import render_markdown
2425
from indico.web.forms.base import IndicoForm
2526
from indico.web.forms.fields import IndicoPasswordField, TextListField
2627
from indico.web.forms.validators import HiddenUnless
@@ -61,7 +62,8 @@ class SettingsForm(IndicoForm):
6162
cloudconvert_conversion_notice = TextAreaField(_('PDF conversion notice'),
6263
description=_('A notice that will be shown to end users when '
6364
'converting PDF files in the upload files dialog. '
64-
'You may use basic HTML elements for formatting.'))
65+
'You may use Markdown and basic HTML elements for '
66+
'formatting.'))
6567
valid_extensions = TextListField(_('Extensions'),
6668
filters=[lambda exts: sorted({ext.lower().lstrip('.').strip() for ext in exts})],
6769
description=_('File extensions for which PDF conversion is supported. '
@@ -114,11 +116,14 @@ def _add_file_form_fields(self, form_cls, **kwargs):
114116
description = _('If enabled, your files will be converted to PDF if possible. '
115117
'The following file types can be converted: {exts}').format(exts=exts)
116118
if self.settings.get('cloudconvert_conversion_notice'):
117-
description = '{}<br>{}'.format(self.settings.get('cloudconvert_conversion_notice'),
118-
_('The following file types can be converted: {exts}').format(exts=exts))
119+
notice = Markup(render_markdown(self.settings.get('cloudconvert_conversion_notice'))) # noqa: RUF035
120+
description = Markup('{}<br>{}').format(
121+
notice,
122+
_('The following file types can be converted: {exts}').format(exts=exts)
123+
)
119124
return 'convert_to_pdf', \
120125
BooleanField(_('Convert to PDF'), widget=SwitchWidget(),
121-
description=Markup(description),
126+
description=description,
122127
default=True)
123128

124129
def _add_url_form_fields(self, form_cls, **kwargs):

0 commit comments

Comments
 (0)