Skip to content

Commit

Permalink
[#70044] account for all fence block characters when dividing into ch…
Browse files Browse the repository at this point in the history
…unks
  • Loading branch information
Trzcin committed Dec 11, 2024
1 parent 04438d8 commit 8c86421
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hooks/useText.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export const useText = ({ preview }) => {
}

const endLine = startLine + newChunk.trimLeft().split("\n").length - 1;
if (countOccurences(lastChunk?.md, /\n```/g) % 2 != 0) {
const fenceRegex = /^[`:~]{3}/gm;
if (countOccurences(lastChunk?.md, fenceRegex) % 2 != 0) {
chunks[lastChunkIdx] = { md: lastChunk.md + newChunk, startLine: lastChunk.startLine, endLine };
} else {
chunks.push({ md: newChunk, startLine, endLine });
Expand Down

0 comments on commit 8c86421

Please sign in to comment.