mdcmd

package
v0.0.0-...-9c55465 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Markdown2HTML = &gcli.Command{
	Name:    "html",
	Desc:    "convert one or multi markdown file to html",
	Aliases: []string{"tohtml"},

	Func: mh.Handle,
	Config: func(c *gcli.Command) {
		c.BoolOpt(&mh.toc, "toc", "", false,
			"Generate a table of contents (implies --latex=false)")
		flag.BoolVar(&mh.tocOnly, "toconly", false,
			"Generate a table of contents only (implies -toc)")
		c.BoolOpt(&mh.page, "page", "", false,
			"Generate a standalone HTML page (implies --latex=false)")
		c.BoolOpt(&mh.latex, "latex", "", false,
			"Generate LaTeX output instead of HTML")

		c.BoolOpt(&mh.smartyPants, "smartypants", "", true,
			"Apply smartypants-style substitutions")
		c.BoolOpt(&mh.latexDashes, "latexdashes", "", true,
			"Use LaTeX-style dash rules for smartypants")
		c.BoolOpt(&mh.fractions, "fractions", "", true,
			"Use improved fraction rules for smartypants")
		c.BoolOpt(&mh.htmlSimple, "html-simple", "", true,
			"Sets HTML output to a simple, just bare minimum HTML tags and attributes")

		c.StrOpt(&mh.css, "css", "", "",
			"Link to a CSS stylesheet (implies --page)")
		c.StrOpt(&mh.output, "output", "", "",
			"the rendered content output, default output STDOUT")
		c.StrOpt(&mh.driver, "driver", "", "bf",
			`set the markdown renderer driver.
allow:
gm,gmd,gomd - gomarkdown
gd,gdm 		- goldmark
`)

		c.AddArg("files", "the listed files will be render to html", false, true)

		mh.cmd = c
	},
}

Markdown2HTML Convert Markdown to HTML styles from https://github.com/facelessuser/MarkdownPreview

"image_path": "https://github.githubassets.com/images/icons/emoji/unicode/", "non_standard_image_path": "https://github.githubassets.com/images/icons/emoji/"

View Source
var Markdown2SQL = &gcli.Command{
	Name:    "sql",
	Aliases: []string{"tosql"},
	Desc:    "convert an markdown table to create DB table SQL",
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, _ []string) error {
		return errors.New("TODO")
	},
}
View Source
var MarkdownServeCmd = &gcli.Command{
	Name:    "serve",
	Aliases: []string{"server"},
	Desc:    "convert an markdown table to create DB table SQL",
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, _ []string) error {
		return errorx.New("TODO")
	},
}
View Source
var MdRenderCmd = &gcli.Command{
	Name:    "render",
	Aliases: []string{"view", "cat"},
	Desc:    "render markdown file contents on the terminal console",
	Config: func(c *gcli.Command) {
		c.StrOpt2(&mrOpts.style, "style, s", "sets the render style, default is auto.\n allow: auto, dark, dracula, light, notty, pink")
		c.AddArg("file", "want rendered file path", true)
	},
	Func: func(c *gcli.Command, _ []string) error {
		fpath := c.Arg("file").String()
		str, err := kautorw.ReadContents("@" + fpath)
		if err != nil {
			return err
		}

		out, err := glamour.Render(str, mrOpts.style)
		if err == nil {

			stdio.WriteString(out)
		}
		return err
	},
}

MdRenderCmd instance

View Source
var MkDownCmd = &gcli.Command{
	Name:    "mkdown",
	Desc:    "some tools for markdown",
	Aliases: []string{"md", "mdown", "markdown"},
	Subs: []*gcli.Command{
		MdRenderCmd,
		Markdown2HTML,
		Markdown2SQL,
		MarkdownServeCmd,
	},
}

MkDownCmd instance

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL