Skip to content

Commit

Permalink
new line rendering fix for code
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Jul 3, 2024
1 parent 3decba0 commit 02d2f38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
6 changes: 2 additions & 4 deletions component/src/views/chat/messages/messagesBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {ProcessedTextToSpeechConfig} from './textToSpeech/textToSpeech';
import {ElementUtils} from '../../../utils/element/elementUtils';
import {HTMLDeepChatElements} from './html/htmlDeepChatElements';
import {RemarkableConfig} from './remarkable/remarkableConfig';
import {RemarkableUtils} from './remarkable/remarkableUtils';
import {FireEvents} from '../../../utils/events/fireEvents';
import {HTMLClassUtilities} from '../../../types/html';
import {MessageStyleUtils} from './messageStyleUtils';
Expand Down Expand Up @@ -167,11 +166,10 @@ export class MessagesBase {
}

public renderText(bubbleElement: HTMLElement, text: string) {
const processedText = RemarkableUtils.replaceNewlineWithDouble(text);
bubbleElement.innerHTML = this._remarkable.render(processedText);
bubbleElement.innerHTML = this._remarkable.render(text);
// there is a bug in remarkable where text with only numbers and full stop after them causes the creation
// of a list which has no innert text and is instead prepended as a prefix in the start attribute (12.)
if (bubbleElement.innerText.trim().length === 0) bubbleElement.innerText = processedText;
if (bubbleElement.innerText.trim().length === 0) bubbleElement.innerText = text;
}

// this is mostly used for enabling highlight.js to highlight code if it downloads later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ export class RemarkableConfig {
},
html: false, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags (<br />)
breaks: false, // Convert '\n' in paragraphs into <br>
breaks: true, // Convert '\n' in paragraphs into <br>
langPrefix: 'language-', // CSS language prefix for fenced blocks
linkTarget: '_blank', // set target to open in a new tab
typographer: true, // Enable smartypants and other sweet transforms
});
} else {
return new Remarkable({
breaks: true,
linkTarget: '_blank', // set target to open in a new tab
});
}
Expand Down

This file was deleted.

0 comments on commit 02d2f38

Please sign in to comment.