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

Support source maps #614

Open
asbjornu opened this issue Dec 27, 2020 · 4 comments
Open

Support source maps #614

asbjornu opened this issue Dec 27, 2020 · 4 comments

Comments

@asbjornu
Copy link
Contributor

With tools such as markdown-it-source-map it is possible to add source maps in the form of data-source-line attributes to generated HTML in order to provide more meaningful error messages from the generated HTML. Is this something HTMLProofer would be OK to add support for?

I haven't researched how to get source maps into our Jekyll pipeline, but I suppose it's possible to hook into Kramdown to add this through a Jekyll plugin somehow.

Thoughts?

@gjtorikian
Copy link
Owner

Is there a Ruby version of that tool available?

@asbjornu
Copy link
Contributor Author

Not that I've been able to find, no. But I assume it's simple enough to extend the Kramdown::Converter::Html class and override the necessary methods. We already do that in kramdown-plantuml to add support for PlantUML code.

@gjtorikian
Copy link
Owner

It's an interesting idea but it presupposes that the HTML would come from Markdown. I'd have to think a bit on how to support such a thing. html-proofer is "source agnostic" and only runs on the HTML files. So such a change (in theory) would have to read the HTML, and the source map, to provide the original Markdown location.

@asbjornu
Copy link
Contributor Author

asbjornu commented Jan 4, 2021

We could make it source agnostic by adding something like this to every HTML document:

<html data-source="../pages/source-markdown.md">

The data-source attribute would contain the relative path to the source of the generated HTML document, which could be in any format.

If I were to write a plugin to generate something like this for Kramdown and Jekyll, I would probably emit the attributes only when JEKYLL_ENV is different to production.

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

No branches or pull requests

2 participants