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 (
<Suspense fallback={<Loader />}>
{
/* <button
<button
className="btn-primary"
onClick={() =>
navigator.clipboard.writeText(JSON.stringify(elements, null, 2))}
>
copy ast
</button> */
}
</button>
{hasEscapedTOC !== undefined &&
(
<TTCMDRenderer

View File

@ -185,7 +185,7 @@ TokenIdentifiers.set("anchor", {
},
});
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) {
return {
// content: inline,

View File

@ -123,9 +123,10 @@ function filterOverlappingPBlocks(blocks: TokenMarker[]): TokenMarker[] {
// Filter out 'p' blocks that overlap with any other block
for (const otherBlock of blocks) {
if (
otherBlock !== block && (
otherBlock !== block &&
(
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