Skip to content

[Bug]: Problems with Markdown links #404

Description

@miaogaolin

Issue validation

  • I checked the issue to prevent duplicate
  • I checked my configurations files and the documentation

Command used

Upload single current active note

Plugin version

7.6.4

Describe the bug

This is my Markdown article example.

[[#This is is h2]]

## This is is h2

The current incorrect result is:

[ > This is is h2](.md#this-is-is-h2)

## This is is h2

The correct result should be:

[This is is h2](#this-is-is-h2)

How to reproduce ?

No response

Minimal Reproducible Example

---
share: true
---
[[#This is is h2]]

## This is is h2

Configuration

{
  "github": {
    "branch": "main",
    "automaticallyMergePR": true,
    "dryRun": {
      "enable": true,
      "folderName": "github-publisher-test"
    },
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[PUBLISHER] Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "yaml",
    "defaultName": "content/posts",
    "rootFolder": "content",
    "yamlFolderKey": "dir",
    "frontmatterTitle": {
      "enable": false,
      "key": "title"
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "includeAttachments": true,
      "enable": false,
      "excluded": []
    },
    "folderNote": {
      "enable": false,
      "rename": "index.md",
      "addTitle": {
        "enable": false,
        "key": "title"
      }
    },
    "metadataExtractorPath": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [
      {
        "entry": "/\\[([^\\[\\]]+)\\]\\((1\\-Literature|2-Permanent|\\d{1,2}\\.{1,2}).+?md\\)/",
        "replace": "$1",
        "flags": "",
        "after": true
      },
      {
        "entry": "/\\]\\(([^)\\/]+)\\.md/",
        "replace": "]({{< relref \"$1.md\" >}}",
        "flags": "",
        "after": true,
        "inCodeBlocks": false
      },
      {
        "entry": "/cover\\.image/",
        "replace": "cover:\\n    image",
        "flags": "",
        "after": false
      },
      {
        "entry": "/\\]\\(([^/\\)]+?)\\.(png|jpg|jpeg|webp|gif|avif)/",
        "replace": "](/images/$1.$2",
        "flags": "",
        "after": true
      },
      {
        "entry": "/\\!\\[\\[([^/\\]]+?)\\.(png|jpg|jpeg|webp|gif|avif)\\|(\\d+)(x(\\d+))?\\]\\]/",
        "replace": "{{< figure src=\"/images/$1.$2\"  width=\"$3\" height=\"$5\">}}",
        "flags": "",
        "after": false
      },
      {
        "entry": "/\\!\\[\\[([^/\\]]+?)\\.(png|jpg|jpeg|webp|gif|avif)\\|([^\\|]*?)(\\|(\\d+)(x(\\d+))?)?\\]\\]/",
        "replace": "{{< figure src=\"/images/$1.$2\" caption=\"$3\" width=\"$5\" height=\"$7\">}}",
        "flags": "",
        "after": false
      },
      {
        "entry": "/\\[todo::[^\\]]+?\\]/",
        "replace": "",
        "flags": "",
        "after": true,
        "inCodeBlocks": false
      }
    ],
    "tags": {
      "inline": true,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": false,
      "unshared": false,
      "wiki": true,
      "slugify": "strict",
      "unlink": false,
      "relativePath": true,
      "textPrefix": "/"
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [],
    "notes": false,
    "folder": "static/images",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [
      "avif"
    ],
    "sendSimpleLinks": true,
    "forcePush": true,
    "forcePushAttachments": [],
    "useObsidianFolder": false
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [],
    "copyLink": {
      "enable": false,
      "links": "",
      "removePart": [],
      "addCmd": false,
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  }
}

Relevant log output

OS

Windows

Anything else?

Hi, I’d like to discuss another configuration issue related to Sluglify markdown links. Here’s an example:

This is the content of This is Note2.md:

## This is h2

This is the content of Note1.md:

[[This is Note2#This is h2]]

When Sluglify markdown links is set to lower, the uploaded content of Note1.md becomes:

[This is Note2 > This is h2](this-is-note2.md#this-is-h2)

However, this result is incorrect because the file this-is-note2.md does not exist, while the anchor this-is-h2 correctly links to the This is h2 heading.

If Sluglify markdown links is set to disable, the uploaded content of Note1.md becomes:

[This is Note2 > This is h2](This%20is%20Note2.md#This%20is%20h2)

In this case, the link to the This is h2 heading no longer works. To ensure that anchors work correctly, they must be converted to lowercase and have special characters replaced with -.

I noticed that earlier versions of the plugin had a dedicated option called Sluglify anchor in markdown links. Is there any recommended way to handle this situation in the current version?

Image

Obsidian information

SYSTEM INFO:
	Obsidian version: v1.10.6
	Installer version: v1.9.12
	Operating system: Windows 11 Pro 10.0.26100
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 1
	Restricted mode: off
	Plugins installed: 20
	Plugins enabled: 18
		1: Linter v1.30.0
		2: Enveloppe v7.6.4
		3: Image Inserter v0.8.4
		4: Dataview v0.5.68
		5: Excalidraw v2.15.3
		6: Homepage v4.2.2
		7: Charts v3.9.0
		8: QuickAdd v2.4.0
		9: Douban v2.3.0
		10: Iconic v1.1.4
		11: Tag Wrangler v0.6.4
		12: TagFolder v0.18.11
		13: Regex Find/Replace v1.2.0
		14: BRAT v1.3.2
		15: Commander v0.5.4
		16: Quiet Outline v0.5.3
		17: Remotely Save v0.5.25
		18: Image Converter v1.3.18

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.

Metadata

Metadata

Assignees

Labels

🐛 BugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions