ttcMD: fixes issues where paragraphs are filtered despite being a valid parent,

Fixes a greedy rx from inline-code
This commit is contained in:
Emmaline Autumn 2024-03-14 00:48:00 -06:00
parent 4615f11cfa
commit 9c04f13a42
3 changed files with 6 additions and 7 deletions

View File

@ -45,15 +45,13 @@ export const TTCMD: FC<
return ( return (
<Suspense fallback={<Loader />}> <Suspense fallback={<Loader />}>
{ <button
/* <button
className="btn-primary" className="btn-primary"
onClick={() => onClick={() =>
navigator.clipboard.writeText(JSON.stringify(elements, null, 2))} navigator.clipboard.writeText(JSON.stringify(elements, null, 2))}
> >
copy ast copy ast
</button> */ </button>
}
{hasEscapedTOC !== undefined && {hasEscapedTOC !== undefined &&
( (
<TTCMDRenderer <TTCMDRenderer

View File

@ -185,7 +185,7 @@ TokenIdentifiers.set("anchor", {
}, },
}); });
TokenIdentifiers.set("inline-code", { TokenIdentifiers.set("inline-code", {
rx: /\s?`(.{3,}|[a-z0-9]*?)`[^`a-z0-9\n]/gi, rx: /\s?`(.{3,}?|[a-z0-9]*?)`[^`a-z0-9\n]/gi,
parse(s) { parse(s) {
return { return {
// content: inline, // content: inline,

View File

@ -123,9 +123,10 @@ function filterOverlappingPBlocks(blocks: TokenMarker[]): TokenMarker[] {
// Filter out 'p' blocks that overlap with any other block // Filter out 'p' blocks that overlap with any other block
for (const otherBlock of blocks) { for (const otherBlock of blocks) {
if ( if (
otherBlock !== block && ( otherBlock !== block &&
(
otherBlock.start === block.start || otherBlock.start === block.start ||
otherBlock.end === block.end (otherBlock.end === block.end && otherBlock.start < block.start)
) )
) { ) {
return false; // Overlapping 'p' block found, filter it out return false; // Overlapping 'p' block found, filter it out