diff --git a/babel/messages/extract.py b/babel/messages/extract.py index c2dcd5b99..153fe5116 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 282d294f3..32500676a 100644 --- a/babel/messages/jslexer.py +++ b/babel/messages/jslexer.py @@ -31,7 +31,7 @@ Token = namedtuple('Token', 'type value lineno') -rules = [ +_rules = [ (None, re.compile(r'\s+(?u)')), (None, re.compile(r'