weblate/docs/formats/markdown.rst
Michal Čihař dfa024910d feat(checks): introduce auto-safe-html
This uses the source string to detect whether HTML sanitization should happen
to gracefully handle formats like MDX which mix up HTML markup with MDX specific
markup.
2026-04-14 14:10:34 +02:00

66 lines
2.5 KiB
ReStructuredText

.. _markdown:
Markdown files
--------------
.. versionadded:: 5.0
.. include:: /snippets/format-in-development.rst
The translatable content is extracted from the Markdown files and offered for the translation.
Markdown units automatically get the ``md-text`` and ``auto-safe-html`` flags.
This keeps the unsafe HTML check active for plain text, standard HTML, and
custom elements while avoiding HTML cleanup on non-HTML angle-bracket syntax
such as MDX or JSX-like components. Use the explicit ``safe-html`` flag for
strings that are known to contain HTML and should always be sanitized,
including SVG or MathML snippets.
.. include:: /snippets/format-database-backed.rst
.. seealso::
:doc:`tt:formats/md`
Example file:
.. literalinclude:: ../../weblate/trans/tests/data/cs.md
:language: md
.. include:: /snippets/format-features/markdown-features.rst
Weblate configuration
+++++++++++++++++++++
+--------------------------------+-------------------------------------+
| Typical Weblate :ref:`component` |
+================================+=====================================+
| File mask | ``path/*.md`` |
+--------------------------------+-------------------------------------+
| Monolingual base language file | ``path/en.md`` |
+--------------------------------+-------------------------------------+
| Template for new translations | ``path/en.md`` |
+--------------------------------+-------------------------------------+
| File format | `Markdown file` |
+--------------------------------+-------------------------------------+
| File format parameters | ``markdown_merge_duplicates=True`` |
+--------------------------------+-------------------------------------+
.. _markdown-duplicates:
Handling duplicate strings
++++++++++++++++++++++++++
By default, Weblate treats each occurrence of a string as a separate
translation unit to provide line-based context. This can be problematic
in Markdown tables, where reordering rows changes the context and can
lead to translation loss.
To consolidate identical strings into a single translation unit, enable
:guilabel:`Deduplicate identical strings` in the
:ref:`component-file_format_params`.
.. note::
Enabling this option disables line-based context for the merged units,
ensuring that translations remain stable even if rows or sections
are moved within the document.