Skip to content

Commit

Permalink
Unbreak some Markdown tables that are all one 1 line in translations …
Browse files Browse the repository at this point in the history
…(#43523)
  • Loading branch information
peterbe authored Sep 29, 2023
1 parent 3b58e7f commit 02ca29e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/correct-translation-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 02ca29e

Please sign in to comment.