mdcoach

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 38 Imported by: 0

README

Markdown Coach

Markdown to HTML slide compiler. Supports multiple displays with optional extended notes.

go install github.com/dkotik/mdcoach/cmd/mdcoach@latest

Slide Rendering

Headings of the first and second level and horizontal rules cut the content into slides. Headings of the first level also change the slide background to action color.

Synchronization

Browser windows containing presentations with the same document title will all synchronize their current slide position using window.localStorage events. Open multiple windows to present the same presentation on different monitors.

Use different viewing modes to give yourself convenient access to notes. Put two windows side by side in order to see notes next to the replica of the slides shown to the audience. Press C button to clone the current presentation window.

Markdown Behavior

Mdcoach departs from normal Markdown grammar in the following cases.

Included Files

An image element in a root-level paragraph that points to a Markdown file causes the entire paragraph to be replaced with the rendered content of that file. Relative links and images are all updated according to the relative file path of the included file.

Aside Elements
> > Nested double block-quote is rendered as an `<aside>` element instead of a block-quote, which then transforms the slide in the following ways.
  1. If found at the end of slide content, they float to the right. First image of the <aside> block fills the right side.
  2. If found after the title of the slide, they float to the left. First image of the <aside> block fills the left side.
  3. If found after the title of the slide, but there is nothing else in the slide, they become a splash element. First image of the <aside> block fills the entire screen as a background element.
  4. An empty aside element > > confines all the following slide elements to notes.

Documentation

Overview

Package mdcoach converts Markdown files to HTML presentations with notes.

Index

Constants

View Source
const (
	ImageCSSClass           = "mdcoachImage"
	ImageContentClassPrefix = ImageCSSClass + "Content"
)
View Source
const FootnoteIndexAttribute = "data-slide-footnote-index"
View Source
const ImageStyle = `.` + ImageCSSClass + ` {
	min-height: 1.5em;
	min-width: 1.5em;
	background-repeat: no-repeat;
	background-position: center center;
	background-size: contain;
	aspect-ratio: attr(data-aspect-ratio type(<number>));
}

`

Variables

View Source
var ErrEmoteNotFound = fmt.Errorf("emote not found: %w", fs.ErrNotExist)

ErrEmoteNotFound indicates that no configured filesystem contains an emote asset.

View Source
var KindEmote = ast.NewNodeKind("Emote")
View Source
var KindFigure = ast.NewNodeKind("Figure")

KindFigure is the node kind for image-only figures.

View Source
var KindSlideNotes = ast.NewNodeKind("SlideNotes")
View Source
var (
	// SlideKind is the node kind for presentation slides.
	SlideKind = ast.NewNodeKind("Slide")
)

Functions

func NewBlockquoteTransformer added in v0.0.7

func NewBlockquoteTransformer() parser.ASTTransformer

NewBlockquoteTransformer returns an AST transformer that moves trailing parenthetical citations in blockquotes into footer elements.

func NewDocumentIDInjector added in v0.0.6

func NewDocumentIDInjector() parser.ASTTransformer

NewDocumentIDInjector returns a transformer that sets the document's id attribute to the xxhash of its deterministic AST dump.

func NewEmoteColonCodeParser added in v0.0.8

func NewEmoteColonCodeParser() parser.InlineParser

NewEmoteColonCodeParser returns a Goldmark v2 inline parser for :text: emotes.

func NewEmoteFilesystem added in v0.0.8

func NewEmoteFilesystem(filesystems ...fs.FS) fs.FS

NewEmoteFilesystem returns an fs.FS that searches each provided filesystem in order.

func NewEmoteParser added in v0.0.6

func NewEmoteParser(emoticons map[string]string) parser.InlineParser

NewEmoteParser returns a Goldmark v2 inline parser for configured emoticons.

func NewEmoteRenderer added in v0.0.6

func NewEmoteRenderer(cache *ImageCache, storage fs.FS, imageExtension string) html.NodeRenderer

NewEmoteRenderer returns a Goldmark renderer that uses cached images for emote names found in the storage.

func NewFigureRenderer added in v0.0.6

func NewFigureRenderer() html.NodeRenderer

NewFigureRenderer returns a Goldmark v2 HTML renderer for Figure nodes.

func NewFigureTransformer added in v0.0.6

func NewFigureTransformer() parser.ASTTransformer

NewFigureTransformer returns an AST transformer that turns image-only document children into Figure nodes.

func NewFootnoteRenderer added in v0.0.7

func NewFootnoteRenderer() htmlrenderer.NodeRenderer

NewFootnoteRenderer returns an HTML renderer that renders footnotes at their position in the AST instead of collecting them at the end of the document.

func NewImageRenderer added in v0.0.6

func NewImageRenderer() html.NodeRenderer

func NewParser added in v0.0.6

func NewParser() parser.Parser

NewParser returns a Goldmark v2 parser configured for presentations.

func NewRenderer added in v0.0.6

func NewRenderer(cache *ImageCache) html.Renderer

NewRenderer returns a renderer that shares cache with image loading.

func NewSlideNotes added in v0.0.7

func NewSlideNotes() ast.Node

NewSlideNotes returns a new [slideNotes] node.

func NewSlideNotesParser added in v0.0.7

func NewSlideNotesParser() parser.BlockParser

NewSlideNotesParser returns a BlockParser for slide notes.

func NewSlideNotesRenderer added in v0.0.7

func NewSlideNotesRenderer() html.NodeRenderer

NewSlideNotesRenderer returns a Goldmark v2 HTML renderer for SlideNotes nodes.

func NewSlideRenderer added in v0.0.6

func NewSlideRenderer(fr html.NodeRenderer) html.NodeRenderer

NewSlideRenderer returns a Goldmark v2 HTML renderer for Slide nodes.

func NewSlideTransformer added in v0.0.6

func NewSlideTransformer(headingLevelLimit int) parser.ASTTransformer

NewSlideTransformer returns an AST transformer that groups sections into slides.

Types

type Emote added in v0.0.6

type Emote struct {
	ast.BaseInline
	Name text.SingleLineValue
}

Emote is an inline text emoji such as :smile:.

func (*Emote) Dump added in v0.0.6

func (e *Emote) Dump(source []byte) *ast.NodeDump

Dump includes the emote name in AST dumps.

func (*Emote) Kind added in v0.0.6

func (*Emote) Kind() ast.NodeKind

Kind returns EmoteKind.

type Figure added in v0.0.6

type Figure struct {
	ast.BaseBlock
}

Figure is a figure containing a single image.

func (*Figure) Dump added in v0.0.6

func (f *Figure) Dump(_ []byte) *ast.NodeDump

Dump dumps the figure and its children.

func (*Figure) Kind added in v0.0.6

func (*Figure) Kind() ast.NodeKind

Kind returns FigureKind.

type ImageCache added in v0.0.6

type ImageCache struct {
	// contains filtered or unexported fields
}

func NewImageCache added in v0.0.6

func NewImageCache() *ImageCache

func (*ImageCache) Get added in v0.0.6

func (c *ImageCache) Get(location string) (*imageWebp, bool)

func (*ImageCache) Set added in v0.0.6

func (c *ImageCache) Set(img *imageWebp)

func (*ImageCache) WriteImageDataCSS added in v0.0.6

func (c *ImageCache) WriteImageDataCSS(w io.Writer) error

type ImageLoader added in v0.0.6

type ImageLoader struct {
	// contains filtered or unexported fields
}

func NewImageLoader added in v0.0.6

func NewImageLoader(cache *ImageCache, ic MediaOptions) *ImageLoader

func (*ImageLoader) LoadImages added in v0.0.6

func (l *ImageLoader) LoadImages(ctx context.Context, source []byte, tree ast.Node) error

LoadImages downloads image destinations that are owned by the AST nodes. Use LoadImagesFromSource when the AST was parsed from Markdown source.

type MediaOptions added in v0.0.6

type MediaOptions struct {
	FS          fs.FS
	Path        string
	WidthLimit  int
	HeightLimit int
	Quality     int
}

type Slide added in v0.0.6

type Slide struct {
	ast.BaseBlock
	Index        int
	HeadingLevel int
	SlideLayout  SlideLayout
}

Slide is a presentation slide containing a section of the document.

The heading that starts a section is part of that section and is therefore the first child of the corresponding Slide node.

func NewSlide added in v0.0.6

func NewSlide(children ...ast.Node) (s *Slide)

func (*Slide) Dump added in v0.0.6

func (s *Slide) Dump(_ []byte) *ast.NodeDump

Dump dumps the slide and its children.

func (*Slide) Kind added in v0.0.6

func (*Slide) Kind() ast.NodeKind

Kind returns SlideKind.

type SlideLayout added in v0.0.6

type SlideLayout string
const (
	SlideNormalLayout     SlideLayout = "normal"
	SlideSplashLayout     SlideLayout = "splash"
	SlideLeftAsideLayout  SlideLayout = "left-aside"
	SlideRightAsideLayout SlideLayout = "right-aside"
)

Directories

Path Synopsis
cmd
mdcoach command
Package main provides command line interface to [mdcoach.Iterator].
Package main provides command line interface to [mdcoach.Iterator].
Package epub writes HTML presentation documents as EPUB 3 publications.
Package epub writes HTML presentation documents as EPUB 3 publications.
Package internal provides common utilities for the mdcoach and related packages.
Package internal provides common utilities for the mdcoach and related packages.
Package presentation makes HTML presentations from Markdown files.
Package presentation makes HTML presentations from Markdown files.
index
Package index maintains an HTML page that links to compiled presentations.
Package index maintains an HTML page that links to compiled presentations.
Package review generates PDF review sheets from Markdown frontmatter questions.
Package review generates PDF review sheets from Markdown frontmatter questions.

Jump to

Keyboard shortcuts

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