···121121const calloutLineRegex = new RegExp(/^> *\[\!\w+\][+-]?.*$/, "gm")
122122// (?:^| ) -> non-capturing group, tag should start be separated by a space or be the start of the line
123123// #(...) -> capturing group, tag itself must start with #
124124-// (?:[-_\p{L}])+ -> non-capturing group, non-empty string of (Unicode-aware) alpha-numeric characters, hyphens and/or underscores
125125-// (?:\/[-_\p{L}]+)*) -> non-capturing group, matches an arbitrary number of tag strings separated by "/"
126126-const tagRegex = new RegExp(/(?:^| )#((?:[-_\p{L}\d])+(?:\/[-_\p{L}\d]+)*)/, "gu")
124124+// (?:[-_\p{L}\d\p{Z}])+ -> non-capturing group, non-empty string of (Unicode-aware) alpha-numeric characters and symbols, hyphens and/or underscores
125125+// (?:\/[-_\p{L}\d\p{Z}]+)*) -> non-capturing group, matches an arbitrary number of tag strings separated by "/"
126126+const tagRegex = new RegExp(/(?:^| )#((?:[-_\p{L}\d\p{Z}])+(?:\/[-_\p{L}\d\p{Z}]+)*)/, "gu")
127127const blockReferenceRegex = new RegExp(/\^([A-Za-z0-9]+)$/, "g")
128128129129export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (
···405405 if (/^\d+$/.test(tag)) {
406406 return false
407407 }
408408+408409 tag = slugTag(tag)
409410 if (file.data.frontmatter && !file.data.frontmatter.tags.includes(tag)) {
410411 file.data.frontmatter.tags.push(tag)
+11-11
quartz/util/path.ts
···11-import { slug } from "github-slugger"
11+import { slug as slugAnchor } from "github-slugger"
22import type { Element as HastElement } from "hast"
33// this file must be isomorphic so it can't use node libs (e.g. path)
44···4343 return res
4444}
45454646+function sluggify(s: string): string {
4747+ return s
4848+ .split("/")
4949+ .map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments
5050+ .join("/") // always use / as sep
5151+ .replace(/\/$/, "")
5252+}
5353+4654export function slugifyFilePath(fp: FilePath, excludeExt?: boolean): FullSlug {
4755 fp = _stripSlashes(fp) as FilePath
4856 let ext = _getFileExtension(fp)
···5159 ext = ""
5260 }
53615454- let slug = withoutFileExt
5555- .split("/")
5656- .map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments
5757- .join("/") // always use / as sep
5858- .replace(/\/$/, "") // remove trailing slash
6262+ let slug = sluggify(withoutFileExt)
59636064 // treat _index as index
6165 if (_endsWith(slug, "_index")) {
···156160 return [fp, anchor]
157161}
158162159159-export function slugAnchor(anchor: string) {
160160- return slug(anchor)
161161-}
162162-163163export function slugTag(tag: string) {
164164 return tag
165165 .split("/")
166166- .map((tagSegment) => slug(tagSegment))
166166+ .map((tagSegment) => sluggify(tagSegment))
167167 .join("/")
168168}
169169