We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9577e1 commit 64eeeccCopy full SHA for 64eeecc
sdkjs-plugins/content/openai/scripts/code.js
@@ -122,10 +122,15 @@
122
throw data.error
123
124
let text = data.choices[0].text;
125
- // if (text.startsWith('\n'))
126
- // text = text.replace('\n\n', '\n').replace('\n', '<br>');
+ if (!text.includes('</')) {
+ // it's necessary because "PasteHtml" method ignores "\n" and we are trying to replace it on "<br>" when we don't have a html code in answer
127
128
- // text = text.replace(/\n\n/g,'\n').replace(/\n/g,'<br>');
+ if (text.startsWith('\n'))
129
+ text = text.replace('\n\n', '\n').replace('\n', '');
130
+
131
+ text = text.replace(/\n\n/g,'\n').replace(/\n/g,'<br>');
132
+ }
133
134
window.Asc.plugin.executeMethod('PasteHtml', ['<div>'+text+'</div>']);
135
})
136
.catch(function(error) {
0 commit comments