Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert CSV string into a markdown table. Returns the string representation of the markdown table if converted successfully and an error if failed.
func ValidateConfig ¶
Validate the Config object passed as parameter. An error will be returned in case the configuration was invalid.
Types ¶
type CSVReaderConfig ¶ added in v0.1.5
type CSVReaderConfig struct {
// Comma is the field delimiter.
// It is set to comma (',') by NewReader.
// Comma must be a valid rune and must not be \r, \n,
// or the Unicode replacement character (0xFFFD).
Comma rune
// Comment, if not 0, is the comment character. Lines beginning with the
// Comment character without preceding whitespace are ignored.
// With leading whitespace the Comment character becomes part of the
// field, even if TrimLeadingSpace is true.
// Comment must be a valid rune and must not be \r, \n,
// or the Unicode replacement character (0xFFFD).
// It must also not be equal to Comma.
Comment rune
// FieldsPerRecord is the number of expected fields per record.
// If FieldsPerRecord is positive, Read requires each record to
// have the given number of fields. If FieldsPerRecord is 0, Read sets it to
// the number of fields in the first record, so that future records must
// have the same field count. If FieldsPerRecord is negative, no check is
// made and records may have a variable number of fields.
FieldsPerRecord int
// If LazyQuotes is true, a quote may appear in an unquoted field and a
// non-doubled quote may appear in a quoted field.
LazyQuotes bool
// If TrimLeadingSpace is true, leading white space in a field is ignored.
// This is done even if the field delimiter, Comma, is white space.
TrimLeadingSpace bool
// ReuseRecord controls whether calls to Read may return a slice sharing
// the backing array of the previous call's returned slice for performance.
// By default, each call to Read returns newly allocated memory owned by the caller.
ReuseRecord bool
}
Mirroring https://pkg.go.dev/encoding/csv#Reader
type ColumnSortFunction ¶ added in v1.0.6
type ColumnSortOption ¶ added in v1.0.5
type ColumnSortOption int
const ( None ColumnSortOption = 0 Ascending ColumnSortOption = 1 Descending ColumnSortOption = 2 Custom ColumnSortOption = 3 )
type Config ¶
type Config struct {
// Align the rendered content for the Markdown table. 0 = Center, 1 = Left, 2 = Right
Align Align
// Caption of the table (as an HTML comment)
Caption string
// Should the markdown table be the compact version
Compact bool
// Reader configuration to be used for Reader type.
// See also https://pkg.go.dev/encoding/csv#Reader
CSVReaderConfig CSVReaderConfig
// List of columns to be excluded from table construction
ExcludedColumns []string
// Should the columns be sorted and how?
SortColumns ColumnSortOption
// Custom sort function
SortFunction ColumnSortFunction
// Log detailed diagnostic messages when running the program.
VerboseLogging bool
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.