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

(Org-mode Interop) Clobbering Properties #32

Closed
ComedyTomedy opened this issue May 24, 2024 · 3 comments
Closed

(Org-mode Interop) Clobbering Properties #32

ComedyTomedy opened this issue May 24, 2024 · 3 comments

Comments

@ComedyTomedy
Copy link

This may not be a design goal, or perhaps not for 1.0, but I think it's a good idea to leave any org-mode markup that BrainTool doesn't understand unaltered, so that the BrainTool.org file can seamlessly interop with Emacs, eleventy, org-roam, LogSeq, and other apps that speak org.

The Problem

I tried adding a property drawer to one of the links:

:PROPERTIES:
:ID: this-is-my-id
:prop: value is a string with whitespace
:END:

After importing to BT, editing the link, then M-x revert-buffer in Emacs, it's been changed to:

:PROPERTIES:
:ID: this
:prop: value
:END:

The Solution

The problem is in BTAppNode.js line 595.

        const reg = /:(\w*):\s*(\w*)/g;              // regex to iterate thru props and values

Can be altered to:

        const reg = /:(\w*):\s*(.*\w)/g;              // regex to iterate thru props and values

This uses the greediness of \s* to guarantee we're not starting the value on whitespace, the greediness of .* to ensure the whole value is included, and the \w character to effectively strip any trailing whitespace (matching the behaviour of Emacs org-entry-get.

@ComedyTomedy
Copy link
Author

...we could also do a simpler value slurp and leave trailing whitespace unaltered, too. I can't imagine anything relies on trailing whitespace in values though, given that org won't read it.

tconfrey added a commit that referenced this issue Jul 16, 2024
… item deletion. browser maximized - don't adjust position on first opening TM. fixed regex to not clobber org properties
@tconfrey
Copy link
Owner

Thanks for the detailed bug report! And apologies for the delay, I haven't been monitoring this list very closely. The most recent 1.0.2 version of BT, which just went live in the Chrome Store, fixes the bug. I went with the approach of grabbing everything to the end of the line:
/:([\w-]*):(.*)$/gm;

@ComedyTomedy
Copy link
Author

Thanks a lot! No problem about response time, I can only apologise for throwing so many thoughts and ideas at you. I mean well.

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

2 participants