Skip to content

BUG: custom property keys containing hyphens or spaces will be clipped as "my-key" (double quotes) instead of my-key (no quotes) #866

@OdysseyHome

Description

@OdysseyHome

Is this issue related to missing content or incorrect conversion to Markdown?

  • No. This is definitely a Web Clipper bug.

Have you reviewed the troubleshooting instructions?

Operating system

Windows 11

Browser

Chrome

Web Clipper version

1.6.1

Obsidian version

1.12.7

Describe the bug

I think it's easier to show the bug with an example:

Here's a demo custom template showing properties with their keys written in different case styles.

{
  "schemaVersion": "0.1.0",
  "name": "Example Template",
  "behavior": "create",
  "noteContentFormat": "",
  "properties": [
    {
      "name": "test property 0",
      "value": "spaced key",
      "type": "text"
    },
    {
      "name": "test-property-1",
      "value": "kebab case key",
      "type": "text"
    },
    {
      "name": "test_property_2",
      "value": "snake case key",
      "type": "text"
    },
    {
      "name": "testProperty3",
      "value": "camel case key",
      "type": "text"
    },
    {
      "name": "string_test-property_4",
      "value": "hybrid case key",
      "type": "text"
    }
  ],
  "triggers": [],
  "noteNameFormat": "Example Web Clipper Template",
  "path": "Example"
}

Clipping a page with this template will create a note with this yaml frontmatter in source view:

---
"test property 0": "spaced key"
"test-property-1": "kebab case key"
test_property_2: "snake case key"
testProperty3: "camel case key"
"string_test-property_4": "hybrid case key"
---

So any property key with a hyphen or space character gets outputted as a JSON property key instead of a normal yaml key with no double quotes like in the obsidan yaml documentation.

This syntax only gets reformatted when manually adding a property to the note through the property view. So in obsidan clicking "+ Add Property" then selecting the tags property the yaml will be sanitised.

---
test property 0: spaced key
test-property: kebab case key
test_property_2: snake case key
testProperty3: camel case key
string_test-property-3: hybrid case key
tags:
---

Expected behavior

Was expecting the clipper to create a note with obsdian yaml (no quotes for keys and values) rather than json yaml.

I only noticed this because I'm using the Linter Community Plugin to add frontmatter automatically on note save. If the key is "my-key" Linter will not recognise it as my-key and try to add it causing the properties view to complain about duplicate keys.

Since other community plugins use a variety of yaml key naming conventions (e.g. excalidraw uses kebab, tasks uses snake) it can make integrating the web clipper into custom workflows difficult if the keys are wrapped in double quotes.

URLs where the bug occurs

No response

To reproduce

  1. Import the demo template
  2. Clip any web page so that obsidian will create a note
  3. Examine the yaml frontmatter in source view
  4. Add the tags property using the editing view's properties view UI
  5. observe the yaml being sanitised

Your template file

{
  "schemaVersion": "0.1.0",
  "name": "Example Template",
  "behavior": "create",
  "noteContentFormat": "",
  "properties": [
    {
      "name": "test property 0",
      "value": "spaced key",
      "type": "text"
    },
    {
      "name": "test-property-1",
      "value": "kebab case key",
      "type": "text"
    },
    {
      "name": "test_property_2",
      "value": "snake case key",
      "type": "text"
    },
    {
      "name": "testProperty3",
      "value": "camel case key",
      "type": "text"
    },
    {
      "name": "string_test-property_4",
      "value": "hybrid case key",
      "type": "text"
    }
  ],
  "triggers": [],
  "noteNameFormat": "Example Web Clipper Template",
  "path": "Example"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions