Commit 9ae055f8 authored by Andreas Jung's avatar Andreas Jung

added locale support

parent 1843caf0
...@@ -205,9 +205,11 @@ Special symbology is used to indicate special constructs: ...@@ -205,9 +205,11 @@ Special symbology is used to indicate special constructs:
''' '''
import ts_regex, regex import ts_regex
import regex
from ts_regex import gsub from ts_regex import gsub
from string import split, join, strip, find from string import split, join, strip, find
import string
def untabify(aString, def untabify(aString,
indent_tab=ts_regex.compile('\(\n\|^\)\( *\)\t').search_group, indent_tab=ts_regex.compile('\(\n\|^\)\( *\)\t').search_group,
...@@ -366,8 +368,8 @@ class StructuredText: ...@@ -366,8 +368,8 @@ class StructuredText:
aStructuredString = gsub( aStructuredString = gsub(
'\"\([^\"\0]+\)\":' # title: <"text":> '\"\([^\"\0]+\)\":' # title: <"text":>
+ ('\([-:a-zA-Z0-9_,./?=@#~&]+%s\)' + ('\([-:%s0-9_,./?=@#~&]+%s\)'
% not_punctuation_or_whitespace) % (string.letters,not_punctuation_or_whitespace))
+ optional_trailing_punctuation + optional_trailing_punctuation
+ trailing_space, + trailing_space,
'<a href="\\2">\\1</a>\\4\\5\\6', '<a href="\\2">\\1</a>\\4\\5\\6',
...@@ -375,8 +377,8 @@ class StructuredText: ...@@ -375,8 +377,8 @@ class StructuredText:
aStructuredString = gsub( aStructuredString = gsub(
'\"\([^\"\0]+\)\",[\0- ]+' # title: <"text", > '\"\([^\"\0]+\)\",[\0- ]+' # title: <"text", >
+ ('\([a-zA-Z]*:[-:a-zA-Z0-9_,./?=@#~&]*%s\)' + ('\([%s]*:[-:%s0-9_,./?=@#~&]*%s\)'
% not_punctuation_or_whitespace) % (string.letters,string.letters,not_punctuation_or_whitespace))
+ optional_trailing_punctuation + optional_trailing_punctuation
+ trailing_space, + trailing_space,
'<a href="\\2">\\1</a>\\4\\5\\6', '<a href="\\2">\\1</a>\\4\\5\\6',
...@@ -492,7 +494,7 @@ class HTML(StructuredText): ...@@ -492,7 +494,7 @@ class HTML(StructuredText):
).match_group, ).match_group,
nl=ts_regex.compile('\n').search, nl=ts_regex.compile('\n').search,
ol=ts_regex.compile( ol=ts_regex.compile(
'[ \t]*\(\([0-9]+\|[a-zA-Z]+\)[.)]\)+[ \t\n]+\([^\0]*\|$\)' '[ \t]*\(\([0-9]+\|[%s]+\)[.)]\)+[ \t\n]+\([^\0]*\|$\)' % string.letters
).match_group, ).match_group,
olp=ts_regex.compile('[ \t]*([0-9]+)[ \t\n]+\([^\0]*\|$\)' olp=ts_regex.compile('[ \t]*([0-9]+)[ \t\n]+\([^\0]*\|$\)'
).match_group, ).match_group,
...@@ -564,12 +566,12 @@ def html_quote(v, ...@@ -564,12 +566,12 @@ def html_quote(v,
def html_with_references(text, level=1): def html_with_references(text, level=1):
text = gsub( text = gsub(
'[\0\n]\.\. \[\([0-9_a-zA-Z-]+\)\]', '[\0\n]\.\. \[\([0-9_%s-]+\)\]' % string.letters,
'\n <a name="\\1">[\\1]</a>', '\n <a name="\\1">[\\1]</a>',
text) text)
text = gsub( text = gsub(
'\([\0- ,]\)\[\([0-9_a-zA-Z-]+\)\]\([\0- ,.:]\)', '\([\0- ,]\)\[\([0-9_%s-]+\)\]\([\0- ,.:]\)' % string.letters,
'\\1<a href="#\\2">[\\2]</a>\\3', '\\1<a href="#\\2">[\\2]</a>\\3',
text) text)
...@@ -584,7 +586,7 @@ def html_with_references(text, level=1): ...@@ -584,7 +586,7 @@ def html_with_references(text, level=1):
def main(): def main():
import sys, getopt import sys, getopt
opts,args=getopt.getopt(sys.argv[1:],'tw') opts,args=getopt.getopt(sys.argv[1:],'twl')
if args: if args:
[infile]=args [infile]=args
...@@ -597,6 +599,10 @@ def main(): ...@@ -597,6 +599,10 @@ def main():
if filter(lambda o: o[0]=='-w', opts): if filter(lambda o: o[0]=='-w', opts):
print 'Content-Type: text/html\n' print 'Content-Type: text/html\n'
if filter(lambda o: o[0]=='-l', opts):
import locale
locale.setlocale(locale.LC_ALL,"")
if s[:2]=='#!': if s[:2]=='#!':
s=ts_regex.sub('^#![^\n]+','',s) s=ts_regex.sub('^#![^\n]+','',s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment