Replies: 3 comments 4 replies
-
The two formats you have tried are indeed not supposed to work. The spec-compliant way to specify link destinations with spaces is to enclose the target within angle brackets: [File with spaces](<File with spaces.md>) However, sadly, this does not work in latest Laika either, and that is indeed a bug. Fortunately it's trivial to fix and this PR (#385) takes care of that. Unfortunately for the latest release I'm not aware of any workaround, so your options boil down to:
|
Beta Was this translation helpful? Give feedback.
-
My tests on branch md-link-targets and directory.conf with
laikaSite error:
renders incorrect as:
so link doesn't work because filename extension is not .html
Renders correct as:
So turning off validation is not a solution for me. For tests I've made change in laika.ast.RelativePath#parse - from:
to
And it works - rendered html is:
|
Beta Was this translation helpful? Give feedback.
-
Ah, yes. Sorry, I initially thought that 2) would work as I wrongly expected the suffix translation would still happen, but it does not (and for good reasons, so this approach is indeed not viable). I edited my initial response to avoid any confusion. Solution 3) looks neat, but is not an option either, because But fortunately I found something that actually works (and this time I tested it). I don't know why I did not think of this right away, but you can easily transform the AST between parsing and rendering yourself if you need adjustments for specific tools. import laika.ast._
val rules = RewriteRules.forSpans {
case ref: LinkPathReference => Replace(ref.copy(path =
VirtualPath.parse(java.net.URLDecoder.decode(ref.path.toString, "UTF-8"))
))
} How you register the rule depends on whether you use the sbt plugin or the library API. For the plugin: laikaExtensions += laikaRewriteRules(rules) For the library API: val transformer = Transformer
.from(Markdown)
.to(HTML)
.usingRules(rules)
.build The rewrite rule is applied before the validation phase, so you don't need to disable anything. This works with Laika 0.19.0, but not with older versions. The concepts behind AST rewriting are documented in this chapter: https://planet42.github.io/Laika/latest/04-customizing-laika/05-ast-rewriting.html |
Beta Was this translation helpful? Give feedback.
-
I have a file name
File with spaces.md
And in another file I'd like to put a link to the first one.
I've tried:
But I've got:
So I've tried:
But I've got:
Is it a bug?
BTW I try to use Obsidian.md to edit markdown files and then publish them using Laika.
Beta Was this translation helpful? Give feedback.
All reactions