Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Support "lite" syntax for aliases #43

Open
nobiot opened this issue Sep 20, 2020 · 7 comments
Open

(feat) Support "lite" syntax for aliases #43

nobiot opened this issue Sep 20, 2020 · 7 comments

Comments

@nobiot
Copy link
Owner

nobiot commented Sep 20, 2020

This is the current syntax to define aliases. Compliant with YAML syntax, and works great.

 roam_alias: [ alias 1, 'alias 2', "alias 3" ]

I feel that I would like to have an option to also support

roam_alise: alias 1, alise 2

and/or

aliases: [alias 1, alias 2]

The latter is compatible with gatsby-themes-brain

Let's how far this idea can be implemented.

@romariorobby
Copy link

I'd like to see this support as well especially the second option. Currently I use emacs and logseq. it seems logseq parse [ and " incorrectly and create their own page. suppose to just ignore it. i know its not relevant but it would be nice to incorperate with other app as well.

@nobiot
Copy link
Owner Author

nobiot commented Mar 19, 2022

What would you really like? The second option is this: aliases: [alias 1, alias 2], which contains [.

Have you already tried the syntax you would like to use? And what is the syntax you would like to use?

@romariorobby
Copy link

No, I mean this alias: alias 1, alias 2 which doesn't contain [ and "

@romariorobby
Copy link

romariorobby commented Mar 19, 2022

My setup currently something like this:

title: title
id: id
roam_aliases: [ "alias1", "alias2" ] # emacs (md-roam) alias
aliases: alias1    # Obsidian alias
alias:: alias1      # Logseq alias

@nobiot
Copy link
Owner Author

nobiot commented Mar 20, 2022

OK. I see. I don't think I'll be changing the code any time soon. You can achieve the following by two minor changes as below.

You can already omit quotation marks.

  1. Allow comma separated values without the square brackets like this:
    roam_aliases: alias 1, alias 2
    Each alias is separated only by a comma "," -- you can use spaces within a alias, they do not split aliases
  2. Change the name of the property like aliases, not roam_aliases

For 1, override the definition of function md-roam--yaml-seq-to-list:

(defun md-roam--yaml-seq-to-list ()
  (let ((regexp "\\(\s*\\)\\(.*\\)\\(\s*\\)") ;; this line is the only difference
        (separator ",\s*"))
    (when (string-match regexp seq)
      (let ((items (split-string-and-unquote
                    (match-string-no-properties 2 seq) separator)))
        (mapcar #'md-roam--remove-single-quotes items)))))

For 2 above, change the value of md-roam-regex-aliases:

(setq md-roam-regex-aliases
  ;; Assumed to be case insensitive
  "\\(^.*ALIASES:[ \t]*\\)\\(.*\\)")

@gambhiro
Copy link

This advice about the aliases key would be useful to see in README, it helps when integrating with Obsidian.

@nobiot
Copy link
Owner Author

nobiot commented Jan 19, 2023

@gambhiro 👍 thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants