The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: support emoji tags (closes #634)

+15 -14
+4 -3
quartz/plugins/transformers/ofm.ts
··· 121 121 const calloutLineRegex = new RegExp(/^> *\[\!\w+\][+-]?.*$/, "gm") 122 122 // (?:^| ) -> non-capturing group, tag should start be separated by a space or be the start of the line 123 123 // #(...) -> capturing group, tag itself must start with # 124 - // (?:[-_\p{L}])+ -> non-capturing group, non-empty string of (Unicode-aware) alpha-numeric characters, hyphens and/or underscores 125 - // (?:\/[-_\p{L}]+)*) -> non-capturing group, matches an arbitrary number of tag strings separated by "/" 126 - const tagRegex = new RegExp(/(?:^| )#((?:[-_\p{L}\d])+(?:\/[-_\p{L}\d]+)*)/, "gu") 124 + // (?:[-_\p{L}\d\p{Z}])+ -> non-capturing group, non-empty string of (Unicode-aware) alpha-numeric characters and symbols, hyphens and/or underscores 125 + // (?:\/[-_\p{L}\d\p{Z}]+)*) -> non-capturing group, matches an arbitrary number of tag strings separated by "/" 126 + const tagRegex = new RegExp(/(?:^| )#((?:[-_\p{L}\d\p{Z}])+(?:\/[-_\p{L}\d\p{Z}]+)*)/, "gu") 127 127 const blockReferenceRegex = new RegExp(/\^([A-Za-z0-9]+)$/, "g") 128 128 129 129 export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = ( ··· 405 405 if (/^\d+$/.test(tag)) { 406 406 return false 407 407 } 408 + 408 409 tag = slugTag(tag) 409 410 if (file.data.frontmatter && !file.data.frontmatter.tags.includes(tag)) { 410 411 file.data.frontmatter.tags.push(tag)
+11 -11
quartz/util/path.ts
··· 1 - import { slug } from "github-slugger" 1 + import { slug as slugAnchor } from "github-slugger" 2 2 import type { Element as HastElement } from "hast" 3 3 // this file must be isomorphic so it can't use node libs (e.g. path) 4 4 ··· 43 43 return res 44 44 } 45 45 46 + function sluggify(s: string): string { 47 + return s 48 + .split("/") 49 + .map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments 50 + .join("/") // always use / as sep 51 + .replace(/\/$/, "") 52 + } 53 + 46 54 export function slugifyFilePath(fp: FilePath, excludeExt?: boolean): FullSlug { 47 55 fp = _stripSlashes(fp) as FilePath 48 56 let ext = _getFileExtension(fp) ··· 51 59 ext = "" 52 60 } 53 61 54 - let slug = withoutFileExt 55 - .split("/") 56 - .map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments 57 - .join("/") // always use / as sep 58 - .replace(/\/$/, "") // remove trailing slash 62 + let slug = sluggify(withoutFileExt) 59 63 60 64 // treat _index as index 61 65 if (_endsWith(slug, "_index")) { ··· 156 160 return [fp, anchor] 157 161 } 158 162 159 - export function slugAnchor(anchor: string) { 160 - return slug(anchor) 161 - } 162 - 163 163 export function slugTag(tag: string) { 164 164 return tag 165 165 .split("/") 166 - .map((tagSegment) => slug(tagSegment)) 166 + .map((tagSegment) => sluggify(tagSegment)) 167 167 .join("/") 168 168 } 169 169