diff --git a/packages/quicktype-core/src/language/Python/PythonRenderer.ts b/packages/quicktype-core/src/language/Python/PythonRenderer.ts index 63ec3c70d..adddd4558 100644 --- a/packages/quicktype-core/src/language/Python/PythonRenderer.ts +++ b/packages/quicktype-core/src/language/Python/PythonRenderer.ts @@ -60,11 +60,14 @@ export class PythonRenderer extends ConvenienceRenderer { protected emitDescriptionBlock(lines: Sourcelike[]): void { if (lines.length === 1) { const docstring = modifySource(content => { + if (content.startsWith('"')) { + content = ' ' + content; + } if (content.endsWith('"')) { - return content.slice(0, -1) + '\\"'; + content = content + ' '; } - return content; + return content.replace(/"/g, '\\"'); }, lines[0]); this.emitComments([{ customLines: [docstring], lineStart: '"""', lineEnd: '"""' }]); } else {