flashcards

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 11 Imported by: 0

README

Flashcards

Convert text flashcards to CSV or HTML.
Flashcards can be uninterpreted text or MathJax TeX.
HTML uses a simple JavaScript Model-View-Controller.

Go library and command.

https://pkg.go.dev/github.com/MihaiB/flashcards

go install ./flashcards
`go env GOPATH`/bin/flashcards -help

Documentation

Overview

Package flashcards parses and formats flashcards.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFlashcardBack = errors.New("Flashcard has no back side")

ErrNoFlashcardBack is the error returned when a Flashcard has no back side.

Functions

func WriteHTMLMathJaxTeX

func WriteHTMLMathJaxTeX(directory string, flashcards []*Flashcard) error

WriteHTMLMathJaxTeX creates the directory and writes the flashcards, which may contain MathJax TeX, to index.html and associated asset files in the directory.

func WriteHTMLText

func WriteHTMLText(directory string, flashcards []*Flashcard) error

WriteHTMLText creates the directory and writes the flashcards as text to index.html and associated asset files in the directory.

func WriteJSON

func WriteJSON(w io.Writer, flashcards []*Flashcard) error

WriteJSON converts each Flashcard to an object with two keys, "front" and "back", and writes the resulting JSON array to w.

func WriteStudyBlue

func WriteStudyBlue(w io.Writer, flashcards []*Flashcard) error

WriteStudyBlue escapes the flashcard text to HTML, converts "\n" to "<br>" and writes the result as CSV which can be imported on StudyBlue.com.

Types

type DirWriteFunc

type DirWriteFunc func(directory string, flashcards []*Flashcard) error

A DirWriteFunc creates the directory and writes the flashcards in it.

type Flashcard

type Flashcard struct {
	Front, Back string
}

A Flashcard has a front side and a back side.

type Reader

type Reader interface {
	Read() (*Flashcard, error)
}

Reader reads Flashcards. It does not hold references to a Flashcard after returning it. If the error is not nil, callers must discard the returned Flashcard.

func NewReader

func NewReader(r io.Reader) Reader

NewReader returns a new Reader reading from r. A flashcard consists of adjacent, non-empty lines. The first line is the flashcard's front, the remaining lines are its back. If a flashcard has no back side, the Reader stops with ErrNoFlashcardBack. Flashcards are separated by empty lines. Lines are terminated by "\n".

type WriteFunc

type WriteFunc func(w io.Writer, flashcards []*Flashcard) error

A WriteFunc writes the flashcards to w.

Directories

Path Synopsis
Flashcards formats flashcards.
Flashcards formats flashcards.

Jump to

Keyboard shortcuts

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