carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
42 stars 27 forks source link

Error in rendering links on instructor view #404

Closed brownsarahm closed 1 year ago

brownsarahm commented 1 year ago

When we include images, we can use the relative path and sandpaper turns it into the correct path after building: https://preview.carpentries.org/instructor-training/fig/mental_models.svg,

but when we have links in an instructor note, it turns relative paths into:

https://preview.carpentries.org/instructor-training/instructor/fig/array-math.png

when the correct path should be:

https://preview.carpentries.org/instructor-training/fig/array-math.png

this is the underlying cause of: https://github.com/carpentries/instructor-training/issues/1501

zkamvar commented 1 year ago

The reason why this was not caught is because instructor pages live inside of the instructor/ subfolder, which only copies the HTML pages, not the assets. Images are accurately rendered because we have a function that takes the images from the HTML and adds a backtrace to the path:

https://github.com/carpentries/sandpaper/blob/4eebe102f640d0fa53039dea070054bf6bc51f6d/R/utils-xml.R#L115-L123

However, I did not go further with internal links because that ended up always taking people outside of instructor mode, but I could explicitly filter for relative links that are not HTML.

zkamvar commented 1 year ago

And yes, I am embarrased by the dead code inside that function.