dendron
dendron copied to clipboard
`[`, `(`, `,`, `;` should be allowed before the `@user` tag
Please select if your request is either something new or an enhancement
- [x] Enhancement of an existing Feature.
- [ ] Request of a new feature.
Please select the area your request applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)
- [ ] Workspace - VSCode workspace, vaults, Intellisense/autocomplete, Dendron settings
- [ ] Views - Dendron Preview, Tree View, Side Panels in the UI
- [ ] Lookup - Dendron's Lookup Command
- [ ] Schema - Dendron Schemas
- [ ] Pod - Data import from / export to Dendron
- [ ] Publish - External Site Publish
- [x] Markdown - Markdown features, such as syntax support and features
Is your feature request related to a problem? Please describe
Currently @user
tag doesn't work whenever there is non-space character before it. However, sometimes people may want to tag people in following ways:
- xxxx (@user is handling this)
- @user1,@user2
- @user1;@user2
- [@citekey1;@citekey2] #for using user tag for citation notes
All of these doesn't recognize the tag as link.
Describe the solution you'd like
Special characters, including [
, (
, ,
, ;
should be allowed before the @user
tag
thanks for the issue. have added it as a crop candidate
This issue is featured in this week's round of CROP.
I haven't been able to build proper tests to be able to submit an actual PR for this, but if someone does come to implement it - from manual testing you should only need to do is swap out the regexs in the following :
https://github.com/dendronhq/dendron/blob/9efdf2c453e822972e5cb749e558b00de572005b/packages/engine-server/src/markdown/remark/userTags.ts#L30-L44
becomes:
export const USERTAG_REGEX = new RegExp(
// Require one of ,;([ or whitespace before to avoid something like [email protected]
`^(?<=^|[\\s,;\\(\\[])(?<tagSymbol>@)(?<tagContents>` +
`${GOOD_MIDDLE_CHARACTER}*` +
`${GOOD_END_CHARACTER}` +
`)`
);
/** Same as `USERTAG_REGEX`, except that that it doesn't have to be at the start of the string. */
export const USERTAG_REGEX_LOOSE = new RegExp(
// Require one of ,;([ or whitespace before to avoid something like [email protected]
`(?<=^|[\\s,;\\(\\[])(?<userTag>@)(?<userTagContents>` +
`${GOOD_MIDDLE_CHARACTER}*` +
`${GOOD_END_CHARACTER}` +
`)`
);
and https://github.com/dendronhq/dendron/blob/9efdf2c453e822972e5cb749e558b00de572005b/packages/engine-server/src/markdown/remark/userTags.ts#L82-L96
becomes
function locator(value: string, fromIndex: number) {
// Do not locate a symbol if the previous character is non-whitespace (except one of ,;([ ).
// Unified cals tokenizer starting at the index we return here,
// so tokenizer won't be able to reject it for not starting with a non-space character.
const atSymbol = value.indexOf("@", fromIndex);
if (atSymbol === 0) {
return atSymbol;
} else if (atSymbol > 0) {
const previousSymbol = value[atSymbol - 1];
if (!previousSymbol || /[\s([,;]/.exec(previousSymbol)) {
return atSymbol;
}
}
return -1;
}