Skip to content

Commit 95f9db7

Browse files
committed
Quartz sync: Jun 5, 2025, 11:35 PM
1 parent 432a80b commit 95f9db7

File tree

5 files changed

+169
-67
lines changed

5 files changed

+169
-67
lines changed

content/z-index/Guideline.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description:
33
created: 2023-12-01
4-
modified: 2025-06-04
4+
modified: 2025-06-05
55
status:
66
- 🗺️
77
tags:
@@ -83,7 +83,7 @@ markmap:
8383
* ...
8484

8585
# Quartz Frontmatter
86-
```
86+
```text
8787
title: Title of the page
8888
description: Description of the page used for link previews.
8989
date: 2025-05-01
@@ -161,7 +161,7 @@ draft: true
161161
- [ ] Subtask 1
162162

163163
## Horizontal rule
164-
```
164+
```text
165165
***
166166
****
167167
* * *
@@ -203,7 +203,7 @@ int main() {
203203
[^2]
204204
[^note]
205205
-
206-
```
206+
```text
207207
This is a simple footnote[^1].[^1][^1]
208208
[^2]
209209
[^note]
@@ -216,7 +216,7 @@ int main() {
216216

217217
- You can also use inline footnotes. ^[This is an inline footnote.]
218218
-
219-
```
219+
```text
220220
You can also use inline footnotes. ^[This is an inline footnote.]
221221
```
222222

quartz/components/scripts/slide.inline.ts

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
import { mouseEnterHandler, clearActivePopover } from './popover.inline'
22
import { SlideOptions } from '../Slide'
33

4+
function addClipboard() {
5+
const svgCopy =
6+
'<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg>'
7+
const svgCheck =
8+
'<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" fill="rgb(63, 185, 80)" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>'
9+
10+
const els = document.getElementsByTagName("pre")
11+
for (let i = 0; i < els.length; i++) {
12+
const button = els[i].querySelector(".clipboard-button") as HTMLButtonElement | null
13+
const codeBlock = els[i].getElementsByTagName("code")[0]
14+
15+
if (!button || !codeBlock) continue
16+
17+
const source = (
18+
codeBlock.dataset.clipboard ? JSON.parse(codeBlock.dataset.clipboard) : codeBlock.innerText
19+
).replace(/\n\n/g, "\n")
20+
21+
function onClick() {
22+
navigator.clipboard.writeText(source).then(
23+
() => {
24+
if (button) {
25+
button.blur()
26+
button.innerHTML = svgCheck
27+
setTimeout(() => {
28+
button.innerHTML = svgCopy;
29+
button.style.borderColor = ""
30+
}, 2000)
31+
}
32+
},
33+
(error) => console.error(error),
34+
)
35+
}
36+
37+
button.addEventListener("click", onClick)
38+
window.addCleanup(() => button.removeEventListener("click", onClick))
39+
}
40+
}
41+
442
function renderPopoverInSlide() {
543
const mindmapLinks = document.querySelectorAll(".remark-slide-content a.internal") as NodeListOf<HTMLAnchorElement>
644
for (const link of mindmapLinks) {
@@ -79,8 +117,11 @@ function renderMermaidInSlide() {
79117
})
80118
}
81119

120+
82121
function anchorBlank(html: string): string {
83-
return html.replace(/<a\b([^>]*?)>/g, '<a $1 target="_blank">')
122+
// return html.replace(/<a\b([^>]*?)>/g, '<a $1 target="_blank">')
123+
// return html.replace(/(?<!<sup>)<a\b([^>]*?)>/g, '<a $1 target="_blank">')
124+
return html
84125
}
85126

86127
function unwrapSlideNote(html: string): string {
@@ -94,11 +135,7 @@ function unwrapFootnotesSection(html: string): string {
94135
)
95136
}
96137

97-
function collapseSeparators(input: string): string {
98-
return input.replace(/(?:\n*\s*---\s*\n*){2,}/g, '\n---\n')
99-
}
100-
101-
function injectSeparators(html: string, separator = "\n---\n"): string {
138+
function injectSeparators(html: string, separator: string): string {
102139
let firstHeadingInjected = false
103140

104141
return html
@@ -113,6 +150,45 @@ function injectSeparators(html: string, separator = "\n---\n"): string {
113150
})
114151
}
115152

153+
function handleFootnote(data: string, separator: string) {
154+
const slides = data.split(separator)
155+
const refIndexMap = new Map<string, number>()
156+
157+
slides.forEach((slide, index) => {
158+
const regex = /<sup><a [^>]*?id="(user-content-fnref[^"]+)"/g
159+
160+
let match
161+
while ((match = regex.exec(slide)) !== null) {
162+
const id = match[1]
163+
refIndexMap.set(`#${id}`, index + 1)
164+
}
165+
166+
const hrefRegex = /<sup><a href="(#user-content-fn[^"]+)"/g
167+
slide = slide.replace(hrefRegex, () => {
168+
return `<sup><a href="${window.location.pathname}#${slides.length}"`
169+
})
170+
171+
// const refRegex = /<sup><a\s+[^>]*?href="([^"]+)"[^>]*?id="user-content-fnref-([\d-]+)"[^>]*?>.*?<\/a><\/sup>/g
172+
// slide = slide.replace(refRegex, (_, href, refText) => {
173+
// return `<sup><a href="${window.location.pathname}#${slides.length}">${refText}</a></sup>`
174+
// })
175+
176+
slides[index] = slide
177+
})
178+
179+
slides[slides.length - 1] = slides[slides.length - 1].replace(
180+
/<a\s+([^>]*?)href="(#user-content-fn[^"]+)"([^>]*)>/g,
181+
(fullMatch, beforeHref, href, afterHref) => {
182+
if (refIndexMap.has(href)) {
183+
return `<a ${beforeHref}href="${window.location.pathname}#${refIndexMap.get(href)}"${afterHref}>`
184+
}
185+
return fullMatch
186+
}
187+
)
188+
189+
return slides.join("\n---\n")
190+
}
191+
116192
function appendRemark(option: SlideOptions) {
117193

118194
const header = `${document.querySelector(".page-header h1.article-title")?.outerHTML}`
@@ -122,17 +198,23 @@ function appendRemark(option: SlideOptions) {
122198
console.warn("No header found in the document. Cannot render slide.")
123199
return;
124200
}
201+
const separator = "\n---\n<div id=\"inject-slide\"></div>";
125202

126203
const body = document.querySelector(".center article")?.innerHTML
127-
const data = anchorBlank(
128-
unwrapSlideNote(
129-
unwrapFootnotesSection(
130-
collapseSeparators(
131-
injectSeparators(header + tags + body)
204+
205+
// sorry callback hell
206+
const data =
207+
anchorBlank(
208+
unwrapSlideNote(
209+
unwrapFootnotesSection(
210+
handleFootnote(
211+
injectSeparators(header + tags + body, separator),
212+
separator
213+
)
132214
)
133215
)
134216
)
135-
)
217+
136218
document.body.innerHTML = ""
137219

138220
const script = document.createElement("script")
@@ -147,6 +229,7 @@ function appendRemark(option: SlideOptions) {
147229
() => {
148230
renderMermaidInSlide()
149231
renderPopoverInSlide()
232+
addClipboard()
150233
}
151234
)
152235
}

quartz/components/styles/mindmap.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
code {
2626
border-radius: 3px;
27-
padding: 0;
27+
padding: 7px;
28+
background-color: var(--shiki-light-bg);
29+
color: var(--shiki-light);
2830
}
2931

3032
img {

quartz/static/scripts/slide.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,7 +3733,7 @@ function(hljs){
37333733

37343734
// общий паттерн для определения идентификаторов
37353735
var UNDERSCORE_IDENT_RE = '[A-Za-zА-Яа-яёЁ_][A-Za-zА-Яа-яёЁ_0-9]+';
3736-
3736+
37373737
// v7 уникальные ключевые слова, отсутствующие в v8 ==> keyword
37383738
var v7_keywords =
37393739
'далее ';
@@ -3745,7 +3745,7 @@ function(hljs){
37453745

37463746
// keyword : ключевые слова
37473747
var KEYWORD = v7_keywords + v8_keywords;
3748-
3748+
37493749
// v7 уникальные директивы, отсутствующие в v8 ==> meta-keyword
37503750
var v7_meta_keywords =
37513751
'загрузитьизфайла ';
@@ -3762,7 +3762,7 @@ function(hljs){
37623762
// v7 системные константы ==> built_in
37633763
var v7_system_constants =
37643764
'разделительстраниц разделительстрок символтабуляции ';
3765-
3765+
37663766
// v7 уникальные методы глобального контекста, отсутствующие в v8 ==> built_in
37673767
var v7_global_context_methods =
37683768
'ansitooem oemtoansi ввестивидсубконто ввестиперечисление ввестипериод ввестиплансчетов выбранныйплансчетов ' +
@@ -3776,7 +3776,7 @@ function(hljs){
37763776
'префиксавтонумерации пропись пустоезначение разм разобратьпозициюдокумента рассчитатьрегистрына ' +
37773777
'рассчитатьрегистрыпо симв создатьобъект статусвозврата стрколичествострок сформироватьпозициюдокумента ' +
37783778
'счетпокоду текущеевремя типзначения типзначениястр установитьтана установитьтапо фиксшаблон шаблон ';
3779-
3779+
37803780
// v8 методы глобального контекста ==> built_in
37813781
var v8_global_context_methods =
37823782
'acos asin atan base64значение base64строка cos exp log log10 pow sin sqrt tan xmlзначение xmlстрока ' +
@@ -3871,7 +3871,7 @@ function(hljs){
38713871
v7_system_constants +
38723872
v7_global_context_methods + v8_global_context_methods +
38733873
v8_global_context_property;
3874-
3874+
38753875
// v8 системные наборы значений ==> class
38763876
var v8_system_sets_of_values =
38773877
'webцвета windowsцвета windowsшрифты библиотекакартинок рамкистиля символы цветастиля шрифтыстиля ';
@@ -4023,7 +4023,7 @@ function(hljs){
40234023
'кодировкаименфайловвzipфайле методсжатияzip методшифрованияzip режимвосстановленияпутейфайловzip режимобработкиподкаталоговzip ' +
40244024
'режимсохраненияпутейzip уровеньсжатияzip ';
40254025

4026-
// v8 системные перечисления -
4026+
// v8 системные перечисления -
40274027
// Блокировка данных, Фоновые задания, Автоматизированное тестирование,
40284028
// Доставляемые уведомления, Встроенные покупки, Интернет, Работа с двоичными данными ==> class
40294029
var v8_system_enums_other =
@@ -4142,7 +4142,7 @@ function(hljs){
41424142

41434143
// literal : примитивные типы
41444144
var LITERAL = 'null истина ложь неопределено';
4145-
4145+
41464146
// number : числа
41474147
var NUMBERS = hljs.inherit(hljs.NUMBER_MODE);
41484148

@@ -4163,10 +4163,10 @@ function(hljs){
41634163
}
41644164
]
41654165
};
4166-
4166+
41674167
// comment : комментарии
41684168
var COMMENTS = hljs.inherit(hljs.C_LINE_COMMENT_MODE);
4169-
4169+
41704170
// meta : инструкции препроцессора, директивы компиляции
41714171
var META = {
41724172
className: 'meta',
@@ -4177,13 +4177,13 @@ function(hljs){
41774177
COMMENTS
41784178
]
41794179
};
4180-
4180+
41814181
// symbol : метка goto
41824182
var SYMBOL = {
41834183
className: 'symbol',
41844184
begin: '~', end: ';|:', excludeEnd: true
4185-
};
4186-
4185+
};
4186+
41874187
// function : объявление процедур и функций
41884188
var FUNCTION = {
41894189
className: 'function',
@@ -4235,7 +4235,7 @@ function(hljs){
42354235
NUMBERS,
42364236
STRINGS,
42374237
DATE
4238-
]
4238+
]
42394239
}
42404240
}},{name:"abnf",create:/*
42414241
Language: Augmented Backus-Naur Form
@@ -5643,7 +5643,7 @@ function(hljs) {
56435643
]
56445644
},
56455645
{
5646-
className: 'meta',
5646+
className: 'meta',
56475647
begin: '^\\s*#\\w+', end:'$',
56485648
relevance: 0
56495649
},
@@ -28385,40 +28385,40 @@ function highlightCodeBlocks (content, slideshow) {
2838528385
highlightInline = slideshow.getHighlightInlineCode(),
2838628386
meta;
2838728387

28388-
codeBlocks.forEach(function (block) {
28389-
if (block.className === '') {
28390-
block.className = slideshow.getHighlightLanguage();
28391-
}
28388+
// codeBlocks.forEach(function (block) {
28389+
// if (block.className === '') {
28390+
// block.className = slideshow.getHighlightLanguage();
28391+
// }
2839228392

28393-
if (block.parentElement.tagName !== 'PRE') {
28394-
utils.addClass(block, 'remark-inline-code');
28395-
if (highlightInline) {
28396-
highlighter.engine.highlightBlock(block, '');
28397-
}
28398-
return;
28399-
}
28393+
// if (block.parentElement.tagName !== 'PRE') {
28394+
// utils.addClass(block, 'remark-inline-code');
28395+
// if (highlightInline) {
28396+
// highlighter.engine.highlightBlock(block, '');
28397+
// }
28398+
// return;
28399+
// }
2840028400

28401-
if (highlightLines) {
28402-
meta = extractMetadata(block);
28403-
}
28401+
// if (highlightLines) {
28402+
// meta = extractMetadata(block);
28403+
// }
2840428404

28405-
if (block.className !== '') {
28406-
highlighter.engine.highlightBlock(block, ' ');
28407-
}
28405+
// if (block.className !== '') {
28406+
// highlighter.engine.highlightBlock(block, ' ');
28407+
// }
2840828408

28409-
wrapLines(block);
28409+
// wrapLines(block);
2841028410

28411-
if (highlightLines) {
28412-
highlightBlockLines(block, meta.highlightedLines);
28413-
}
28411+
// if (highlightLines) {
28412+
// highlightBlockLines(block, meta.highlightedLines);
28413+
// }
2841428414

28415-
if (highlightSpans) {
28416-
// highlightSpans is either true or a RegExp
28417-
highlightBlockSpans(block, highlightSpans);
28418-
}
28415+
// if (highlightSpans) {
28416+
// // highlightSpans is either true or a RegExp
28417+
// highlightBlockSpans(block, highlightSpans);
28418+
// }
2841928419

28420-
utils.addClass(block, 'remark-code');
28421-
});
28420+
// utils.addClass(block, 'remark-code');
28421+
// });
2842228422
}
2842328423

2842428424
function extractMetadata (block) {
@@ -28487,6 +28487,7 @@ function highlightBlockSpans (block, highlightSpans) {
2848728487
});
2848828488
});
2848928489
}
28490+
2849028491
},{"../components/slide-number/slide-number":"components/slide-number","../converter":13,"../highlighter":15,"../utils":25}],28:[function(require,module,exports){
2849128492
var SlideView = require('./slideView')
2849228493
, Timer = require('../components/timer/timer')

0 commit comments

Comments
 (0)