Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.79k stars 860 forks source link

feat: Implement flutter_html_code extension #1293

Closed krille-chan closed 1 year ago

krille-chan commented 1 year ago

This is my attempt to contribute an official extension. Just uses the flutter_highlighter package to render nice code blocks. I have this already in use in two of my Flutter apps :)

Sub6Resources commented 1 year ago

Thank you for the contribution! Your pull request has raised a good question: What type of official extensions for flutter_html should we maintain in this repository?

Here's a rough outline, with more to come in the wiki soon:

  1. Does the extension add functionality supported by major browsers today, but not supported by flutter_html? If no, consider releasing as a third-party extension package.
  2. Does the extension depend on a third-party package? If no, consider adding to the core flutter_html library as a built-in HtmlExtension.
  3. Is the extension generally helpful and useable? If no, consider releasing as a third-party extension package.
  4. Is the extension of high quality? If no, consider adding tests and documentation to improve the quality of the package.

Although this extension you've written meets the last three points, the answer to the first question is a no. I'm not aware of any major browsers that perform automatic syntax highlighting in <code> blocks, without external Javascript. (Please let me know if I'm mistaken!)

As such, I highly encourage you to publish this as your own standalone package! Syntax highlighting is definitely useful, even if major browsers (and thus flutter_html) don't perform it automatically. See https://dart.dev/tools/pub/publishing for best practices and tips for getting started with publishing your own packages.

Let me know if you have any questions!

krille-chan commented 1 year ago

Thank you very much for your response and I totally agree with you. I will publish it as a standalone package on pub.dev and link it here later