mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[bugfix] Markdown formatting updates (#743)
* add minify dependency specifically for markdown * rearrange markdown formatting * update markdown tests
This commit is contained in:
47
vendor/github.com/tdewolff/parse/v2/error.go
generated
vendored
Normal file
47
vendor/github.com/tdewolff/parse/v2/error.go
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
package parse
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Error is a parsing error returned by parser. It contains a message and an offset at which the error occurred.
|
||||
type Error struct {
|
||||
Message string
|
||||
Line int
|
||||
Column int
|
||||
Context string
|
||||
}
|
||||
|
||||
// NewError creates a new error
|
||||
func NewError(r io.Reader, offset int, message string, a ...interface{}) *Error {
|
||||
line, column, context := Position(r, offset)
|
||||
if 0 < len(a) {
|
||||
message = fmt.Sprintf(message, a...)
|
||||
}
|
||||
return &Error{
|
||||
Message: message,
|
||||
Line: line,
|
||||
Column: column,
|
||||
Context: context,
|
||||
}
|
||||
}
|
||||
|
||||
// NewErrorLexer creates a new error from an active Lexer.
|
||||
func NewErrorLexer(l *Input, message string, a ...interface{}) *Error {
|
||||
r := bytes.NewBuffer(l.Bytes())
|
||||
offset := l.Offset()
|
||||
return NewError(r, offset, message, a...)
|
||||
}
|
||||
|
||||
// Position returns the line, column, and context of the error.
|
||||
// Context is the entire line at which the error occurred.
|
||||
func (e *Error) Position() (int, int, string) {
|
||||
return e.Line, e.Column, e.Context
|
||||
}
|
||||
|
||||
// Error returns the error string, containing the context and line + column number.
|
||||
func (e *Error) Error() string {
|
||||
return fmt.Sprintf("%s on line %d and column %d\n%s", e.Message, e.Line, e.Column, e.Context)
|
||||
}
|
Reference in New Issue
Block a user