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

[BUG] Unrelated frontmatter being modified when modifying via table #117

Closed
PaperOrb opened this issue Jun 10, 2022 · 10 comments
Closed

[BUG] Unrelated frontmatter being modified when modifying via table #117

PaperOrb opened this issue Jun 10, 2022 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@PaperOrb
Copy link

PaperOrb commented Jun 10, 2022

Selecting a personalRating:
folder_db_button_click

Causes modifications to unrelated fields inside the note which breaks things:
folder_db_diff
folder_db_2

Here's the settings for that personalRating column:
column_settings

Using Ubuntu 21.04 with obsidian 0.14.15

@RafaelGB RafaelGB added the triage Issue not tagged yet. talking to the user label Jun 10, 2022
@RafaelGB
Copy link
Owner

hi @PaperOrb
After edit a cell, the plugin check every field inside the frontmatter and adds commas wrapping the text if it’s necessary.

In your image, those fields than lose their commas looks like they do not need it but url field cause it contains “:”

Could you attach the db file and some example with the original text to test it? I cant see what’s the problem

@PaperOrb
Copy link
Author

Hey @RafaelGB, here's the DB and a file to test it with:
folder db test.md
FINAL FANTASY VII (2013).md

@RafaelGB
Copy link
Owner

thanks! Will be added to bugs in roadmap

@RafaelGB RafaelGB added bug Something isn't working and removed triage Issue not tagged yet. talking to the user labels Jun 10, 2022
@RafaelGB RafaelGB changed the title Unrelated frontmatter being modified when modifying via table [BUG] Unrelated frontmatter being modified when modifying via table Jun 10, 2022
@mProjectsCode
Copy link

The notes seem to be generated by my Media DB Plugin.

For that plugin, I wrote my own YAML stringifier that consistently adds quotation marks around strings. Mostly because I prefer it that way.

I am guessing that the db folder plugin replaces the entire frontmatter block and uses the obsidian API YAML stringifier for that.

@RafaelGB
Copy link
Owner

hi @mProjectsCode . I am afraid that the plugin use the dataview parser with all the fields. I added a proxy between to give it some value with quotes in some cases. I can add more uses cases to fix your issue

@mProjectsCode
Copy link

thanks for the quick answer.

I personally think a setting to always add quotation marks to strings would be nice.

That also seems to be the simplest way to resolve the small "conflict" between our plugins. I will also work on an option to only add quotation marks only where it is necessary for my plugin.

@RafaelGB
Copy link
Owner

We can collaborate to obtain the best parsing. In src/services/DataviewService.ts is the behaviour of the writing quotes:

private handleMarkdownBreaker(value: string, isInline?: boolean): string {
        if (isInline) {
            return value;
        }
        // Check possible markdown breakers of the yaml
        if (MarkdownBreakerRules.INIT_CHARS.some(c => value.startsWith(c)) ||
            MarkdownBreakerRules.BETWEEN_CHARS.some(rule => value.includes(rule)) ||
            MarkdownBreakerRules.UNIQUE_CHARS.some(c => value === c)) {
            value = value.replaceAll(`"`, `\\"`);
            return `"${value}"`;
        }

        return value;
    }

@RafaelGB RafaelGB self-assigned this Jun 20, 2022
@RafaelGB
Copy link
Owner

New property added to select your editing preferences

Screen.Recording.2022-06-21.at.22.51.06.mov

@mProjectsCode
Copy link

Looks great, except that it also adds quotation marks around non-strings like booleans and numbers.

@RafaelGB
Copy link
Owner

Fixed too :)

@RafaelGB RafaelGB closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants