Skip to content

Commit 64eeecc

Browse files
AlexeyMatveev686AlexeyMatveev686
AlexeyMatveev686
authored and
AlexeyMatveev686
committed
Fix bug #61079.
1 parent c9577e1 commit 64eeecc

File tree

1 file changed

+8
-3
lines changed
  • sdkjs-plugins/content/openai/scripts

1 file changed

+8
-3
lines changed

sdkjs-plugins/content/openai/scripts/code.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,15 @@
122122
throw data.error
123123

124124
let text = data.choices[0].text;
125-
// if (text.startsWith('\n'))
126-
// text = text.replace('\n\n', '\n').replace('\n', '<br>');
125+
if (!text.includes('</')) {
126+
// 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
127127

128-
// text = text.replace(/\n\n/g,'\n').replace(/\n/g,'<br>');
128+
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+
129134
window.Asc.plugin.executeMethod('PasteHtml', ['<div>'+text+'</div>']);
130135
})
131136
.catch(function(error) {

0 commit comments

Comments
 (0)