Enveloppe / obsidian-enveloppe

Enveloppe helps you to publish your notes on a GitHub repository from your Obsidian Vault, for free!
https://enveloppe.github.io/
Apache License 2.0
613 stars 38 forks source link

[Bug]: dataviewjs code blocks result in errors within callout blocks because of the > character. JSON Parse error? #354

Closed wychwitch closed 1 month ago

wychwitch commented 2 months ago

Issue validation

Command used

Upload all notes, Upload unpublished notes, Upload single current active note, Refresh published and upload new notes

Plugin version

7.2.8

Describe the bug

Dataviewjs blocks within callouts and quotes do not render correctly because of the > character. If you make one, you'll get the error Evaluation Error: SyntaxError: Unexpected token '>'.

This happens both with a > character at the beginning of each line (including the code lines) and with only a > on the first and last lines of the dataviewjs block.

In obsidian they render just fine.

This big however does NOT occur with vanilla dataview blocks, only the dataviewjs ones.

Looking at the console errors, there's a Bad escaped character in JSON error that occurs when the troublesome file is processed, I'm not sure how relevant that is, however I'll put it in the log output thing.

How to reproduce ?

  1. Make a dataviewjs block in a callout block.
  2. Publish with enveloppe, with the convert dataview-to-markdown setting enabled.
  3. See bug.

Minimal Reproducible Example

---
tags:
  - dataviewjstest
name: lorem ipsum
---

dataviewjs block outside of callout:
```dataviewjs
 let page_name = dv.current().name;
 dv.span(page_name);

[!NOTE] Title dataviewjs block with > character on each line

let page_name = dv.current().name;
dv.span(page_name);

dataviewjs block with > character only on first and last line of block

let page_name = dv.current().name;
dv.span(page_name);

dataview block with > character on each line

TABLE name
FROM #dataviewjstest

dataview block with > character only on first and last line

TABLE  name
FROM #dataviewjstest

End of testing

Configuration

{
  "github": {
    "branch": "live",
    "automaticallyMergePR": true,
    "dryRun": {
      "enable": false,
      "folderName": "github-publisher"
    },
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[PUBLISHER] Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "obsidian",
    "defaultName": "content",
    "rootFolder": "",
    "yamlFolderKey": "",
    "frontmatterTitle": {
      "enable": true,
      "key": "slug"
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "includeAttachments": true,
      "enable": true,
      "excluded": []
    },
    "folderNote": {
      "enable": false,
      "rename": "index.md",
      "addTitle": {
        "enable": false,
        "key": "title"
      }
    },
    "metadataExtractorPath": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [],
    "tags": {
      "inline": false,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": false,
      "wiki": false,
      "slugify": "disable"
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [],
    "notes": true,
    "folder": "",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": true
  },
  "plugin": {
    "shareKey": "publish-ash",
    "excludedFolder": [],
    "copyLink": {
      "enable": true,
      "links": "<redacted>",
      "removePart": [],
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "github-configuration"
}

Relevant log output

plugin:obsidian-mkdocs-publisher:29 DEV LOGS [20:59:52.455] main:
 SyntaxError: Bad escaped character in JSON at position 17
    at JSON.parse (<anonymous>)
    at eval (plugin:obsidian-mkdo…-publisher:27:98844)
    at String.replace (<anonymous>)
    at replaceText (plugin:obsidian-mkdo…-publisher:27:98679)
    at strictStringConversion (plugin:obsidian-mkdo…-publisher:27:93881)
    at convertWikilinks (plugin:obsidian-mkdo…-publisher:27:91176)
    at convertDataviewLinks (plugin:obsidian-mkdocs-publisher:35:2531)
    at async convertDataviewQueries (plugin:obsidian-mkdocs-publisher:35:2058)
    at async mainConverting (plugin:obsidian-mkdocs-publisher:44:1691)
    at async GithubBranch.publish (plugin:obsidian-mkdocs-publisher:44:5274)
notif   @   plugin:obsidian-mkdocs-publisher:29
logs    @   plugin:obsidian-mkdocs-publisher:30
eval    @   plugin:obsidian-mkdocs-publisher:27
replaceText @   plugin:obsidian-mkdocs-publisher:27
strictStringConversion  @   plugin:obsidian-mkdocs-publisher:27
convertWikilinks    @   plugin:obsidian-mkdocs-publisher:27
convertDataviewLinks    @   plugin:obsidian-mkdocs-publisher:35
await in convertDataviewLinks (async)       
convertDataviewQueries  @   plugin:obsidian-mkdocs-publisher:35
await in convertDataviewQueries (async)     
mainConverting  @   plugin:obsidian-mkdocs-publisher:44
await in mainConverting (async)     
publish @   plugin:obsidian-mkdocs-publisher:44
await in publish (async)        
shareOneNote    @   plugin:obsidian-mkdocs-publisher:32
await in shareOneNote (async)       
checkCallback   @   plugin:obsidian-mkdocs-publisher:32
RK  @   app.js:1
t.onChooseItem  @   app.js:1
t.onChooseSuggestion    @   app.js:1
t.selectSuggestion  @   app.js:1
e.useSelectedItem   @   app.js:1
(anonymous) @   app.js:1
e.handleKey @   app.js:1
e.onKeyEvent    @   app.js:1

OS

Windows

Anything else?

No response

Obsidian information

SYSTEM INFO:
    Obsidian version: v1.6.5
    Installer version: v1.4.16
    Operating system: Windows 10 Education 10.0.22631
    Login status: logged in
    Catalyst license: insider
    Insider build toggle: on
    Live preview: on
    Base theme: adapt to system
    Community theme: Prism v3.5.3
    Snippets enabled: 1
    Restricted mode: off
    Plugins installed: 15
    Plugins enabled: 15
        1: Admonition v10.3.2
        2: Colored Tags Wrangler v0.19.3
        3: Enveloppe v7.2.8
        4: File Diff v1.1.1
        5: Homepage v3.8.0
        6: Dataview v0.5.66
        7: Outliner v4.8.1
        8: Style Settings v1.0.8
        9: Update modified date v1.3.2
        10: Templater v2.3.3
        11: Dice Roller v11.0.4
        12: Rant-Lang v0.5.9
        13: Buttons v0.5.1
        14: Multi Properties v1.1.1
        15: Leaflet v6.0.5

RECOMMENDATIONS:
    Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.