Compare commits

...

10 Commits

Author SHA1 Message Date
vorpax
07a0104e0c Quartz sync: Dec 24, 2025, 11:51 AM
Some checks failed
Build and Test / build-and-test (ubuntu-latest) (push) Has been skipped
Build and Test / publish-tag (push) Has been skipped
Build and Test / build-and-test (macos-latest) (push) Has been cancelled
Build and Test / build-and-test (windows-latest) (push) Has been cancelled
Docker build & push image / build (push) Has been skipped
2025-12-24 11:51:34 +01:00
AshGrey : りす 🐿️
9c042dd717 fix(helpers): correct regex of function escapePath (#2254) 2025-12-19 11:37:53 -08:00
Rahmat Ardiansyah
bacd19c4ea feat: implement touch dragging event (#2224) 2025-12-09 13:50:04 -05:00
dependabot[bot]
722277b202 chore(deps-dev): bump the production-dependencies group with 2 updates (#2241)
Bumps the production-dependencies group with 2 updates: [esbuild](https://github.com/evanw/esbuild) and [prettier](https://github.com/prettier/prettier).


Updates `esbuild` from 0.27.0 to 0.27.1
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.27.0...v0.27.1)

Updates `prettier` from 3.7.3 to 3.7.4
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.7.3...3.7.4)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.27.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: production-dependencies
- dependency-name: prettier
  dependency-version: 3.7.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: production-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-09 13:47:09 -05:00
Rithsagea
e6cc9ba368 fix: pass mathjax macros to rehype correctly (#2218) 2025-12-06 22:51:37 -05:00
Eritque arcus
643aca5ffa fix(LaTex/render/Typst): Add stroke color to typst-doc styles (#2237)
* fix: Add stroke color to typst-doc styles

* chore: better style by override

* fix: remove * selector in CSS

* chore: remove empty line
2025-12-06 17:01:04 -05:00
うろちょろ
ec26ebcc9e feat: improve search tokenization for CJK languages (#2231)
* feat: improve search tokenization for CJK languages

Enhance the encoder function to properly tokenize CJK (Chinese, Japanese,
Korean) characters while maintaining English word tokenization. This fixes
search issues where CJK text was not searchable due to whitespace-only
splitting.

Changes:
- Tokenize CJK characters (Hiragana, Katakana, Kanji, Hangul) individually
- Preserve whitespace-based tokenization for non-CJK text
- Support mixed CJK/English content in search queries

This addresses the CJK search issues reported in #2109 where Japanese text
like "て以来" was not searchable because the encoder only split on whitespace.

Tested with Japanese, Chinese, and Korean content to verify character-level
tokenization works correctly while maintaining English search functionality.

* perf: optimize CJK search encoder with manual buffer tracking

Replace regex-based tokenization with index-based buffer management.
This improves performance by ~2.93x according to benchmark results.

- Use explicit buffer start/end indices instead of string concatenation
- Replace split(/\s+/) with direct whitespace code point checks
- Remove redundant filter() operations
- Add CJK Extension A support (U+20000-U+2A6DF)

Performance: ~878ms → ~300ms (100 iterations, mixed CJK/English text)

* test: add comprehensive unit tests for CJK search encoder

Add 21 unit tests covering:
- English word tokenization
- CJK character-level tokenization (Japanese, Korean, Chinese)
- Mixed CJK/English content
- Edge cases

All tests pass, confirming the encoder correctly handles CJK text.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 10:04:38 -08:00
dependabot[bot]
19e324d914 chore(deps): bump the production-dependencies group across 1 directory with 7 updates (#2233)
Bumps the production-dependencies group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [chokidar](https://github.com/paulmillr/chokidar) | `4.0.3` | `5.0.0` |
| [mdast-util-to-hast](https://github.com/syntax-tree/mdast-util-to-hast) | `13.2.0` | `13.2.1` |
| [pixi.js](https://github.com/pixijs/pixijs) | `8.14.1` | `8.14.3` |
| [preact](https://github.com/preactjs/preact) | `10.27.2` | `10.28.0` |
| [workerpool](https://github.com/josdejong/workerpool) | `10.0.0` | `10.0.1` |
| [prettier](https://github.com/prettier/prettier) | `3.6.2` | `3.7.3` |
| [tsx](https://github.com/privatenumber/tsx) | `4.20.6` | `4.21.0` |



Updates `chokidar` from 4.0.3 to 5.0.0
- [Release notes](https://github.com/paulmillr/chokidar/releases)
- [Commits](https://github.com/paulmillr/chokidar/compare/4.0.3...5.0.0)

Updates `mdast-util-to-hast` from 13.2.0 to 13.2.1
- [Release notes](https://github.com/syntax-tree/mdast-util-to-hast/releases)
- [Commits](https://github.com/syntax-tree/mdast-util-to-hast/compare/13.2.0...13.2.1)

Updates `pixi.js` from 8.14.1 to 8.14.3
- [Release notes](https://github.com/pixijs/pixijs/releases)
- [Commits](https://github.com/pixijs/pixijs/compare/v8.14.1...v8.14.3)

Updates `preact` from 10.27.2 to 10.28.0
- [Release notes](https://github.com/preactjs/preact/releases)
- [Commits](https://github.com/preactjs/preact/compare/10.27.2...10.28.0)

Updates `workerpool` from 10.0.0 to 10.0.1
- [Changelog](https://github.com/josdejong/workerpool/blob/master/HISTORY.md)
- [Commits](https://github.com/josdejong/workerpool/compare/v10.0.0...v10.0.1)

Updates `prettier` from 3.6.2 to 3.7.3
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.6.2...3.7.3)

Updates `tsx` from 4.20.6 to 4.21.0
- [Release notes](https://github.com/privatenumber/tsx/releases)
- [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs)
- [Commits](https://github.com/privatenumber/tsx/compare/v4.20.6...v4.21.0)

---
updated-dependencies:
- dependency-name: chokidar
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: production-dependencies
- dependency-name: mdast-util-to-hast
  dependency-version: 13.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production-dependencies
- dependency-name: pixi.js
  dependency-version: 8.14.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production-dependencies
- dependency-name: preact
  dependency-version: 10.28.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
- dependency-name: workerpool
  dependency-version: 10.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production-dependencies
- dependency-name: prettier
  dependency-version: 3.7.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
- dependency-name: tsx
  dependency-version: 4.21.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-01 17:33:43 -08:00
dependabot[bot]
368203cf85 chore(deps): bump the ci-dependencies group across 1 directory with 2 updates (#2234)
Bumps the ci-dependencies group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [rlespinasse/github-slug-action](https://github.com/rlespinasse/github-slug-action).


Updates `actions/checkout` from 5 to 6
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

Updates `rlespinasse/github-slug-action` from 5.3.0 to 5.4.0
- [Release notes](https://github.com/rlespinasse/github-slug-action/releases)
- [Commits](https://github.com/rlespinasse/github-slug-action/compare/v5.3.0...v5.4.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: ci-dependencies
- dependency-name: rlespinasse/github-slug-action
  dependency-version: 5.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: ci-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-01 17:32:52 -08:00
Nhat
13ff64db97 feat(i18n): update Vietnamese translations (#2228)
* feat(i18n): update Vietnamese translations

* Apply suggestion from @aarnphm

Co-authored-by: Aaron Pham <contact@aarnphm.xyz>

---------

Co-authored-by: Aaron Pham <contact@aarnphm.xyz>
2025-11-29 13:31:17 -05:00
16 changed files with 5474 additions and 696 deletions

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build Preview name: Build Preview
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@@ -19,7 +19,7 @@ jobs:
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
@@ -53,7 +53,7 @@ jobs:
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Node - name: Setup Node

View File

@@ -21,11 +21,11 @@ jobs:
echo "OWNER_LOWERCASE=${OWNER,,}" >> ${GITHUB_ENV} echo "OWNER_LOWERCASE=${OWNER,,}" >> ${GITHUB_ENV}
env: env:
OWNER: "${{ github.repository_owner }}" OWNER: "${{ github.repository_owner }}"
- uses: actions/checkout@v5 - uses: actions/checkout@v6
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Inject slug/short variables - name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5.3.0 uses: rlespinasse/github-slug-action@v5.4.0
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx

View File

6
content/index.md Normal file
View File

@@ -0,0 +1,6 @@
---
title: Welcome to Quartz
---
This is a blank Quartz installation.
See the [documentation](https://quartz.jzhao.xyz) for how to get started.

801
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -42,7 +42,7 @@
"@tweenjs/tween.js": "^25.0.0", "@tweenjs/tween.js": "^25.0.0",
"ansi-truncate": "^1.4.0", "ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0", "async-mutex": "^0.5.0",
"chokidar": "^4.0.3", "chokidar": "^5.0.0",
"cli-spinner": "^0.2.10", "cli-spinner": "^0.2.10",
"d3": "^7.9.0", "d3": "^7.9.0",
"esbuild-sass-plugin": "^3.3.1", "esbuild-sass-plugin": "^3.3.1",
@@ -57,12 +57,12 @@
"js-yaml": "^4.1.1", "js-yaml": "^4.1.1",
"lightningcss": "^1.30.2", "lightningcss": "^1.30.2",
"mdast-util-find-and-replace": "^3.0.2", "mdast-util-find-and-replace": "^3.0.2",
"mdast-util-to-hast": "^13.2.0", "mdast-util-to-hast": "^13.2.1",
"mdast-util-to-string": "^4.0.0", "mdast-util-to-string": "^4.0.0",
"micromorph": "^0.4.5", "micromorph": "^0.4.5",
"minimatch": "^10.1.1", "minimatch": "^10.1.1",
"pixi.js": "^8.14.1", "pixi.js": "^8.14.3",
"preact": "^10.27.2", "preact": "^10.28.0",
"preact-render-to-string": "^6.6.3", "preact-render-to-string": "^6.6.3",
"pretty-bytes": "^7.1.0", "pretty-bytes": "^7.1.0",
"pretty-time": "^1.1.0", "pretty-time": "^1.1.0",
@@ -93,7 +93,7 @@
"unified": "^11.0.5", "unified": "^11.0.5",
"unist-util-visit": "^5.0.0", "unist-util-visit": "^5.0.0",
"vfile": "^6.0.3", "vfile": "^6.0.3",
"workerpool": "^10.0.0", "workerpool": "^10.0.1",
"ws": "^8.18.3", "ws": "^8.18.3",
"yargs": "^18.0.0" "yargs": "^18.0.0"
}, },
@@ -106,9 +106,9 @@
"@types/source-map-support": "^0.5.10", "@types/source-map-support": "^0.5.10",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"@types/yargs": "^17.0.35", "@types/yargs": "^17.0.35",
"esbuild": "^0.27.0", "esbuild": "^0.27.1",
"prettier": "^3.6.2", "prettier": "^3.7.4",
"tsx": "^4.20.6", "tsx": "^4.21.0",
"typescript": "^5.9.3" "typescript": "^5.9.3"
} }
} }

4970
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,8 +7,8 @@ import fs from "fs"
export function escapePath(fp) { export function escapePath(fp) {
return fp return fp
.replace(/\\ /g, " ") // unescape spaces .replace(/\\ /g, " ") // unescape spaces
.replace(/^".*"$/, "$1") .replace(/^"(.*)"$/, "$1")
.replace(/^'.*"$/, "$1") .replace(/^'(.*)'$/, "$1")
.trim() .trim()
} }

View File

@@ -29,17 +29,31 @@ class DiagramPanZoom {
const mouseDownHandler = this.onMouseDown.bind(this) const mouseDownHandler = this.onMouseDown.bind(this)
const mouseMoveHandler = this.onMouseMove.bind(this) const mouseMoveHandler = this.onMouseMove.bind(this)
const mouseUpHandler = this.onMouseUp.bind(this) const mouseUpHandler = this.onMouseUp.bind(this)
// Touch drag events
const touchStartHandler = this.onTouchStart.bind(this)
const touchMoveHandler = this.onTouchMove.bind(this)
const touchEndHandler = this.onTouchEnd.bind(this)
const resizeHandler = this.resetTransform.bind(this) const resizeHandler = this.resetTransform.bind(this)
this.container.addEventListener("mousedown", mouseDownHandler) this.container.addEventListener("mousedown", mouseDownHandler)
document.addEventListener("mousemove", mouseMoveHandler) document.addEventListener("mousemove", mouseMoveHandler)
document.addEventListener("mouseup", mouseUpHandler) document.addEventListener("mouseup", mouseUpHandler)
this.container.addEventListener("touchstart", touchStartHandler, { passive: false })
document.addEventListener("touchmove", touchMoveHandler, { passive: false })
document.addEventListener("touchend", touchEndHandler)
window.addEventListener("resize", resizeHandler) window.addEventListener("resize", resizeHandler)
this.cleanups.push( this.cleanups.push(
() => this.container.removeEventListener("mousedown", mouseDownHandler), () => this.container.removeEventListener("mousedown", mouseDownHandler),
() => document.removeEventListener("mousemove", mouseMoveHandler), () => document.removeEventListener("mousemove", mouseMoveHandler),
() => document.removeEventListener("mouseup", mouseUpHandler), () => document.removeEventListener("mouseup", mouseUpHandler),
() => this.container.removeEventListener("touchstart", touchStartHandler),
() => document.removeEventListener("touchmove", touchMoveHandler),
() => document.removeEventListener("touchend", touchEndHandler),
() => window.removeEventListener("resize", resizeHandler), () => window.removeEventListener("resize", resizeHandler),
) )
} }
@@ -99,6 +113,30 @@ class DiagramPanZoom {
this.container.style.cursor = "grab" this.container.style.cursor = "grab"
} }
private onTouchStart(e: TouchEvent) {
if (e.touches.length !== 1) return
this.isDragging = true
const touch = e.touches[0]
this.startPan = { x: touch.clientX - this.currentPan.x, y: touch.clientY - this.currentPan.y }
}
private onTouchMove(e: TouchEvent) {
if (!this.isDragging || e.touches.length !== 1) return
e.preventDefault() // Prevent scrolling
const touch = e.touches[0]
this.currentPan = {
x: touch.clientX - this.startPan.x,
y: touch.clientY - this.startPan.y,
}
this.updateTransform()
}
private onTouchEnd() {
this.isDragging = false
}
private zoom(delta: number) { private zoom(delta: number) {
const newScale = Math.min(Math.max(this.scale + delta, this.MIN_SCALE), this.MAX_SCALE) const newScale = Math.min(Math.max(this.scale + delta, this.MIN_SCALE), this.MAX_SCALE)
@@ -120,11 +158,15 @@ class DiagramPanZoom {
} }
private resetTransform() { private resetTransform() {
this.scale = 1
const svg = this.content.querySelector("svg")! const svg = this.content.querySelector("svg")!
const rect = svg.getBoundingClientRect()
const width = rect.width / this.scale
const height = rect.height / this.scale
this.scale = 1
this.currentPan = { this.currentPan = {
x: svg.getBoundingClientRect().width / 2, x: (this.container.clientWidth - width) / 2,
y: svg.getBoundingClientRect().height / 2, y: (this.container.clientHeight - height) / 2,
} }
this.updateTransform() this.updateTransform()
} }

View File

@@ -16,11 +16,49 @@ interface Item {
type SearchType = "basic" | "tags" type SearchType = "basic" | "tags"
let searchType: SearchType = "basic" let searchType: SearchType = "basic"
let currentSearchTerm: string = "" let currentSearchTerm: string = ""
const encoder = (str: string) => { const encoder = (str: string): string[] => {
return str const tokens: string[] = []
.toLowerCase() let bufferStart = -1
.split(/\s+/) let bufferEnd = -1
.filter((token) => token.length > 0) const lower = str.toLowerCase()
let i = 0
for (const char of lower) {
const code = char.codePointAt(0)!
const isCJK =
(code >= 0x3040 && code <= 0x309f) ||
(code >= 0x30a0 && code <= 0x30ff) ||
(code >= 0x4e00 && code <= 0x9fff) ||
(code >= 0xac00 && code <= 0xd7af) ||
(code >= 0x20000 && code <= 0x2a6df)
const isWhitespace = code === 32 || code === 9 || code === 10 || code === 13
if (isCJK) {
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart, bufferEnd))
bufferStart = -1
}
tokens.push(char)
} else if (isWhitespace) {
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart, bufferEnd))
bufferStart = -1
}
} else {
if (bufferStart === -1) bufferStart = i
bufferEnd = i + char.length
}
i += char.length
}
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart))
}
return tokens
} }
let index = new FlexSearch.Document<Item>({ let index = new FlexSearch.Document<Item>({

View File

@@ -0,0 +1,163 @@
import test, { describe } from "node:test"
import assert from "node:assert"
// Inline the encoder function from search.inline.ts for testing
const encoder = (str: string): string[] => {
const tokens: string[] = []
let bufferStart = -1
let bufferEnd = -1
const lower = str.toLowerCase()
let i = 0
for (const char of lower) {
const code = char.codePointAt(0)!
const isCJK =
(code >= 0x3040 && code <= 0x309f) ||
(code >= 0x30a0 && code <= 0x30ff) ||
(code >= 0x4e00 && code <= 0x9fff) ||
(code >= 0xac00 && code <= 0xd7af) ||
(code >= 0x20000 && code <= 0x2a6df)
const isWhitespace = code === 32 || code === 9 || code === 10 || code === 13
if (isCJK) {
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart, bufferEnd))
bufferStart = -1
}
tokens.push(char)
} else if (isWhitespace) {
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart, bufferEnd))
bufferStart = -1
}
} else {
if (bufferStart === -1) bufferStart = i
bufferEnd = i + char.length
}
i += char.length
}
if (bufferStart !== -1) {
tokens.push(lower.slice(bufferStart))
}
return tokens
}
describe("search encoder", () => {
describe("English text", () => {
test("should tokenize simple English words", () => {
const result = encoder("hello world")
assert.deepStrictEqual(result, ["hello", "world"])
})
test("should handle multiple spaces", () => {
const result = encoder("hello world")
assert.deepStrictEqual(result, ["hello", "world"])
})
test("should handle tabs and newlines", () => {
const result = encoder("hello\tworld\ntest")
assert.deepStrictEqual(result, ["hello", "world", "test"])
})
test("should lowercase all text", () => {
const result = encoder("Hello WORLD Test")
assert.deepStrictEqual(result, ["hello", "world", "test"])
})
})
describe("CJK text", () => {
test("should tokenize Japanese Hiragana character by character", () => {
const result = encoder("こんにちは")
assert.deepStrictEqual(result, ["こ", "ん", "に", "ち", "は"])
})
test("should tokenize Japanese Katakana character by character", () => {
const result = encoder("コントロール")
assert.deepStrictEqual(result, ["コ", "ン", "ト", "ロ", "ー", "ル"])
})
test("should tokenize Japanese Kanji character by character", () => {
const result = encoder("日本語")
assert.deepStrictEqual(result, ["日", "本", "語"])
})
test("should tokenize Korean Hangul character by character", () => {
const result = encoder("안녕하세요")
assert.deepStrictEqual(result, ["안", "녕", "하", "세", "요"])
})
test("should tokenize Chinese characters character by character", () => {
const result = encoder("你好世界")
assert.deepStrictEqual(result, ["你", "好", "世", "界"])
})
test("should handle mixed Hiragana/Katakana/Kanji", () => {
const result = encoder("て以来")
assert.deepStrictEqual(result, ["て", "以", "来"])
})
})
describe("Mixed CJK and English", () => {
test("should handle Japanese with English words", () => {
const result = encoder("hello 世界")
assert.deepStrictEqual(result, ["hello", "世", "界"])
})
test("should handle English with Japanese words", () => {
const result = encoder("世界 hello world")
assert.deepStrictEqual(result, ["世", "界", "hello", "world"])
})
test("should handle complex mixed content", () => {
const result = encoder("これはtest文章です")
assert.deepStrictEqual(result, ["こ", "れ", "は", "test", "文", "章", "で", "す"])
})
test("should handle mixed Korean and English", () => {
const result = encoder("hello 안녕 world")
assert.deepStrictEqual(result, ["hello", "안", "녕", "world"])
})
test("should handle mixed Chinese and English", () => {
const result = encoder("你好 world")
assert.deepStrictEqual(result, ["你", "好", "world"])
})
})
describe("Edge cases", () => {
test("should handle empty string", () => {
const result = encoder("")
assert.deepStrictEqual(result, [])
})
test("should handle only whitespace", () => {
const result = encoder(" \t\n ")
assert.deepStrictEqual(result, [])
})
test("should handle single character", () => {
const result = encoder("a")
assert.deepStrictEqual(result, ["a"])
})
test("should handle single CJK character", () => {
const result = encoder("あ")
assert.deepStrictEqual(result, ["あ"])
})
test("should handle CJK with trailing whitespace", () => {
const result = encoder("日本語 ")
assert.deepStrictEqual(result, ["日", "本", "語"])
})
test("should handle English with trailing whitespace", () => {
const result = encoder("hello ")
assert.deepStrictEqual(result, ["hello"])
})
})
})

View File

@@ -65,7 +65,6 @@ pre {
overflow: hidden; overflow: hidden;
& > .mermaid-content { & > .mermaid-content {
padding: 2rem;
position: relative; position: relative;
transform-origin: 0 0; transform-origin: 0 0;
transition: transform 0.1s ease; transition: transform 0.1s ease;

View File

@@ -3,85 +3,83 @@ import { Translation } from "./definition"
export default { export default {
propertyDefaults: { propertyDefaults: {
title: "Không có tiêu đề", title: "Không có tiêu đề",
description: "Không có mô tả được cung cấp", description: "Không có mô tả",
}, },
components: { components: {
callout: { callout: {
note: "Ghi Chú", note: "Ghi chú",
abstract: "Tóm Tắt", abstract: "Tổng quan",
info: "Thông tin", info: "Thông tin",
todo: "Cần Làm", todo: "Cần phải làm",
tip: "Gợi Ý", tip: "Gợi ý",
success: "Thành Công", success: "Thành công",
question: "Nghi Vấn", question: "Câu hỏi",
warning: "Cảnh Báo", warning: "Cảnh báo",
failure: "Thất Bại", failure: "Thất bại",
danger: "Nguy Hiểm", danger: "Nguy hiểm",
bug: "Lỗi", bug: "Lỗi",
example: "Ví Dụ", example: "Ví dụ",
quote: "Trích Dẫn", quote: "Trích dẫn",
}, },
backlinks: { backlinks: {
title: "Liên Kết Ngược", title: "Liên kết ngược",
noBacklinksFound: "Không có liên kết ngược được tìm thấy", noBacklinksFound: "Không có liên kết ngược nào",
}, },
themeToggle: { themeToggle: {
lightMode: "Sáng", lightMode: "Chế độ sáng",
darkMode: "Tối", darkMode: "Chế độ tối",
}, },
readerMode: { readerMode: {
title: "Chế độ đọc", title: "Chế độ đọc",
}, },
explorer: { explorer: {
title: "Trong bài này", title: "Nội dung",
}, },
footer: { footer: {
createdWith: "Được tạo bởi", createdWith: "Được tạo bằng",
}, },
graph: { graph: {
title: "Biểu Đồ", title: "Sơ đồ",
}, },
recentNotes: { recentNotes: {
title: "Bài viết gần đây", title: "Ghi chú gần đây",
seeRemainingMore: ({ remaining }) => `Xem ${remaining} thêm`, seeRemainingMore: ({ remaining }) => `Xem thêm ${remaining} ghi chú`,
}, },
transcludes: { transcludes: {
transcludeOf: ({ targetSlug }) => `Bao gồm ${targetSlug}`, transcludeOf: ({ targetSlug }) => `Trích dẫn toàn bộ từ ${targetSlug}`,
linkToOriginal: "Liên Kết Gốc", linkToOriginal: "Xem trang gốc",
}, },
search: { search: {
title: "Tìm Kiếm", title: "Tìm",
searchBarPlaceholder: "Tìm kiếm thông tin", searchBarPlaceholder: "Tìm kiếm thông tin",
}, },
tableOfContents: { tableOfContents: {
title: "Bảng Nội Dung", title: "Mục lục",
}, },
contentMeta: { contentMeta: {
readingTime: ({ minutes }) => `đọc ${minutes} phút`, readingTime: ({ minutes }) => `${minutes} phút đọc`,
}, },
}, },
pages: { pages: {
rss: { rss: {
recentNotes: "Những bài gần đây", recentNotes: "Ghi chú gần đây",
lastFewNotes: ({ count }) => `${count} Bài gần đây`, lastFewNotes: ({ count }) => `${count} Trang gần đây`,
}, },
error: { error: {
title: "Không Tìm Thấy", title: "Không tìm thấy",
notFound: "Trang này được bảo mật hoặc không tồn tại.", notFound: "Trang này riêng tư hoặc không tồn tại.",
home: "Trở về trang chủ", home: "Về trang chủ",
}, },
folderContent: { folderContent: {
folder: "Thư Mục", folder: "Thư mục",
itemsUnderFolder: ({ count }) => itemsUnderFolder: ({ count }) => `${count} trang trong thư mục này.`,
count === 1 ? "1 mục trong thư mục này." : `${count} mục trong thư mục này.`,
}, },
tagContent: { tagContent: {
tag: "Thẻ", tag: "Thẻ",
tagIndex: "Thẻ Mục Lục", tagIndex: "Danh sách thẻ",
itemsUnderTag: ({ count }) => itemsUnderTag: ({ count }) => `${count} trang gắn thẻ này.`,
count === 1 ? "1 mục gắn thẻ này." : `${count} mục gắn thẻ này.`, showingFirst: ({ count }) => `Đang hiển thị ${count} trang đầu tiên.`,
showingFirst: ({ count }) => `Hiển thị trước ${count} thẻ.`, totalTags: ({ count }) => `Có tổng cộng ${count} thẻ.`,
totalTags: ({ count }) => `Tìm thấy ${count} thẻ tổng cộng.`,
}, },
}, },
} as const satisfies Translation } as const satisfies Translation

View File

@@ -17,8 +17,10 @@ interface Options {
typstOptions: TypstOptions typstOptions: TypstOptions
} }
// mathjax macros
export type Args = boolean | number | string | null
interface MacroType { interface MacroType {
[key: string]: string [key: string]: string | Args[]
} }
export const Latex: QuartzTransformerPlugin<Partial<Options>> = (opts) => { export const Latex: QuartzTransformerPlugin<Partial<Options>> = (opts) => {
@@ -37,11 +39,20 @@ export const Latex: QuartzTransformerPlugin<Partial<Options>> = (opts) => {
case "typst": { case "typst": {
return [[rehypeTypst, opts?.typstOptions ?? {}]] return [[rehypeTypst, opts?.typstOptions ?? {}]]
} }
default:
case "mathjax": { case "mathjax": {
return [[rehypeMathjax, { macros, ...(opts?.mathJaxOptions ?? {}) }]] return [
} [
default: { rehypeMathjax,
return [[rehypeMathjax, { macros, ...(opts?.mathJaxOptions ?? {}) }]] {
...(opts?.mathJaxOptions ?? {}),
tex: {
...(opts?.mathJaxOptions?.tex ?? {}),
macros,
},
},
],
]
} }
} }
}, },

View File

@@ -41,13 +41,17 @@ ul,
.katex, .katex,
.math, .math,
.typst-doc, .typst-doc,
.typst-doc * { g[class~="typst-text"] {
color: var(--darkgray); color: var(--darkgray);
fill: var(--darkgray); fill: var(--darkgray);
overflow-wrap: break-word; overflow-wrap: break-word;
text-wrap: pretty; text-wrap: pretty;
} }
path[class~="typst-shape"] {
stroke: var(--darkgray);
}
.math { .math {
&.math-display { &.math-display {
text-align: center; text-align: center;