diff --git a/lib/correct-translation-content.js b/lib/correct-translation-content.js index cefb28788dfe..38948322f610 100644 --- a/lib/correct-translation-content.js +++ b/lib/correct-translation-content.js @@ -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,