Closed quinn-p-mchugh closed 1 year ago
Real question: did you try to use the regex replacement of contents to remove the .MD extension?
Probably something with \((.*)\.md(.*)\)
→ ($1$2)
See https://regex101.com/r/2xMqDG/1
You can remove the #
part with juste using ($1)
as replacement.
Hi @Lisandra-dev,
Great question - this may very well be a case of user error!
I'll give the above suggestion a try, but given that use of backslashes yields an error (see #172), I'll need to wait until the new release to begin testing.
Thanks for your prompt response! Very much appreciate the help here.
FWIW, I've confirmed that the following (non-regex) replacement does not remove the .md
extension.
Also: thank you for filling in the issue title - I neglected to do this by mistake. My apologies.
As I said in my first post, you need to set the regex in the content remplacement. Not in the path remplacement.
Hi @Lisandra-dev,
Ah, thank you - I'll read more carefully next time.
Hmmm... it seems the following settings in the Text replacer
setting do not remove the .md
extension from links.
I've verified convertWikiLinks
function is called before the findAndReplaceText
function, so no issues there.
I might have to do some debugging on my end to see what might be going awry.
In any case, here's my settings and test content, in case anything jumps out at you.
{
"github": {
"branch": "main",
"automaticallyMergePR": true,
"tokenPath": "%configDir%/plugins/%pluginID%/env",
"api": {
"tiersForApi": "Github Free/Pro/Team (default)",
"hostname": ""
},
"workflow": {
"commitMessage": "[Obsidian GitHub Publisher] Merge",
"name": ""
},
"verifiedRepo": true
},
"upload": {
"behavior": "yaml",
"defaultName": "docs",
"rootFolder": "",
"yamlFolderKey": "publish-path",
"frontmatterTitle": {
"enable": true,
"key": "publish-filename"
},
"replaceTitle": [
{
"regex": "/\\s+/",
"replacement": "-",
"type": "title"
}
],
"replacePath": [],
"autoclean": {
"enable": false,
"excluded": []
},
"folderNote": {
"enable": false,
"rename": "index.md"
},
"metadataExtractorPath": ""
},
"conversion": {
"hardbreak": false,
"dataview": true,
"censorText": [
{
"entry": "/\\.md/",
"replace": "//",
"after": false
},
{
"entry": ".md",
"replace": "",
"after": false
},
{
"entry": "/\\((.*)\\.md(.*)\\)/",
"replace": "/$1$2/",
"after": false
},
{
"entry": "/\\.md/",
"replace": "",
"after": false
}
],
"tags": {
"inline": false,
"exclude": [],
"fields": []
},
"links": {
"internal": true,
"unshared": false,
"wiki": true,
"slugify": true
}
},
"embed": {
"attachments": true,
"keySendFile": [],
"notes": true,
"folder": ""
}
}
---
publish: true
publish-path: blog/2022
publish-filename:
---
[[test-docs-post]]
---
publish: true
publish-path: docs
publish-filename:
---
[[test-blog-post]]
---
publish: true
publish-path: blog/2022
publish-filename:
---
[test-docs-post](../../docs/test-docs-post.md#)
---
publish: true
publish-path: docs
publish-filename:
---
[test-blog-post](../blog/2022/test-blog-post.md#)
Change the arrow to down :)
Ah, shoot. Thank you @Lisandra-dev! Changing the arrow to down resolved my issue.
I've provided the full resolution below for anyone with similar inquiries.
.md
from markdown links)Content's conversion
section.[[Wikilinks]] to [MDlinks](links)
settings is enabled.Text replacer
setting.Value to Replace
, enter the following regex: /(\[.*?\]\(.*?).md(.*?\))/
(see here for explanation)Replacement
, enter $1$2
Save
The markdown links generated by Obsidian GitHub publisher should now omit the .md
extension while maintaining any anchor links (link#my-heading
). This should resolve cross-section (blog
--> docs
) linking issues with Docusarus.
It seems it the links in dataview are not being replaced. can anyone verify?
What do you mean by the links in dataview ?
Tables in dataview have a link called File
, which is a link.
No problem on my side :/
Here my settings tested:
"conversion": {
"hardbreak": false,
"dataview": true,
"censorText": [
{
"entry": "/(\\[.*?\\]\\(.*?).md(.*?\\))/",
"replace": "$1$2",
"flags": "",
"after": true
}
],
"tags": {
"inline": false,
"exclude": [],
"fields": []
},
"links": {
"internal": true,
"unshared": true,
"wiki": true,
"slugify": false
}
mine is this:
"conversion": {
"hardbreak": true,
"dataview": true,
"censorText": [
{
"entry": "/(\\[.*?\\]\\(.*?).md(.*?\\))/",
"replace": "$1$2",
"flags": "",
"after": true
}
],
"tags": {
"inline": false,
"exclude": [],
"fields": []
},
"links": {
"internal": true,
"unshared": false,
"wiki": true,
"slugify": true
}
},
in your screenshot, it seems that only the first row of the table was replaced but other links are still with .md
is that right?
Oh, yeah, I think you need to use g
in the regex. Like that: /(\[.*?\]\(.*?).md(.*?\))/g
I have added g at the end. but no matter if it is added or unadded. .md is still not being replaced.
Works on my side :/
I rebuilt my repo and it is working now. thanks. (the plugin was not pushing changes after editing at all.
Issue validation
Is your feature related to a problem ?
I recently confirmed that Docusaurus does not support relative markdown linking between blog and doc pages.
This means that the relative markdown links (
[link](../../docs/.md#)
) generated by the Obsidian GitHub Publisher plugin do not work for links between pages in theblog
section and thedocs
section any Docusaurus website. This might be fixed in the future, but one of the lead developer's notes that this would require a significant change to how links are routed in Docusaurus.However, using standard URL links (without the
.md
extension) work just fine.For example: If I provide a link in a blog post like
[link](../../docs/relevant-doc-page.md#)
, the link does not work.whereas...
When I remove the
.md
extension ([link](../../docs/relevant-doc-page)
), the link routes successfully.What solution do you want to see ?
As a workaround, I'd like an option to remove the
.md
extension from all wikilinks that are converted to relative markdown links, so these links work properly on websites built with Docusaurus.So instead of:
[link](../../docs/relative-doc-page.md#)
It should be:
[link](../../docs/relative-doc-page)
This could be a matter of including the file extension in any user-specified regular expressions in the
Apply edit on the folder path or filename (automatically)
setting, allowing users to remove the.md
file extension by specifying.md
underValue to replace
and nothing for theReplacement
value.Describe the alternative you've considered
Other solutions might look like:
Omit .md file extension?
) in theContent's conversion
section to omit the.md
file extension for any[[Wikilinks]]
that are converted to[MDlinks](links)
.OS
Windows
Anything else?
I think enabling the ability to modify file extensions (in addition to filename and folder path) in the
Apply edit on the folder path or filename (automatically)
setting would be the most flexible solution. However, this may or may not cause issues in the event that users' existing regex replace settings happen to match the.md
file extension.Plugin version
6.2.5
Obsidian version & debug log