diff --git a/transcrypt/modules/org/transcrypt/compiler.py b/transcrypt/modules/org/transcrypt/compiler.py index 05dff4f1..23b5d98d 100644 --- a/transcrypt/modules/org/transcrypt/compiler.py +++ b/transcrypt/modules/org/transcrypt/compiler.py @@ -2061,7 +2061,7 @@ def visit_ClassDef (self, node): if self.allowDocAttribs: docString = ast.get_docstring (node) if docString: - self.emit (' .__setdoc__ (\'{}\')', docString.replace ('\n', '\\n ')) + self.emit (' .__setdoc__ (\'{}\')', docString.replace ('\n', '\\n ').replace('\'', '\\\'')) # Deal with data class var assigns, a flavor of special class var assigns if isDataClass: # Constructor + params have to be generated, no real class vars, just syntactically @@ -2747,7 +2747,7 @@ def pushPropertyAccessor(functionName): if self.allowDocAttribs: docString = ast.get_docstring (node) if docString: - self.emit (' .__setdoc__ (\'{}\')', docString.replace ('\n', '\\n ')) + self.emit (' .__setdoc__ (\'{}\')', docString.replace ('\n', '\\n ').replace('\'', '\\\'')) if decorate: @@ -3102,7 +3102,7 @@ def visit_Module (self, node): # Insert docstring at hoist location, further hoists are PRE(!)pended if self.allowDocAttribs and docString: - self.emit ('export var __doc__ = \'{}\';\n', docString.replace ('\n', '\\n')) + self.emit ('export var __doc__ = \'{}\';\n', docString.replace ('\n', '\\n').replace ('\'', '\\\'')) ''' Make the globals () function work as well as possible in conjunction with JavaScript 6 modules rather than closures