lightbend / paradox

Markdown documentation
https://github.com/lightbend/paradox/blob/main/docs/src/main/paradox/index.md
Apache License 2.0
246 stars 76 forks source link

does not work when there are spaces in the parent path #387

Open raboof opened 4 years ago

raboof commented 4 years ago
[error] java.net.URISyntaxException: Illegal character in path at index 28: /home/aengelen/dev/akka-http docs/docs/src/main/paradox
[error]         at java.net.URI$Parser.fail(URI.java:2848)
[error]         at java.net.URI$Parser.checkChars(URI.java:3021)
[error]         at java.net.URI$Parser.parseHierarchical(URI.java:3105)
[error]         at java.net.URI$Parser.parse(URI.java:3063)
[error]         at java.net.URI.<init>(URI.java:588)
[error]         at com.lightbend.paradox.markdown.Path$.relativeLocalPath(Page.scala:234)
[error]         at com.lightbend.paradox.ParadoxProcessor.mapping$1(ParadoxProcessor.scala:413)
[error]         at com.lightbend.paradox.ParadoxProcessor.$anonfun$rootPageMappings$1(ParadoxProcessor.scala:418)
brownnrl commented 3 years ago

Would adding a replace ' ', '%20' at the link below be a possible fix?

https://github.com/lightbend/paradox/blob/e2e5b64a20d39afd88f81f1d29ecb5786005f640/core/src/main/scala/com/lightbend/paradox/markdown/Page.scala#L220

raboof commented 3 years ago

I don't know - is it possible for you to test?

brownnrl commented 3 years ago

Yeah, I'll test it. Haven't done much in the way of sbt-plugin development.

I cloned out the repo and ran an sbt compile / test, and the following tests failed:

[info] Tests: succeeded 204, failed 22, canceled 0, ignored 0, pending 0
[info] *** 22 TESTS FAILED ***
[error] Failed tests:
[error]         com.lightbend.paradox.markdown.FrontinSpec
[error]         com.lightbend.paradox.markdown.SnipDirectiveSpec
[error]         com.lightbend.paradox.markdown.SnippetIndentationTest
[error]         com.lightbend.paradox.markdown.GitHubDirectiveSpec
[error]         com.lightbend.paradox.markdown.IndexSpec
[error] (tests / Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 17 s, completed Apr 22, 2021 9:17:48 AM

All the failures had the same stack trace on a windows 10 box, scala 2.12 running sbt 1.5 which grabbed sbt 1.4.7.

[info]   java.net.URISyntaxException: Illegal character in path at index 13: /Users/(my username with spaces)/projects/paradox/.
[info]   at java.net.URI$Parser.fail(Unknown Source)
[info]   at java.net.URI$Parser.checkChars(Unknown Source)
[info]   at java.net.URI$Parser.parseHierarchical(Unknown Source)
[info]   at java.net.URI$Parser.parse(Unknown Source)
[info]   at java.net.URI.<init>(Unknown Source)
[info]   at com.lightbend.paradox.markdown.Path$.relativeLocalPath(Page.scala:235)

Probably adding a specific whitespace inclusive test to the PathSpec would be warranted. https://github.com/lightbend/paradox/blob/e2e5b64a20d39afd88f81f1d29ecb5786005f640/tests/src/test/scala/com/lightbend/paradox/markdown/PathSpec.scala

I'll let you know where I get and will create a PR if string replacement into the URI fixes it.

brownnrl commented 3 years ago

Adding a simple additional replace call to .repalce('\\','/').replace(" ", "%20") fixed one test and then caused some missing resource stack traces. I'm at the end of time I can allot to it today, and I'm not sure when I will come back to it so I'll attach these sbt test results with that one change to put a pin in it for the time being. test_results.txt .

raboof commented 3 years ago

I'm at the end of time I can allot to it today, and I'm not sure when I will come back to it so I'll attach these sbt test results with that one change to put a pin in it for the time being.

Thanks for nudging this forward!