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]: Regular expression replacement cannot add line breaks. #381

Closed
2 tasks done
ForsakenDelusion opened this issue Jan 26, 2025 · 2 comments
Closed
2 tasks done
Assignees
Labels
🐛 Bug Something isn't working

Comments

@ForsakenDelusion
Copy link

Issue validation

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

Command used

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

Plugin version

7.5.3

Describe the bug

As the title suggests, regular expression replacement cannot add line breaks. After consulting the information, it appears that this might be an issue with Obsidian, but I'm not sure if this plugin can resolve it? Thank you !

/([\s\S]*?)/ -> \n{% raw %}\n$1\n{% endraw %}\n ⬇️ <>

let

brew install hugo

become
\n{% raw %}\n```shell
brew install hugo


### How to reproduce ?

_No response_

### Minimal Reproducible Example

```markdown
Add regular expression replacement rules.
/([\s\S]*?)/  ->  \n{% raw %}\n$1\n{% endraw %}\n  ⬇️  <
Then publish the article.

it let

brew install hugo

become
\n{% raw %}\n
brew install hugo
\n{% endraw %}\n

Configuration

{
  "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": "[PUBLISHER] Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "yaml",
    "defaultName": "_posts",
    "rootFolder": "_posts",
    "yamlFolderKey": "dir",
    "frontmatterTitle": {
      "enable": true,
      "key": "filename"
    },
    "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": "/\\]\\(([^)\\.]+)\\.md/",
        "replace": "]({{< relref \"$1.md\" >}}",
        "flags": "",
        "after": false,
        "inCodeBlocks": false
      },
      {
        "entry": "/cover\\.image/",
        "replace": "cover:\\n    image",
        "flags": "",
        "after": true
      },
      {
        "entry": "/\\]\\(([^/\\)]+?)\\.(png|jpg|jpeg|webp|gif)/",
        "replace": "](/images/$1.$2",
        "flags": "",
        "after": false
      },
      {
        "entry": "/([\\s\\S]*?)/",
        "replace": "\\n    {% raw %}\\n    $1\\n    {% endraw %}\\n    ",
        "flags": "",
        "after": false,
        "inCodeBlocks": true
      }
    ],
    "tags": {
      "inline": true,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": false,
      "wiki": true,
      "slugify": "lower",
      "unlink": false
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [
      {
        "path": "{{default}}",
        "destination": "{{name}}/../images",
        "forcePush": true
      }
    ],
    "keySendFile": [],
    "notes": false,
    "folder": "assets/images",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": true,
    "forcePush": true,
    "forcePushAttachments": [],
    "useObsidianFolder": false
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [],
    "copyLink": {
      "enable": false,
      "links": "",
      "removePart": [],
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "text-conversion"
}

Relevant log output

OS

MacOS

Anything else?

No response

Obsidian information

SYSTEM INFO:
	Obsidian version: v1.7.7
	Installer version: v1.7.7
	Operating system: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000 24.1.0
	Login status: not logged in
	Language: zh
	Insider build toggle: off
	Live preview: on
	Base theme: dark
	Community theme: Things v2.1.20
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 14
	Plugins enabled: 14
		1: Remotely Save v0.5.25
		2: WordPress v0.18.0
		3: Remember cursor position v1.0.9
		4: Latex Suite v1.9.7
		5: Clear Unused Images v1.1.1
		6: markdown export v1.0.24
		7: Link Converter v0.1.6
		8: Workspaces Plus v0.3.3
		9: Git v2.31.1
		10: Tasks v7.14.0
		11: Templater v2.9.1
		12: Dataview v0.5.67
		13: Enveloppe v7.5.3
		14: Paste image rename v1.6.1

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.
@ForsakenDelusion ForsakenDelusion added the 🐛 Bug Something isn't working label Jan 26, 2025
@ForsakenDelusion ForsakenDelusion changed the title [Bug]: 正则替换无法添加换行 [Bug]: Regular expression replacement cannot add line breaks. Jan 26, 2025
@Mara-Li
Copy link
Member

Mara-Li commented Jan 26, 2025

  1. Add a regex101 reproduction : https://regex101.com/ ; don't forget to select EMACScript
  2. Pretty sure it's your regex that have a problem, because a simple regex with like : (x)(test) replaced as $1\n$2 works.
  3. Please open discussion for problem with regex.

@Mara-Li Mara-Li closed this as completed Jan 26, 2025
@ForsakenDelusion
Copy link
Author

Thank you for your patient responses! Appreciate.

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