X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fhtml-gettext.py;h=6920e50d2232ae679234b40ddbefb66f266ad89d;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=aaa8888a3fdac88bcc92052a88a52aa34d17c0ab;hpb=8f9620abc8199c8d108e7f0e16e81a2c08ed5b01;p=lilypond.git
diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py
index aaa8888a3f..6920e50d22 100644
--- a/buildscripts/html-gettext.py
+++ b/buildscripts/html-gettext.py
@@ -29,37 +29,42 @@ my_gettext = langdefs.translation[lang]
html_codes = ((' -- ', ' – '),
(' --- ', ' — '),
("'", '’'))
-html2texi = {'command':
- (re.compile (r'(.*?)'),
- r'@command{\1}'),
- 'code':
- (re.compile (r'(.*?)
'),
- r'@code{\1}')
- }
-texi2html = {'command':
- (re.compile (r'@command{(.*?)}'),
- r'\1'),
- 'code':
- (re.compile (r'@code{(.*?)}'),
- r'\1
')
- }
+texi_html_conversion = {
+ 'command': {
+ 'html2texi':
+ (re.compile (r'(?:|)(.*?)(?:
|)'),
+ r'@command{\1}'),
+ 'texi2html':
+ (re.compile (r'@command{(.*?)}'),
+ r'\1
'),
+ },
+ 'code': {
+ 'html2texi':
+ (re.compile (r'(.*?)
'),
+ r'@code{\1}'),
+ 'texi2html':
+ (re.compile (r'@code{(.*?)}'),
+ r'\1
'),
+ },
+ }
+
whitespaces = re.compile (r'\s+')
def _ (s):
if not s:
return ''
- s = whitespaces.sub (' ', s)
+ str = whitespaces.sub (' ', s)
for c in html_codes:
- s = s.replace (c[1], c[0])
- for u in html2texi.values():
- s = u[0].sub (u[1], s)
- s = my_gettext (s)
- for u in texi2html.values():
- s = u[0].sub (u[1], s)
+ str = str.replace (c[1], c[0])
+ for command in texi_html_conversion:
+ d = texi_html_conversion[command]
+ str = d['html2texi'][0].sub (d['html2texi'][1], str)
+ str = my_gettext (str)
+ str = d['texi2html'][0].sub (d['texi2html'][1], str)
for c in html_codes:
- s = s.replace (c[0], c[1])
- return s
+ str = str.replace (c[0], c[1])
+ return str
link_re = re.compile (r'')
@@ -72,27 +77,28 @@ makeinfo_title_re = re.compile (r'
|))\
-(Appendix |)([A-Z0-9.]+ | (?:<){1,2} | [^:<]+?: | |)\
-(.+?)(
| (?:>){1,2} | |):?')
+a_href_re = re.compile ('(?s)[^>]*?href="[\\w.#-_]+"[^>]*>)(?P)?\
+(?PAppendix )?(?P[A-Z0-9.]+ | (?:<){1,2} | [^:]+?: | |)\
+(?P.+?)(?P(?(code)
|))(?P| (?:>){1,2} | |)
:?')
def a_href_gettext (m):
s = ''
if m.group(0)[-1] == ':':
s = double_punct_char_separator + ':'
t = ''
- if m.group (2):
- t = _ (m.group (2))
- return '' + s
+ if m.group ('appendix'):
+ t = _ (m.group ('appendix'))
+ return '' + s
-h_re = re.compile (r'