Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

thanhngoc541
Copy link

@thanhngoc541 thanhngoc541 commented Sep 18, 2024

Related to #2753

This pull request introduces a new Gno package that utilizes the blackfriday library to render Markdown into HTML.

Supported Markdown Syntax:

  • Headers (#, ##, ###, etc.)
  • Lists (ordered and unordered)
  • Links and Images
  • Code blocks and inline code
  • Emphasis (bold and italic)
  • Blockquotes

Screenshot 2024-09-18 at 17 46 26
Screenshot 2024-09-18 at 17 46 33

func RenderExampleHeader() string {
	input := `
# Heading Level 1
## Heading Level 2
### Heading Level 3
#### Heading Level 4
##### Heading Level 5
###### Heading Level 6
`
	out := runMarkdown(input)
	return out
}
func RenderExampleLists() string {
	input := `
# Unordered List

* Item 1
    * Subitem 1.1
    	* Subitem 1.1.1
* Item 2
    * Subitem 2.1
    	* Subitem 2.1.1


# Ordered List

1. First item
   1. Subitem 1.1
      1. Subitem 1.1.1
2. Second item
   1. Subitem 2.1
      1. Subitem 2.1.1
`

	out := runMarkdown(input)

	return out
}
func RenderExampleLinkAndImage() string {
	input := `
# Link And Image
Here is a [link to VarMeta](https://www.var-meta.com/).
![Gno logo](https://www.var-meta.com/favicon-16x16.png)
`

	out := runMarkdown(input)

	return out
}
func RenderExampleCode() string {
	input := `# Code Block
Here is an inline code example: ` + "`" + `fmt.Println("Hello Gno!")` + "`" + `.

` + "``` go\n" + `func foo() bool {
	return true;
	}
` + "```\n"

	out := runMarkdown(input)

	return out
}
func RenderExampleEmphasis() string {
	input := `# Emphasis
This is **bold** text, and this is _italic_ text.
`
	out := runMarkdown(input)
	return out
}
func RenderExampleBlockquote() string {
	input := `# Blockquote #
> This is a blockquote.

> Here is another blockquote with **bold** and _italic_ text.
`

	out := runMarkdown(input)

	return out
}
func RenderExampleTable() string {
	input := `# Table
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1   | Cell 2   |
| Cell 3   | Cell 4   |
`
	out := runMarkdown(input)
	return out
}
image
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@thanhngoc541 thanhngoc541 requested review from a team as code owners September 18, 2024 04:49
@thanhngoc541 thanhngoc541 requested review from sw360cab and ltzmaxwell and removed request for a team September 18, 2024 04:49
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Sep 18, 2024
@thanhngoc541 thanhngoc541 changed the title Add Gno Package for Markdown Rendering feat: Add Gno Package for Markdown Rendering Sep 18, 2024
@thanhngoc541 thanhngoc541 changed the title feat: Add Gno Package for Markdown Rendering feat(examples): Add Gno Package for Markdown Rendering Sep 18, 2024
@thinhnx-var
Copy link
Contributor

@moul @leohhhn
We are pushing more usage examples to indicate what this package can do.
Could you take a look on this PR and give us review if we are going into right approach or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants