Skip to content

Commit

Permalink
feat: update match cases
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 23, 2021
1 parent 482385b commit eb0a896
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions quake_webapp/quake-render/src/markdown/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@ function getPageLink() {
name: 'page_link',
level: 'inline',
tokenizer(src, _tokens) {
const rule = /^\[\[(.+(?=:)):(\d+)(#(.+)([|\s]))?(|(.+))? "(.+?(?="]]))"]]/;
// test cases:
// [[Note:0001#Heading "file name"]]
// [[Note:0001#Heading|Label "file name"]]
// [[Note:0001|Label "file name"]]
// [[Note:0001 "file name"]]
const rule = /^\[\[(.+):(\d+)#?(.+(?=\|))?\|?(.+)? "(.+?(?="]]))"]]/;
const match = rule.exec(src);
if (match) {
return {
type: 'page_link',
raw: match[0],
entry_type: match[1].trim(),
entry_id: match[2].trim(),
entry_title: match[3].trim(),
entry_heading: '',
entry_label: ''
entry_heading: match[3].trim(),
entry_label: match[4].trim(),
entry_title: match[5].trim()
};
}
}
Expand Down

0 comments on commit eb0a896

Please sign in to comment.