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

lint embedded code #19

Open
micheelengronne opened this issue Apr 2, 2020 · 2 comments
Open

lint embedded code #19

micheelengronne opened this issue Apr 2, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@micheelengronne
Copy link

I currently have separated doc linted with markdown-lint and scripts linted with shellcheck. I would like to merge the 2 to avoid doc maintenance.

Is there a way to run shellcheck with codebraid to lint the embedded code and not break the execution afterward ?

Thanks.

@gpoore
Copy link
Owner

gpoore commented Apr 2, 2020

There isn't a built-in way to do this, but there are several ways it could be done.

The fastest way to get something working would be to extract the code from the markdown via regex and then lint it, keeping track of line numbers between markdown and extracted code for tracing back line numbers. You could take the shellcheck messages, and then substitute line numbers to get back to markdown. I'm planning to add a codebraid feature that will allow all embedded code to be extracted and saved into separate files, so at some point using that will be an option. That will be cleaner than using a regex, but otherwise similar overall.

Here's another option that may be more interesting, but would also involve a bit more work and thus could take longer to get going. codebraid already has built-in machinery for treating code as input for a compiler or interpreter, and then syncing stdout and stderr with markdown and including it in the output document. I could modify that slightly so that code can also be treated as input for a linter, and then linting messages could appear in the output document next to the relevant code just like stderr does now.

@micheelengronne
Copy link
Author

That looks promising. I will test the codebraid feature that extracts code when released. I put this issue in my bookmarks.

@gpoore gpoore added the enhancement New feature or request label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants