From: Aarni Koskela Date: Mon, 18 Jan 2016 15:09:08 +0000 (+0200) Subject: JavaScript: Add JSX/E4X tag lexing X-Git-Tag: 2.3.1~5^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fee76cf39ee4192da534fbafde6ef2e90420429;p=thirdparty%2Fbabel.git JavaScript: Add JSX/E4X tag lexing Fixes #280 --- diff --git a/babel/messages/extract.py b/babel/messages/extract.py index c2dcd5b9..153fe511 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -506,6 +506,8 @@ def extract_javascript(fileobj, keywords, comment_tags, options): :param comment_tags: a list of translator tags to search for and include in the results :param options: a dictionary of additional options (optional) + Supported options are: + * `jsx` -- set to false to disable JSX/E4X support. """ from babel.messages.jslexer import tokenize, unquote_string funcname = message_lineno = None @@ -517,7 +519,7 @@ def extract_javascript(fileobj, keywords, comment_tags, options): last_token = None call_stack = -1 - for token in tokenize(fileobj.read().decode(encoding)): + for token in tokenize(fileobj.read().decode(encoding), jsx=options.get("jsx", True)): if token.type == 'operator' and token.value == '(': if funcname: message_lineno = token.lineno diff --git a/babel/messages/jslexer.py b/babel/messages/jslexer.py index 282d294f..32500676 100644 --- a/babel/messages/jslexer.py +++ b/babel/messages/jslexer.py @@ -31,7 +31,7 @@ name_re = re.compile(r'(\$+\w*|[^\W\d]\w*)(?u)') Token = namedtuple('Token', 'type value lineno') -rules = [ +_rules = [ (None, re.compile(r'\s+(?u)')), (None, re.compile(r'