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]: Jekyll Regex stopped working #377

Closed
2 tasks done
kurko opened this issue Jan 13, 2025 · 6 comments
Closed
2 tasks done

[Bug]: Jekyll Regex stopped working #377

kurko opened this issue Jan 13, 2025 · 6 comments
Assignees
Labels
🐛 Bug Something isn't working

Comments

@kurko
Copy link
Contributor

kurko commented Jan 13, 2025

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.5.2

Describe the bug

The short description is that regex is not working anymore. Jekyll URL links need to look like [Text]({% link something %}), but the links are just pure markdown ([Text](the-url)), which breaks links.

The long description is that this keeps breaking every few months. Every 6 months or so, there's some change to the code that breaks the replacement. I then need to go into the console and debug findAndReplaceText, which is time consuming.

To address the problem of code changes breaking features — regex more specifically , I introduced tests to the repository in this pull request. It was later deleted, which is hard to understand. Lack of tests is like driving a car without brakes. I tried to contribute to make the plugin more stable but it looks like that wasn't welcome.

Without tests, regex will just keep breaking and it makes this plugin unusable. I barely use it due to these problems.

How to reproduce ?

  1. add the following regex: /(?<!\)[(.?)]((?!(http|/image|obsidian/image))(./)(.+?)(.md))/`
  2. add the following replacement: [$1]({% link obsidian/$4.md %})

The expected link will look like [Text]({% link something %}). I wrote about it in this post.

ps. I surrounded the regex with /, whereas the post above doesn't include it because, again, the plugin keeps changing and breaking behavior every once in a while.

Minimal Reproducible Example

---
share: true
title: The simplest test
---

[[the-simplest-test|This doesn't work]]

Configuration

{
  "github": {
    "branch": "main",
    "automaticallyMergePR": false,
    "dryRun": {
      "enable": false,
      "folderName": ""
    },
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[PUBLISHER] Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "fixed",
    "defaultName": "obsidian",
    "rootFolder": "",
    "yamlFolderKey": "",
    "frontmatterTitle": {
      "enable": true,
      "key": "filename"
    },
    "replaceTitle": [
      {
        "type": "title"
      }
    ],
    "replacePath": [
      {
        "regex": "",
        "replacement": "",
        "type": "path"
      }
    ],
    "autoclean": {
      "includeAttachments": true,
      "enable": true,
      "excluded": ""
    },
    "folderNote": {
      "enable": false,
      "rename": "index.md",
      "addTitle": {
        "enable": false,
        "key": "filename"
      }
    },
    "metadataExtractorPath": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [
      {
        "entry": "/(?<!\\`)\\[(.*?)\\]\\((?!(http|\\/*image|obsidian\\/image))(\\.\\/)*(.+?)(\\.md)*\\)/",
        "replace": "[$1]({% link obsidian/$4.md %})",
        "inCodeBlocks": false
      },
      {
        "entry": "/(?<!\\`)\\[(.*?)\\]\\(((obsidian\\/)?image)(.+)\\)/",
        "replace": "[$1](/image$4)"
      }
    ],
    "tags": {
      "inline": false,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": false,
      "unshared": false,
      "wiki": true,
      "slugify": false,
      "unlink": false
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [
      "obsidian"
    ],
    "notes": false,
    "folder": "images/obsidian",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": true,
    "forcePush": true
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [],
    "copyLink": {
      "enable": false,
      "links": "",
      "removePart": [
        ""
      ],
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "help"
}

Relevant log output

Nothing relevant.

OS

MacOS

Anything else?

This line shows what the plugin is outputting. It is effectively bypassing the regex: https://github.com/kurko/blog/pull/101/files#diff-d4abb3176d193679c7724481e08393a8943156ac98663bd289f488ec52a06e86R30

Obsidian information

SYSTEM INFO:
	Obsidian version: v1.7.7
	Installer version: v1.5.12
	Operating system: Darwin Kernel Version 24.2.0: Fri Dec  6 18:40:14 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8103 24.2.0
	Login status: logged in
	Language: en
	Catalyst license: insider
	Insider build toggle: off
	Live preview: off
	Base theme: light
	Community theme: obsidian_ia
	Snippets enabled: 1
	Restricted mode: off
	Plugins installed: 16
	Plugins enabled: 14
		1: Mind Map v1.1.0
		2: Tag Wrangler v0.5.3
		3: Metadata Extractor v1.0.2
		4: Dataview v0.5.67
		5: Force note view mode v1.2.2
		6: Obsidian42 - BRAT v0.6.35
		7: Reading Time v1.1.1
		8: Local images v0.14.2
		9: Commander v0.5.1
		10: Copilot v2.6.6
		11: Periodic Notes v0.0.17
		12: Advanced URI v1.44.2
		13: ToBlog v0.0.1
		14: Enveloppe v7.5.2

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.
@kurko kurko added the 🐛 Bug Something isn't working label Jan 13, 2025
@kurko
Copy link
Contributor Author

kurko commented Jan 13, 2025

For extra context, here's what Jekyll expects as links.

@Mara-Li
Copy link
Member

Mara-Li commented Jan 13, 2025

  1. The tests was deleted because I needed to refactoring the plugin codes.
  2. I didn't touch the regex code since a while. My own regex didn't move since a whiiiile.
  3. Regex continue to needs the / surrounding.

Valid critics is okay. But maintening a plugin on this size with a lot of feature is time consuming and I works alone. The lack of a valid and simple Obsidian tests is also a problem, as I don't have the time to create mock.
I know that some part of the code should be separated to use minimal obsidian code, but they are too much fonction that use little part of the Obsidian API. Typically, path handling.

You can remade a PR with updated tests if you want, as the plugin is a FOSS.

Remember that I work totally alone on this project.

@Mara-Li Mara-Li changed the title [Bug]: Regex stopped working [Bug]: Jekyll Regex stopped working Jan 13, 2025
@Mara-Li
Copy link
Member

Mara-Li commented Jan 13, 2025

PS: It is possible to have a regex101 testing link? Thanks!

@Mara-Li
Copy link
Member

Mara-Li commented Jan 13, 2025

Image

There were a new setting to change the order where regex was applied. You need to change to “apply after” :

Image

@Mara-Li Mara-Li closed this as completed Jan 13, 2025
@kurko
Copy link
Contributor Author

kurko commented Jan 19, 2025

Thanks, it worked. Is there a way of knowing when changes like this are coming? It's really hard to debug.

@Mara-Li
Copy link
Member

Mara-Li commented Jan 19, 2025

Hmm… Maybe I should add some notification in Obsidian when this type of change appear? I don't like it myself (I think it's disruptive).
Maybe made an FR if you have an idea on how I can advertise for this kind of change!

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

No branches or pull requests

2 participants