miller/pkg/input/record_reader_markdown.go
John Kerl af021f28d7
Support markdown format on input (#1478)
* Support markdown on input

* unit-test files

* doc mods

* Unit-test cases for I/O-format keystroke-savers

* -i/-o md as well as -i/-o markdown
2024-01-20 16:51:15 -05:00

30 lines
700 B
Go

package input
import (
"regexp"
"github.com/johnkerl/miller/pkg/cli"
)
func NewRecordReaderMarkdown(
readerOptions *cli.TReaderOptions,
recordsPerBatch int64,
) (IRecordReader, error) {
readerOptions.IFS = "|"
readerOptions.AllowRepeatIFS = false
reader := &RecordReaderPprintBarredOrMarkdown{
readerOptions: readerOptions,
recordsPerBatch: recordsPerBatch,
separatorMatcher: regexp.MustCompile(`^\|[-\| ]+\|$`),
fieldSplitter: newFieldSplitter(readerOptions),
}
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitPprintHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitPprintHeader
}
return reader, nil
}