Refactor stripHtmlKeepLines to utilize convertBrToNewlines for improved HTML handling
This commit is contained in:
parent
c90ee66fb4
commit
4b9631db47
1 changed files with 5 additions and 1 deletions
|
|
@ -192,7 +192,7 @@ export function sanitizeHtml(input) {
|
|||
export function stripHtmlKeepLines(htmlString) {
|
||||
// Replaces <p> tags with a newline at the beginning
|
||||
// and removes all other HTML tags
|
||||
return htmlString
|
||||
return convertBrToNewlines(htmlString)
|
||||
.replace(/<p>/gi, '') // removes <p> tags
|
||||
.replace(/<\/p>/gi, '\n') // replaces </p> tags with newline
|
||||
.replace(/<[^>]*>/g, '') // removes any other HTML tags
|
||||
|
|
@ -203,6 +203,10 @@ export function convertNewlinesToBr(text) {
|
|||
return text.replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
function convertBrToNewlines(html) {
|
||||
return html.replace(/<br\s*\/?>/gi, '\n');
|
||||
}
|
||||
|
||||
// This method is used to convert the model string id used in the URL
|
||||
// to the model string used in the webpage
|
||||
export function getGPTWebModelString(model) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue