Documentation ¶
Overview ¶
Package knuth collects utilities common to all other packages in this repository.
To install all the included go* commands found in cmd/
$ go install modernc.org/knuth/cmd...@latest
Documentation
http://godoc.org/modernc.org/knuth
Hacking ¶
Make sure you have these utilities from the Tex-live package(s) installed in your $PATH:
dvitype gftopk gftype mf mft pooltype tangle tex tftopl vftovp vptovf weave
These programs are used only to generate test data. Users of packages/commands in this repository do not need them installed.
You will also need to perform
$ go install modernc.org/unconvert2@latest
After modification of any sources, run '$ make' in the repository root. That will regenerate all applicable Go code and testdata, run tests of all packages in this repository and install all the commands found in ./cmd.
If your local clone of the repository is private, you need to setup the GOPRIVATE environment variable properly for the tests to pass.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ASCII is a RuneValidator accepting runes '\x00' ... '\xff`. ASCII asciiValidator // Unicode is a RuneValidator accepting all valid unicode code points // except those in category Co and Cs. Unicode unicodeValidator // Assets provides some essential resources: // // fonts/cm/mf/* from https://ctan.org/tex-archive/systems/knuth/dist/cm // lib/* from https://ctan.org/tex-archive/systems/knuth/dist/lib Assets fs.FS = newCFS(assets) )
Functions ¶
func Open ¶
Open attempts to open 'name'. If not successful then it tries to open 'name' using 'search' paths. If still not found then Open may try to find the resource in Assets.
If all letters of the base name of 'name' are upper case then the preceding steps may be extended by additionally looking for the lower case alternative of 'name'.
The caller is responsible to properly .Close any returned non-nil fs.Files to avoid resource exhaustion.
Types ¶
type Changer ¶
type Changer struct {
// contains filtered or unexported fields
}
Changer is a RuneSource implementing patching source using a change file.
func NewChanger ¶
func NewChanger(src, changes RuneSource) (*Changer, error)
NewChanger returns a newly created Changer or an error, if any.
func (*Changer) AddLineColumnInfo ¶
AddLineColumnInfo implements RuneSource, but is a no-op.
type File ¶
type File interface { ByteP() *byte Close() CurPos() int32 Data4P() *[4]byte EOF() bool EOLN() bool ErStat() int32 Get() Put() Read(args ...interface{}) Readln(args ...interface{}) Reset(args ...interface{}) Rewrite(args ...interface{}) SetPos(int32) Write(args ...interface{}) Writeln(args ...interface{}) }
File represents a Pascal file.
func NewBinaryFile ¶
func NewBinaryFile(r io.Reader, w io.Writer, sizeofT int, open func(string) (io.Reader, error)) File
NewBinaryFile returns a File suitable for Pascal file type 'file of T'.
func NewPoolFile ¶
NewPoolFile returns a read only File with a string pool.
type Line ¶
Line represents a source line and its position.
func ReadLine ¶
func ReadLine(s RuneSource) (line *Line, err error)
ReadLine reads from s up to and including the next newline, if any. If s is at EOF, (nil, io.EOF) is returned.
func ReadLine2 ¶
func ReadLine2(s RuneSource) (line *Line, err error)
ReadLine2 is like ReadLine but additionally trims trailing space. The final '\n' is preserved, if any.
type RuneSource ¶
type RuneSource interface { // AddLineColumnInfo adds alternative file, line, and column number information // for a given file offset. The offset must be larger than the offset for the // previously added alternative line info and smaller than the file size; // otherwise the information is ignored. // // AddLineColumnInfo is typically used to register alternative position // information for line directives such as //line filename:line:column. AddLineColumnInfo(offset int, filename string, line, column int) // C returns the current rune or and error, if any. C() (rune, error) // Consume moves to the next rune, if any. Consume() // Position returns the current position. Position() token.Position // PositionFor returns the position for zero based offset. PositionFor(off int) token.Position }
RuneSource provides a finite stream of runes.
func NewRuneSource ¶
func NewRuneSource(name string, src []byte, validator RuneValidator) RuneSource
NewRuneSource returns a newly created Source. Positions will be reported as coming from 'name'. 'src' is UTF-8 encoded. Decoded runes will be validated by 'validator'.
type RuneValidator ¶
type RuneValidator interface { // Validate returns true if its argument is in the accepted rune set. Validate(rune) bool }
RuneValidator validates runes.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
godvitype
Command godvitype is the DVItype program by D. E. Knuth, transpiled to Go.
|
Command godvitype is the DVItype program by D. E. Knuth, transpiled to Go. |
gogftodvi
Command gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
|
Command gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go. |
gogftopk
For more details about the original Pascal program and its usage please see the modernc.org/knuth/gftype package.
|
For more details about the original Pascal program and its usage please see the modernc.org/knuth/gftype package. |
gogftype
Command gogftype is the GFtype program by D. R. Fuchs, transpiled to Go.
|
Command gogftype is the GFtype program by D. R. Fuchs, transpiled to Go. |
gomf
Command gomf is the METAFONT program by D. E. Knuth, transpiled to Go.
|
Command gomf is the METAFONT program by D. E. Knuth, transpiled to Go. |
gomft
Command gomft is the MFT program by D. E. Knuth, transpiled to Go.
|
Command gomft is the MFT program by D. E. Knuth, transpiled to Go. |
gopktype
Command gopktype is the PKtype program by D. E. Knuth, transpiled to Go.
|
Command gopktype is the PKtype program by D. E. Knuth, transpiled to Go. |
gopltotf
Command gopltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
|
Command gopltotf is the PLtoTF program by D. E. Knuth, transpiled to Go. |
gopooltype
Command gopooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
|
Command gopooltype is the POOLtype program by D. E. Knuth, transpiled to Go. |
gotangle
Command gotangle is the TANGLE program by D. E. Knuth, transpiled to Go.
|
Command gotangle is the TANGLE program by D. E. Knuth, transpiled to Go. |
gotex
Command gotex is the TeX program by D. E. Knuth, transpiled to Go.
|
Command gotex is the TeX program by D. E. Knuth, transpiled to Go. |
gotftopl
Command gotftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
|
Command gotftopl is the TFtoPL program by D. E. Knuth, transpiled to Go. |
govftovp
Command govftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
|
Command govftovp is the VFtoVP program by D. E. Knuth, transpiled to Go. |
govptovf
Command govftovp is the VPtoVF program by D. E. Knuth, transpiled to Go.
|
Command govftovp is the VPtoVF program by D. E. Knuth, transpiled to Go. |
goweave
Command goweave is the WEAVE program by D. E. Knuth, transpiled to Go.
|
Command goweave is the WEAVE program by D. E. Knuth, transpiled to Go. |
Package dvi implements encoding and decoding DVI documents.
|
Package dvi implements encoding and decoding DVI documents. |
Package dvitype is the DVItype program by D. E. Knuth, transpiled to Go.
|
Package dvitype is the DVItype program by D. E. Knuth, transpiled to Go. |
font
|
|
afm
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
|
Package afm implements a decoder for AFM (Adobe Font Metrics) files. |
fixed
Package fixed provides types to work with fixed-point numbers.
|
Package fixed provides types to work with fixed-point numbers. |
pkf
Package pkf implements a decoder for the Packed (PK) Font file format.
|
Package pkf implements a decoder for the Packed (PK) Font file format. |
tfm
Package tfm implements a decoder for TFM (TeX Font Metrics) files.
|
Package tfm implements a decoder for TFM (TeX Font Metrics) files. |
Package gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
|
Package gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go. |
Package gftopk is the GFtype program by Tomas Rokicki, transpiled to Go.
|
Package gftopk is the GFtype program by Tomas Rokicki, transpiled to Go. |
Package gftype is the GFtype program by D. R. Fuchs, transpiled to Go.
|
Package gftype is the GFtype program by D. R. Fuchs, transpiled to Go. |
internal
|
|
iobuf
Package iobuf provides buffered I/O tailored for TeX and DVI semantics.
|
Package iobuf provides buffered I/O tailored for TeX and DVI semantics. |
tds
Package tds provides a minimal TeX Directory Structure.
|
Package tds provides a minimal TeX Directory Structure. |
Package kpath provides tools to locate TeX related files.
|
Package kpath provides tools to locate TeX related files. |
Package mf is the METAFONT program by D. E. Knuth, transpiled to Go.
|
Package mf is the METAFONT program by D. E. Knuth, transpiled to Go. |
internal/trap
Package trap is the TRAP variant of the METAFONT program by D. E. Knuth, transpiled to Go.
|
Package trap is the TRAP variant of the METAFONT program by D. E. Knuth, transpiled to Go. |
Package mft is the MFT program by D. E. Knuth, transpiled to Go.
|
Package mft is the MFT program by D. E. Knuth, transpiled to Go. |
Package pktype is the PKtype program by D. E. Knuth, transpiled to Go.
|
Package pktype is the PKtype program by D. E. Knuth, transpiled to Go. |
Package pltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
|
Package pltotf is the PLtoTF program by D. E. Knuth, transpiled to Go. |
Package pooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
|
Package pooltype is the POOLtype program by D. E. Knuth, transpiled to Go. |
Package tangle is the TANGLE program by D. E. Knuth, transpiled to Go.
|
Package tangle is the TANGLE program by D. E. Knuth, transpiled to Go. |
Package tex is the TEX program by D. E. Knuth, transpiled to Go.
|
Package tex is the TEX program by D. E. Knuth, transpiled to Go. |
internal/trip
Package trip is the TRIP variant of the TeX program by D. E. Knuth, transpiled to Go.
|
Package trip is the TRIP variant of the TeX program by D. E. Knuth, transpiled to Go. |
Package tftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
|
Package tftopl is the TFtoPL program by D. E. Knuth, transpiled to Go. |
Package vftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
|
Package vftovp is the VFtoVP program by D. E. Knuth, transpiled to Go. |
Package vptovf is the VPtoVF program by D. E. Knuth, transpiled to Go.
|
Package vptovf is the VPtoVF program by D. E. Knuth, transpiled to Go. |
Package weave is the WEAVE program by D. E. Knuth, transpiled to Go.
|
Package weave is the WEAVE program by D. E. Knuth, transpiled to Go. |
Package web deals with .web files.
|
Package web deals with .web files. |