Skip to content

feat: add callback on codeblocks #191

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

Merged
merged 3 commits into from
Sep 21, 2023
Merged

feat: add callback on codeblocks #191

merged 3 commits into from
Sep 21, 2023

Conversation

youkwhd
Copy link
Contributor

@youkwhd youkwhd commented Sep 21, 2023

Changed the writing behavior of codeblock transformer (buffering it first)

An example of a use case:

(markdown/md-to-html-string "```python\ndef f(x):\n    return x * 2\n```"
                       :codeblock-callback (fn
                                             [code language]
                                             (trim (clygments/highlight code language :html))))

Code above would syntax highlight codeblocks without being bothered to convert the Markdown to HTML first then calling libraries like highlight.js with JavaScript

References:

Changed the writing behavior of codeblock transformer (buffering it
first)

An example of a use case:

    (markdown/md-to-html-string "```python\ndef f(x):\n    return x * 2\n```"
                           :codeblock-callback (fn
                                                 [code language]
                                                 (trim (clygments/highlight code language :html))))

Code above would syntax highlight codeblocks without being bothered to
convert the Markdown to HTML first then calling libraries like
highlight.js with JavaScript

References:
- https://en.wikipedia.org/wiki/Data_buffer
- https://github.com/bfontaine/clygments
- https://pygments.org/
@yogthos yogthos merged commit b6956b3 into yogthos:master Sep 21, 2023
@yogthos
Copy link
Owner

yogthos commented Sep 21, 2023

Thanks for the pr, just pushed out 1.11.5 with the feature to Clojars.

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