nobiot/md-roam

(feat) Support "lite" syntax for aliases

nobiot opened this issue · 7 comments

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.

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.

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?

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

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

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]*\\)\\(.*\\)")

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

@gambhiro 👍 thank you