latex

package module
v0.0.0-...-a5b9eb0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: MIT Imports: 14 Imported by: 1

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

md2latex program

This command converts a single markdown file to latex and writes to contents to a new .text file or to stdout.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPreamble

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.

Types

type Option

type Option func(*Renderer)

Option is the type for functional options.

func WithHeadingLevelOffset

func WithHeadingLevelOffset(offset int) Option

func WithMakeTitle

func WithMakeTitle(value bool) Option

func WithNoHeadingNumbering

func WithNoHeadingNumbering(nonumbering bool) Option

func WithPreamble

func WithPreamble(preamble []byte) Option

func WithPreambleFile

func WithPreambleFile(path string) Option

func WithRenderUnsafeElements

func WithRenderUnsafeElements(unsafe bool) Option

func WithUnicodeCharactersMapping

func WithUnicodeCharactersMapping(mapping func(rune) (raw string, isReplaced bool)) Option

type Renderer

type Renderer 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)
	// contains filtered or unexported fields
}

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

func NewRenderer

func NewRenderer(options ...Option) *Renderer

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

lr := latex.NewRenderer(
		latex.WithRenderUNsafeElements(true),
		// ... add more desired configuration options
)
r := renderer.NewRenderer(renderer.WithNodeRenderers(util.Prioritized(lr, 1000)))
md := goldmark.New(goldmark.WithRenderer(r))
md.Convert(markdown, LaTeXoutput)

func (*Renderer) RegisterFuncs

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

RegisterFuncs implements goldmark's renderer.NodeRenderer interface.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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