argosopentech / argosopentech/translate-html
translate-html should parse whitespace in HTML style
- Dominant language
- Python
- Stars
- 60
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
When an HTML string contains whitespace like tabs or newlines inside a tag, translate-html returns separate translations for the lines (or tab separated text). This is not consistent with the usual HTML parsing. For examples, please see https://github.com/LibreTranslate/LibreTranslate/issues/288
All parts employed in the translation work correctly, e.g. BeautifulSoup respects whitespace (and should do so) when returning the tag tree and the translation function of the single text strings correctly assumes that new lines mean new content, not knowing anymore that the string came from an HTML tag.
So, somewhere on the way the HTML code should be "minified" in order to be consistent with a browser's parsing of the code - at the cost of breaking the visual formatting of the HTML code by translation. I am not sure where this should be done best but I would suggest to do it in the translate_html function. I will create a corresponding PR.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the translate_html function and inspect how BeautifulSoup’s tag tree is passed to the translation function. Compare the whitespace behavior with the examples in LibreTranslate issue 288 and browser-style HTML parsing. Done means whitespace inside tags no longer produces separate translations, while ordinary text translation still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100