1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Unbreak some Markdown tables that are all one 1 line in translations (#43523)

This commit is contained in:
Peter Bengtsson
2023-09-29 15:41:03 -04:00
committed by GitHub
parent 3b58e7f3d3
commit 02ca29eae7

View File

@@ -46,6 +46,27 @@ export function correctTranslatedContentStrings(content, englishContent, context
content = content.replaceAll('{{ 용어집.description }}', '{{ glossary.description }}')
}
// We have seen a lot of Markdown tables, that may have Liquid tags
// (like `{% ifversion ... %}`) within them lose the linebreak between
// the heading and the first row marker.
// For example:
//
// | **Sprache** | **Ökosystem** | **Manifestdatei** | **Unterstützter Abhängigkeitsbereich** | |:---|:---:|:---:|:---|{% ifversion dep
//
// The equivalent English for that is:
//
// | **Language** | **Ecosystem** | **Manifest file** | **Dependency scope supported** |
// |:---|:---:|:---:|:---|
// {%- ifversion dependency-graph-dart-support %}
//
// Let's inject these newline characters if found in the English content.
if (content.includes('| |:---|:') && englishContent.includes('|\n|:---|')) {
content = content.replaceAll('| |:---|:', '|\n|:---|:')
}
if (content.includes('|:---|{% ifversion') && englishContent.includes('|:---|\n{%- ifversion')) {
content = content.replaceAll('|:---|{% ifversion', '|:---|\n{%- ifversion')
}
// A lot of Liquid tags lose their linebreak after the `}` which can
// result in formatting problems, especially around Markdown tables.
// This code here, compares each Liquid statement, in the translation,