-
Notifications
You must be signed in to change notification settings - Fork 388
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
feat(examples): Add Gno Package for Markdown Rendering #2811
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package appears to be a port of github.com/russross/blackfriday.
Since the original repository uses a BSD license, you need to maintain the original copyright notice and license terms.
Please add a LICENSE file to the root directory of your project. Specifically, please add a file named 'LICENSE' in the root directory.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2811 +/- ##
==========================================
+ Coverage 60.84% 60.86% +0.01%
==========================================
Files 563 563
Lines 75190 75190
==========================================
+ Hits 45753 45765 +12
+ Misses 26068 26058 -10
+ Partials 3369 3367 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left some improvements, mostly they are slice range check relates. Please check and apply them. Thank you.
+) CI failing. Please run gno mod tidy
on the markdown directory.
@@ -0,0 +1,5 @@ | |||
module gno.land/r/demo/varmeta_md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing the package name to md
or markdown
?
data = data[offset:] | ||
c := data[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing data[0]
when the data slice is empty can cause a runtime panic. I think need to check the length of data to prevent accessing an empty slice.
data = data[offset:] | |
c := data[0] | |
data = data[offset:] | |
if len(data) == 0 { | |
return 0 | |
} | |
c := data[0] |
This pattern is also found in other functions (e.g., codeSpan
). please check them just for safety.
if data[0] != '#' { | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add slice bound check here as well.
if data[0] != '#' { | |
return false | |
} | |
if len(data) == 0 || data[0] != '#' { | |
return false | |
} |
c := data[i] | ||
|
||
n := 0 | ||
for data[i] != '\n' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add index range check here
for data[i] != '\n' { | |
for i < len(data) && data[i] != '\n' { |
I have update the pull request follow your comment. Thank for your suggestion! |
Hey @thanhngoc541 - just like #2947, we don't really want to have a HTML library. The point of the Markdown UI bounty was to have a Go-like way to write markdown, instead of manually concatenating strings. This PR adds a processor that converts that already impractical string concatenation into HTML. We don't intend to have either. Thank you for your effort, but you can close this PR. |
Related to #2753
This pull request introduces a new Gno package that utilizes the blackfriday library to render Markdown into HTML.
Supported Markdown Syntax:
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description