Adding "Mycomarkup" as a custom renderer

Author Topic
mysh

m

Posted on

This markup language is used in the Mycorrhiza wiki engine. Documentation on Mycomarkup can be found here: https://mycorrhiza.wiki/help/en/mycomarkup

Implementation

First import Mycomarkup v5: go get git.sr.ht/~bouncepaw/mycomarkup/v5.

And then we can follow the process of creating a custom renderer as in adding Blackfriday markdown renderer.

Let’s create convert_mycomarkup.go in the /syntax folder and use build flags just like in the tutorial above!

//go:build mycomarkup
// +build mycomarkup

package syntax

import (
	"git.sr.ht/~bouncepaw/mycomarkup/v5"
	"git.sr.ht/~bouncepaw/mycomarkup/v5/mycocontext"
	"git.sr.ht/~bouncepaw/mycomarkup/v5/options"
	"strings"
)

var opts = options.Options{
	HyphaName:             "",
	WebSiteURL:            "",
	TransclusionSupported: false,
	RedLinksSupported:     false,
	InterwikiSupported:    false,
}.FillTheRest()

func Convert(gmi string, wrap bool) string {
	clearedString := strings.ReplaceAll(gmi, "\r\n", "\n")
	ctx, _ := mycocontext.ContextFromStringInput(clearedString, opts)
	return mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx))
}

And then we can compile vpub-plus with tag mycomarkup: go build -tags mycomarkup .

Caveats

Since mycomarkup has some special sauce called hyphaes and transclusion, we can’t really add it directly to our renderer - we just don’t have enough context for it.

Last edited on