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

Change backslash to forward slash on windows #66

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

christianjann
Copy link
Contributor

Change backslash to forward slash for windows compatibility

rel_path might be something like d2\1.1.svg which does not work in html

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.18%. Comparing base (fbd3661) to head (3e66980).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
+ Coverage   77.82%   78.18%   +0.36%     
==========================================
  Files           4        4              
  Lines         239      243       +4     
==========================================
+ Hits          186      190       +4     
  Misses         53       53              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danieleades
Copy link
Owner

thanks for the contribution!

It would be good to first see a failing test without this change, then to see the test succeed after the change

@christianjann
Copy link
Contributor Author

thanks for the contribution!

It would be good to first see a failing test without this change, then to see the test succeed after the change

Not sure yet how to best test this, how to check the generated html for the correct path, might be better to just merge and unblock other windows users and maybe think about some generic end-2-end tests later.

@danieleades
Copy link
Owner

unfortunately testing on windows is blocked on terrastruct/d2#2044

@@ -151,7 +151,11 @@ impl Backend {
Event::Start(Tag::Paragraph),
Event::Start(Tag::Image {
link_type: LinkType::Inline,
dest_url: rel_path.to_string_lossy().to_string().into(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this definitely necessary?
markdown should be platform-independent. I don't believe backslashes are required in filepaths embedded in markdown, even in a windows environment

Copy link
Contributor Author

@christianjann christianjann Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this definitely necessary? markdown should be platform-independent. I don't believe backslashes are required in filepaths embedded in markdown, even in a windows environment

No they should not be there, but somehow the backslash came in and in the html it was then escaped with some %HexNumber, will try to run the integration tests on Windows and paste the output

https://users.rust-lang.org/t/path-to-url-easiest-way/28632

Something like this might also work: path.components().map(|c| urlencode(c.as_bytes())).join("/")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running cargo test without and with my commit:
image
Unfortunately temp file is gone but the test proves the expected string is not there ;)

Change backslash to forward slash for windows compatibility

rel_path might be something like d2\1.1.svg which does not work in html
@danieleades danieleades merged commit 21c517c into danieleades:main Aug 5, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants