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
636 stars 39 forks source link

[Bug]: URL replacer doesn't work #359

Closed ooker777 closed 2 months ago

ooker777 commented 2 months ago

What does the text transformation to the URL mean? In my understanding it just replaces text in the filename. So I expect if you have a file a.md, and with the rule to replace a with b, then you get b.md as the output. But it doesn't work.

Ultimately I want to avoid the % character in the filename to avoid URIError: URI malformed. But even enabling the Encode to URI option it still isn't converted to %25.

v7.2.12

Mara-Li commented 2 months ago

Can't repro, the % is converted into %25 on my side ; and % is replaced using the link replacement. Note: if you use uri encoding, the regex is applied AFTER the encoding.

ooker777 commented 2 months ago

That's strange. Can you share your config? Mine is:

{
  "github": {
    "branch": "main",
    "automaticallyMergePR": true,
    "dryRun": {
      "enable": false,
      "folderName": "github-publisher"
    },
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[skip netlify] PUBLISHER",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "obsidian",
    "defaultName": "docs",
    "rootFolder": "docs",
    "yamlFolderKey": "category",
    "frontmatterTitle": {
      "enable": true,
      "key": "filename"
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "includeAttachments": true,
      "enable": true,
      "excluded": [
        "docs/assets/favicon.svg",
        "docs/assets/favicon.ico",
        "docs/_data.yaml",
        "docs/_includes/og_image.jsx"
      ]
    },
    "folderNote": {
      "enable": true,
      "rename": "index.md",
      "addTitle": {
        "enable": true,
        "key": "title"
      }
    },
    "metadataExtractorPath": "",
    "subFolder": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [
      {
        "entry": "/\\!\\[.*\\]\\(https:\\/\\/.*(youtube\\.com|youtu\\.be)\\/(.*).*\\)/",
        "replace": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/$2\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen></iframe>",
        "after": true,
        "inCodeBlocks": true
      }
    ],
    "tags": {
      "inline": true,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": false,
      "wiki": true,
      "slugify": "disable"
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [
      "image"
    ],
    "notes": true,
    "folder": "docs/assets/attachments",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": true,
    "forcePushAttachments": [],
    "useObsidianFolder": false
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [
      "Ξ Thiết lập"
    ],
    "copyLink": {
      "enable": true,
      "links": "https://kiếmtiền.quảcầu.cc/",
      "removePart": [
        "content",
        "index.md"
      ],
      "transform": {
        "toUri": true,
        "slugify": "disable",
        "applyRegex": [
          {
            "regex": "%",
            "replacement": "%"
          }
        ]
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "plugin-settings"
}

System info:

Obsidian version: v1.6.7
Installer version: v1.4.13
Operating system: Windows 10 Home Single Language 10.0.22631
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: off
Base theme: adapt to system
Community theme: Catppuccin v0.4.18
Snippets enabled: 2
Restricted mode: off
Plugins installed: 1
Plugins enabled: 1
1: Enveloppe v7.2.12
Mara-Li commented 2 months ago

Why you remplace % by %? ^^'

ooker777 commented 2 months ago

They are different characters actually: % vs . It's to workaround the escaping character that uses the normal one (%). If you replace that with a and b, the problem persists.

Mara-Li commented 2 months ago

It works on my side with your configuration… I tried % to x And your (strange :p) image

ooker777 commented 2 months ago

Hmm, I just realize that those options are only available when Copy link is enable. Does that mean this whole section is just for copying the URL, not actually modifying the output filename? I use a sandbox vault and only install the plugin and import the setting, but in my output repo the filename still isn't converted.

Where do you get that screenshot? It doesn't seem to be from the console.

Mara-Li commented 2 months ago

I just copy / pasted XD And Yes, it's only enabled when the copy-link option is enabled! And it doesn't change the name. To change name, you need to use the filepath option.

It's just a shortcuts to quickly create a link using obsidian with your configuration, without relying on other plugin.

ooker777 commented 2 months ago

Is the link automatically copied into the clipboard, or do I need to execute a command manually?

Is there a way to automatically replace the file name, like the option to replace the file content?

Mara-Li commented 2 months ago
  1. It should be, and a command can be added
  2. Yes, in filepath settings.
ooker777 commented 2 months ago

Yes, in filepath settings.

Stupid me 🤦

The link isn't automatically copied into the clipboard to me. There is also no command so I don't know how to copy it.

Mara-Li commented 2 months ago

For the commands, it needs to be enabled.

The auto-copy (even if the command is disabled) works on my side