-
Notifications
You must be signed in to change notification settings - Fork 404
feat(gnoweb): readme markdown viewer for p/ & r/ #4101
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
base: master
Are you sure you want to change the base?
feat(gnoweb): readme markdown viewer for p/ & r/ #4101
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
First comment pass; I need to delve deeper for a full review, but I will wait for you to resolve the preliminary comments.
markdown: goldmark.New( | ||
goldmark.WithExtensions( | ||
markdown.GnoExtension, | ||
), | ||
), |
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.
the mock cannot depend on goldmark
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 test file doesn't make sense, you are not testing html client but the mock itself.
If no tests were existing before, it is because we need to have a mock for the RPC client itself to be able to test the HTML client.
// If writer is nil, just return metadata | ||
if w == nil { | ||
return &fileMeta, nil | ||
} | ||
|
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.
writer cannot and should not be nil; remove this. it will complexity the caller logic
} | ||
|
||
// RenderMd renders a markdown file and returns the rendered content | ||
func (s *HTMLWebClient) RenderMd(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { |
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.
func (s *HTMLWebClient) RenderMd(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { | |
func (s *HTMLWebClient) RenderMarkdownFile(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { |
type DisplayMode int | ||
|
||
const ( | ||
ModeCode DisplayMode = iota | ||
ModeMarkdown | ||
) |
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.
No, if you are using this within the template, it makes no sense to use int here. Just change this to string, or find a way to expose this as const within the template. But if it's not something simple, simply use string.
type DisplayMode int | |
const ( | |
ModeCode DisplayMode = iota | |
ModeMarkdown | |
) | |
type DisplayMode string | |
const ( | |
ModeCode DisplayMode = "code" | |
ModeMarkdown = "markdown" | |
) |
This PR implements a new feature to display README.md files in a formatted way for both
pures
(p/) andrealms
(r/) in gno.land. This would apply inDirectory
template and inSource
template.Changes
Added a new
RenderMd
method toHTMLWebClient
that:SourceFile
ParseMarkdown
functionModified the
GetDirectoryView
handler to:README.md
in the directoryREADME.md
to the first position in the file listReuse code to create a new
generateTOC
helper method toHTMLWebClient
that:RealmView
settings)In Source template, a markdown file is automatically rendered with Goldmark in HTML:
plain
WebQuery to force code view for markdown filesBenefits
Technical Details
This feature enhances the user experience by making documentation more accessible and readable directly in the web interface.
TODO
code
<->html
)In Directory template
In Source template