Commit f26d80dc authored by Jun Siang Cheah's avatar Jun Siang Cheah
Browse files

Merge remote-tracking branch 'upstream/dev' into feat/oauth

parents 99e7b328 f54a66b8
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -506,13 +506,36 @@ export const removeEmojis = (str) => { ...@@ -506,13 +506,36 @@ export const removeEmojis = (str) => {
return str.replace(emojiRegex, ''); return str.replace(emojiRegex, '');
}; };
export const removeFormattings = (str) => {
return str.replace(/(\*)(.*?)\1/g, '').replace(/(```)(.*?)\1/gs, '');
};
export const extractSentences = (text) => { export const extractSentences = (text) => {
// Split the paragraph into sentences based on common punctuation marks // This regular expression matches code blocks marked by triple backticks
const sentences = text.split(/(?<=[.!?])\s+/); const codeBlockRegex = /```[\s\S]*?```/g;
let codeBlocks = [];
let index = 0;
// Temporarily replace code blocks with placeholders and store the blocks separately
text = text.replace(codeBlockRegex, (match) => {
let placeholder = `\u0000${index}\u0000`; // Use a unique placeholder
codeBlocks[index++] = match;
return placeholder;
});
// Split the modified text into sentences based on common punctuation marks, avoiding these blocks
let sentences = text.split(/(?<=[.!?])\s+/);
// Restore code blocks and process sentences
sentences = sentences.map((sentence) => {
// Check if the sentence includes a placeholder for a code block
return sentence.replace(/\u0000(\d+)\u0000/g, (_, idx) => codeBlocks[idx]);
});
return sentences return sentences
.map((sentence) => removeEmojis(sentence.trim())) .map((sentence) => removeFormattings(removeEmojis(sentence.trim())))
.filter((sentence) => sentence !== ''); .filter((sentence) => sentence);
}; };
export const extractSentencesForAudio = (text) => { export const extractSentencesForAudio = (text) => {
......
This diff is collapsed.
<script> <script>
import { showSidebar } from '$lib/stores'; import { showSidebar } from '$lib/stores';
import Playground from '$lib/components/workspace/Playground.svelte'; import Playground from '$lib/components/playground/Playground.svelte';
</script> </script>
<div <div
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment