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

Automatic linking when syntax highlighting #17

Closed
hadley opened this issue May 27, 2020 · 8 comments
Closed

Automatic linking when syntax highlighting #17

hadley opened this issue May 27, 2020 · 8 comments

Comments

@hadley
Copy link
Member

hadley commented May 27, 2020

Need to post process to:

  1. Convert .md to .json ast using pandoc
  2. Read json into R, then apply pkgdown highlighting to each code chunk
  3. Convert back to .json

Note that goldmark does not preserve raw html (like pandoc does), so it would need to include a shortcode in the output, along the lines of https://anaulin.org/blog/hugo-raw-html-shortcode/

@maelle

This comment has been minimized.

@hadley

This comment has been minimized.

@maelle

This comment has been minimized.

@hadley

This comment has been minimized.

@jemus42

This comment has been minimized.

@jemus42
Copy link

jemus42 commented May 27, 2020

Re: goldmark not preserving raw HTML: This is the default, but not only behavior. I tried the example from the linked blog post and included the following in a plain .md post rendered by goldmark:

<p class="speshal-fancy-custom">
    This is <strong>raw HTML</strong>, inside Markdown.
</p>

And the output is rendered correctly:
image

I think the relevant bit there is the unsafe setting in the goldmark config in my config.toml:

unsafe
By default, Goldmark does not render raw HTMLs and potentially dangerous links. If you have lots of inline HTML and/or JavaScript, you may need to turn this on.

[markup]
  defaultMarkdownHandler = "goldmark"
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

That way you would have to insist on this configuration, but would get away without an extra shortcode, but this option is already mentioned in the README anyway?

@hadley
Copy link
Member Author

hadley commented May 27, 2020

@jemus42 to see the problem you have to indent the raw html by 4 spaces

    <p class="speshal-fancy-custom">
        This is <strong>raw HTML</strong>, inside Markdown.
    </p>

@hadley hadley closed this as completed in 2837503 Jun 1, 2020
@hadley
Copy link
Member Author

hadley commented Jun 1, 2020

Currently a bit slow; will have to improve performance in downlit.

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

3 participants