presenter

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

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 14 Imported by: 0

README

Presenter

Presenter displays slide presentations. It runs a web server that presents slide files from a specific directory.

Introduction

Markdown is a very versatile tool. This library builds on that premise and generates presentations from markdown files.

Production readiness

This project is still in alpha phase. In this stage the public API can change between days.

Documents

Inspiration

Inspiration for the implementation comes from the following places:

How is it different from x/tools/present and x/tools/cmd/present?

  • There is no legacy layout. Only Markdown formatting is available which allows the library to fully build on https://github.com/yuin/goldmark.
  • No "present command invocation", markdown only.
  • Some changes on how metadata and author information parsed.
  • Not focused on Go. There for, the Go playground is not part of the presentation tools.
  • As of now, no notes (#2) and no comments (#3) support.
  • More changes are coming...

Documentation

Overview

Package presenter implements parsing and rendering of present files, which can be slide presentations as in github.com/coding-socks/presenter/cmd/present.

File Format

Present files begin with a header giving the title of the document and other metadata, which looks like:

# Title of document
Subtitle of document
15:04 2 Jan 2006
Tags: foo, bar, baz
Summary: This is a great document you want to read.

The "#" indicates the title. Between the title and other metadata must be no empty lines.

The date line may be written without a time:

2 Jan 2006

In this case, the time will be interpreted as 11am UTC on that date.

The tags line is a comma-separated list of tags that may be used to categorize the document.

The summary line gives a short summary used in blog feeds.

Only the title is required; the subtitle, date, tags, and summary lines are optional.

After the header come zero or more author blocks, like this:

Author Name
Job title, Company
<joe@example.com>
<https://url/>
<@twitter_name>

The first line of the author block is conventionally the author name. Otherwise, the author section may contain a mixture of text, twitter names, and links. For slide presentations, only the plain text lines will be displayed on the first slide.

If multiple author blocks are listed, each new block must be preceded by its own blank line.

After the author blocks come the presentation slides or article sections, which can in turn have subsections. Each slide or section begins with "##" or "###" header line. As of now "####" or more are handled as part of the slide content.

Markdown Syntax

Markdown typically means the generic name for a family of similar markup languages. The specific variant used in present is CommonMark with some extensions to support strikethrough, task list, and twitter link components. See https://commonmark.org/help/tutorial/ for a quick tutorial.

Example:

# Title of document
Subtitle of document
15:04 2 Jan 2006
Tags: foo, bar, baz
Summary: This is a great document you want to read.

My Name
<me@example.com>

## Title of 2nd level Slide (must begin with ##)

Some Text

### Title of 3rd level Slide (must begin with ###)

More text

## Single slide (must have empty body)

### Example formatting

Formatting:

The following text formatted as _italic_, **bold**,
`code`, ~~deleted~~.

Links can have different formats as well.
[This link is labeled with text](https://example.com/),
On the other hand, the following is labeled with the link itself
<https://example.com/>. The next one is an email address <me@example.com>.
And finally, a twitter alias <@rob_pike>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTwitterIndex

func FindTwitterIndex(b []byte) int

FindTwitterIndex returns a stop index value if the given bytes seem an email address.

func NewAnchorTargetBlankExtension

func NewAnchorTargetBlankExtension() *anchorTargetBlankExtension

func NewAnchorTargetBlankTransformer

func NewAnchorTargetBlankTransformer() *anchorTargetBlankTransformer

func NewTwitterLinkExtension

func NewTwitterLinkExtension() goldmark.Extender

NewTwitterLinkExtension returns a new extension.

func NewTwitterLinkParser

func NewTwitterLinkParser() parser.InlineParser

NewTwitterLinkParser return a new InlineParser that parses links.

Types

type Author

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

Author represents the person who wrote and/or is presenting the document.

func (Author) Render

func (a Author) Render() template.HTML

func (Author) RenderText

func (a Author) RenderText() template.HTML

type Doc

type Doc struct {
	Title      string
	Subtitle   string
	Summary    string
	Time       time.Time
	Authors    []Author
	TitleNotes []string
	Sections   []Section
	Tags       []string
}

Doc represents an entire document.

func ParseSlide

func ParseSlide(r io.Reader, mode ParseMode) (*Doc, error)

type ParseMode

type ParseMode int

ParseMode represents flags for the Parse function.

const (
	// TitlesOnly mode parse only the title and subtitle.
	TitlesOnly ParseMode = 1 << (1 + iota)
)

type Section

type Section struct {
	Number []int

	Notes []string
	// contains filtered or unexported fields
}

Section represents a section of a document (such as a presentation slide) comprising a title and a list of elements.

func (Section) Empty

func (s Section) Empty() bool

func (Section) Render

func (s Section) Render() template.HTML

func (Section) RenderTitle

func (s Section) RenderTitle() template.HTML

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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