X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=buildscripts%2Fhtml-gettext.py;h=ccfe6937c0316ec354e2116239475338951a719d;hb=03302c2f0fec2ccf1484b1ab316f90d4c17b786d;hp=a63fc3c3592649524533dc9c77af0a0ba46c145c;hpb=b9c3fa6bdea9d17ef1e93d3595e1b3f69233a49a;p=lilypond.git
diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py
index a63fc3c359..ccfe6937c0 100644
--- a/buildscripts/html-gettext.py
+++ b/buildscripts/html-gettext.py
@@ -20,79 +20,107 @@ files = args [1:]
outdir = '.'
for x in optlist:
- if x[0] == '-o':
- outdir = x[1]
+ if x[0] == '-o':
+ outdir = x[1]
double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep
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)
- 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)
- for c in html_codes:
- s = s.replace (c[0], c[1])
- return s
+ if not s:
+ return ''
+ str = whitespaces.sub (' ', s)
+ for c in html_codes:
+ 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:
+ str = str.replace (c[0], c[1])
+ return str
+
+link_re = re.compile (r'')
def link_gettext (m):
- return ''
+ return ''
+
+makeinfo_title_re = re.compile (r'
)?\
+(?PAppendix )?(?P[A-Z0-9.]+ | (?:<){1,2} | [^>:]+?: | |)\
+(?P(?:|?code>||[^>])+?)(?P(?(code)
|))\
+(?P (?:>){1,2} | |)
:?')
def a_href_gettext (m):
- s = ''
- if m.group(0)[-1] == ':':
- s = double_punct_char_separator + ':'
- t = ''
- if m.lastindex == 7:
- t = m.group(7)
- return '' + s
+ s = ''
+ if m.group(0)[-1] == ':':
+ s = double_punct_char_separator + ':'
+ t = ''
+ if m.group ('appendix'):
+ t = _ (m.group ('appendix'))
+ return '' + s
-def h_gettext (m):
- if m.group (3):
- s = _(m.group(3))
- else:
- s= ''
- return ')?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)
):?', a_href_gettext, page)
- page = re.sub (r'