PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/sunspirit/md/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
sunspirit / md
Files
3 (gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/sunspirit/md/v0
gno
0.9

Files (3)

  • gnomod.tomltoml
  • md.gnogno
  • md_test.gnogno
md_test.gnogno
1package md23import (4	"testing"56	"gno.land/p/nt/uassert/v0"7	"gno.land/p/sunspirit/table/v0"8)910func TestNewBuilder(t *testing.T) {11	mdBuilder := NewBuilder()1213	uassert.Equal(t, len(mdBuilder.elements), 0, "Expected 0 elements")14}1516func TestAdd(t *testing.T) {17	mdBuilder := NewBuilder()1819	header := H1("Hi")20	body := Paragraph("This is a test")2122	mdBuilder.Add(header, body)2324	uassert.Equal(t, len(mdBuilder.elements), 2, "Expected 2 element")25	uassert.Equal(t, mdBuilder.elements[0], header, "Expected element %s, got %s", header, mdBuilder.elements[0])26	uassert.Equal(t, mdBuilder.elements[1], body, "Expected element %s, got %s", body, mdBuilder.elements[1])27}2829func TestRender(t *testing.T) {30	mdBuilder := NewBuilder()3132	header := H1("Hello")33	body := Paragraph("This is a test")3435	seperator := "\n"36	expected := header + seperator + body3738	output := mdBuilder.Add(header, body).Render(seperator)3940	uassert.Equal(t, output, expected, "Expected rendered string %s, got %s", expected, output)41}4243func Test_Bold(t *testing.T) {44	uassert.Equal(t, Bold("Hello"), "**Hello**")45}4647func Test_Italic(t *testing.T) {48	uassert.Equal(t, Italic("Hello"), "*Hello*")49}5051func Test_Strikethrough(t *testing.T) {52	uassert.Equal(t, Strikethrough("Hello"), "~~Hello~~")53}5455func Test_H1(t *testing.T) {56	uassert.Equal(t, H1("Header 1"), "# Header 1\n")57}5859func Test_H2(t *testing.T) {60	uassert.Equal(t, H2("Header 2"), "## Header 2\n")61}6263func Test_H3(t *testing.T) {64	uassert.Equal(t, H3("Header 3"), "### Header 3\n")65}6667func Test_H4(t *testing.T) {68	uassert.Equal(t, H4("Header 4"), "#### Header 4\n")69}7071func Test_H5(t *testing.T) {72	uassert.Equal(t, H5("Header 5"), "##### Header 5\n")73}7475func Test_H6(t *testing.T) {76	uassert.Equal(t, H6("Header 6"), "###### Header 6\n")77}7879func Test_BulletList(t *testing.T) {80	items := []string{"Item 1", "Item 2", "Item 3"}81	result := BulletList(items)82	expected := "- Item 1\n- Item 2\n- Item 3\n"83	uassert.Equal(t, result, expected)84}8586func Test_OrderedList(t *testing.T) {87	items := []string{"Item 1", "Item 2", "Item 3"}88	result := OrderedList(items)89	expected := "1. Item 1\n2. Item 2\n3. Item 3\n"90	uassert.Equal(t, result, expected)91}9293func Test_TodoList(t *testing.T) {94	items := []string{"Task 1", "Task 2"}95	done := []bool{true, false}96	result := TodoList(items, done)97	expected := "- [x] Task 1\n- [ ] Task 2\n"98	uassert.Equal(t, result, expected)99}100101func Test_Blockquote(t *testing.T) {102	text := "This is a blockquote.\nIt has multiple lines."103	result := Blockquote(text)104	expected := "> This is a blockquote.\n> It has multiple lines.\n"105	uassert.Equal(t, result, expected)106}107108func Test_InlineCode(t *testing.T) {109	result := InlineCode("code")110	uassert.Equal(t, result, "`code`")111}112113func Test_LanguageCodeBlock(t *testing.T) {114	result := LanguageCodeBlock("python", "print('Hello')")115	expected := "```python\nprint('Hello')\n```"116	uassert.Equal(t, result, expected)117}118119func Test_CodeBlock(t *testing.T) {120	result := CodeBlock("print('Hello')")121	expected := "```\nprint('Hello')\n```"122	uassert.Equal(t, result, expected)123}124125func Test_LineBreak(t *testing.T) {126	result := LineBreak(2)127	expected := "\n\n\n"128	uassert.Equal(t, result, expected)129130	result = LineBreak(0)131	expected = ""132	uassert.Equal(t, result, expected)133}134135func Test_HorizontalRule(t *testing.T) {136	result := HorizontalRule()137	uassert.Equal(t, result, "---\n")138}139140func Test_Link(t *testing.T) {141	result := Link("Google", "http://google.com")142	uassert.Equal(t, result, "[Google](http://google.com)")143}144145func Test_Image(t *testing.T) {146	result := Image("Alt text", "http://image.url")147	uassert.Equal(t, result, "![Alt text](http://image.url)")148}149150func Test_Footnote(t *testing.T) {151	result := Footnote("1", "This is a footnote.")152	uassert.Equal(t, result, "[1]: This is a footnote.")153}154155func Test_Paragraph(t *testing.T) {156	result := Paragraph("This is a paragraph.")157	uassert.Equal(t, result, "This is a paragraph.\n")158}159160func Test_Table(t *testing.T) {161	tb, err := table.New([]string{"Header1", "Header2"}, [][]string{162		{"Row1Col1", "Row1Col2"},163		{"Row2Col1", "Row2Col2"},164	})165	uassert.NoError(t, err)166167	result := Table(tb)168	expected := "| Header1 | Header2 |\n| ---|---|\n| Row1Col1 | Row1Col2 |\n| Row2Col1 | Row2Col2 |\n"169	uassert.Equal(t, result, expected)170}171172func Test_EscapeMarkdown(t *testing.T) {173	result := EscapeMarkdown("- This is `code`")174	uassert.Equal(t, result, "``- This is `code```")175}176

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.