diff options
author | Philip Chimento <philip@endlessm.com> | 2015-06-18 13:57:53 -0700 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2015-06-18 13:57:53 -0700 |
commit | a2fe0c90e6cbc4d95f772f945833e5dd4255dca8 (patch) | |
tree | babfa9a46e58106e556a0e224b3ef753a04b628b /tools/eos-html-extractor | |
parent | 0e2e2b25766b33e98860b59d1363be528477519d (diff) |
Handle quotes in HTML strings
When generating the .dummy.c file, eos-html-extractor previously did not
escape quotes correctly.
[endlessm/eos-sdk#3291]
Diffstat (limited to 'tools/eos-html-extractor')
-rwxr-xr-x | tools/eos-html-extractor | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/eos-html-extractor b/tools/eos-html-extractor index ef8fc54..c7f87cb 100755 --- a/tools/eos-html-extractor +++ b/tools/eos-html-extractor @@ -10,6 +10,10 @@ import sys from bs4 import BeautifulSoup from html.parser import HTMLParser +ESCAPES = str.maketrans({ + '"': '\\"', +}) + def normalize_string(string): return re.sub(r'\s+', ' ', string.strip()) @@ -84,4 +88,4 @@ for string, line_num, optional_comment in parser.all_translatable_data: out_file.write('#line {line} "{path}"\n'.format(line=line_num, path=final_path)) if optional_comment: out_file.write('// {}\n'.format(optional_comment)) - out_file.write('_("{string}");\n'.format(string=string)) + out_file.write('_("{string}");\n'.format(string=string.translate(ESCAPES))) |