latex

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 10 Imported by: 3

README

goldmark-latex

A LaTeX renderer for Goldmark. Produce .tex files from markdown.

This renderer seeks to be as extensible as Goldmark itself. Please file an issue if it does not meet your requirements.

Results

So far this implementation renders the CommonMark specification with the exception of embedded HTML. It does have some bugs related to undefined ASCII sequences. Any help is appreciated.

result

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPreamble added in v0.1.1

func DefaultPreamble() []byte

DefaultPreamble returns a copy of the default preamble provided by goldmark-latex. It does not include \begin{document} text within, as expected by Config.Preamble.

func NewRenderer

func NewRenderer(opts ...Option) renderer.NodeRenderer

NewRenderer returns a new Renderer with given options. Options are applied in order of appearance. Example:

lr := latex.NewRenderer(latex.Config{
	Unsafe: true, // Add desired configuration options.
})
r := renderer.NewRenderer(renderer.WithNodeRenderers(util.Prioritized(lr, 1000)))
md := goldmark.New(goldmark.WithRenderer(r))
md.Convert(markdown, LaTeXoutput)

Types

type Config

type Config struct {
	// Increase heading levels: if the offset is 1, \section (1) becomes \subsection (2) etc.
	// Negative offset is also valid.
	// Resulting levels are clipped between 1 and 6.
	HeadingLevelOffset int
	// Removes section numbering.
	NoHeadingNumbering bool
	// Replace the default preamble by setting this to a non-nil byte slice.
	// Should NOT end with \begin{document}, this is added automatically.
	Preamble []byte
	// If set renderer will render possibly unsafe elements, such as links and
	// code block raw content.
	Unsafe bool
	// Declares all used unicode characters in the preamble
	// and replaces them with the result of this function.
	DeclareUnicode func(rune) (raw string, isReplaced bool)
}

Config contains parameters for controlling LaTeX output of a Renderer.

func (Config) SetLatexOption

func (r Config) SetLatexOption(c *Config)

SetLatexOption implements the Option interface.

type Option

type Option interface {
	SetLatexOption(*Config)
}

An Option interface sets options for HTML based renderers.

type Renderer

type Renderer struct {
	Config Config
}

Renderer is a LaTeX renderer implementation for extending goldmark to generate .tex files.

func (*Renderer) RegisterFuncs

func (r *Renderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs implements goldmark's renderer.NodeRenderer interface.

Jump to

Keyboard shortcuts

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