deiucanta / chatpad

Not just another ChatGPT user-interface!
https://chatpad.ai
GNU Affero General Public License v3.0
1.36k stars 253 forks source link

add basic syntax highlighting of code blocks with highlight.js #54

Open thavelick opened 1 year ago

thavelick commented 1 year ago

for #35

This implementation works but has a few potential issues that may or may not be a problem for the maintainers:

  1. There's a typescript error because the <Code> component expects children, but we can't provide both children and dangerouslySetHtml
  2. There may be a better way to exclude children from props before passing them to <Code>.
  3. There may be a better way to convert children to a string before passing to hljs.
  4. The background color for code blocks seems to come from the markdown display library rather than hljs. With the github.css theme currently used this looks fine, but other hljs themes can look pretty bad as they expect a black background.
thavelick commented 1 year ago

Also - not sure if I should be including the changes to package-lock.json and yarn-lock.json. Let me know if I should exclude those