Skip to content

Commit 3e3d7ef

Browse files
committed
Quartz sync: Jun 10, 2025, 1:33 PM
1 parent a6f4e6d commit 3e3d7ef

File tree

3 files changed

+44
-3
lines changed
  • content/Computer Science
    • 4 Data & Storage
    • 5 Software Development/Programming Language/JavaScript
  • quartz/plugins/transformers

3 files changed

+44
-3
lines changed

content/Computer Science/1 Foundations & Theory/Algorithms/DB.md renamed to content/Computer Science/4 Data & Storage/DB.md

File renamed without changes.

content/Computer Science/5 Software Development/Programming Language/JavaScript/Hoisting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description:
33
aliases:
44
created: 2025-06-09
5-
modified: 2025-06-09
5+
modified: 2025-06-10
66
---
77

88
- 호이스팅은 “선언”만 끌어올려짐, “초기화”는 아니다

quartz/plugins/transformers/ofm.ts

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ const calloutLineRegex = new RegExp(/^> *\[\!\w+\|?.*?\][+-]?.*$/gm)
140140
const tagRegex = new RegExp(
141141
/(?<=^| )#((?:[-_\p{L}\p{Emoji}\p{M}\d])+(?:\/[-_\p{L}\p{Emoji}\p{M}\d]+)*)/gu,
142142
)
143-
const blockReferenceRegex = new RegExp(/\^([-_A-Za-z0-9]+)$/g)
143+
// const blockReferenceRegex = new RegExp(/\^([-_A-Za-z0-9]+)?$/g)
144+
const blockReferenceRegex = new RegExp(/\^([-_A-Za-z0-9]+)\s*?$/g)
144145
const ytLinkRegex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
145146
const ytPlaylistLinkRegex = /[?&]list=([^#?&]*)/
146147
const videoExtensionRegex = new RegExp(/\.(mp4|webm|ogg|avi|mov|flv|wmv|mkv|mpg|mpeg|3gp|m4v)$/)
@@ -557,7 +558,6 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
557558
const blockTagTypes = new Set(["blockquote"])
558559
return (tree: HtmlRoot, file) => {
559560
file.data.blocks = {}
560-
561561
visit(tree, "element", (node, index, parent) => {
562562
if (blockTagTypes.has(node.tagName)) {
563563
const nextChild = parent?.children.at(index! + 2) as Element
@@ -619,6 +619,47 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
619619
}
620620
}
621621
}
622+
623+
const first = node.children.at(0) as Literal
624+
if (first && first.value && typeof first.value === "string") { // yoma
625+
const matches = first.value.match(blockReferenceRegex)
626+
if (matches && matches.length >= 1) {
627+
first.value = first.value.slice(0, -matches[0].length)
628+
const block = matches[0].slice(1).trim()
629+
630+
if (first.value === "") {
631+
// this is an inline block ref but the actual block
632+
// is the previous element above it
633+
let idx = (index ?? 1) - 1
634+
while (idx >= 0) {
635+
const element = parent?.children.at(idx)
636+
if (!element) break
637+
if (element.type !== "element") {
638+
idx -= 1
639+
} else {
640+
if (!Object.keys(file.data.blocks!).includes(block)) {
641+
element.properties = {
642+
...element.properties,
643+
id: block,
644+
}
645+
file.data.blocks![block] = element
646+
}
647+
return
648+
}
649+
}
650+
} else {
651+
// normal paragraph transclude
652+
if (!Object.keys(file.data.blocks!).includes(block)) {
653+
node.properties = {
654+
...node.properties,
655+
id: block,
656+
}
657+
file.data.blocks![block] = node
658+
}
659+
}
660+
}
661+
}
662+
622663
}
623664
})
624665

0 commit comments

Comments
 (0)