fix bullets, add alt text to preformatted toggles
This commit is contained in:
parent
561165ad84
commit
4f40ff17b6
|
@ -81,13 +81,13 @@ func ParseLine(line string, isPreformatted bool) (GemtextObject, error) {
|
|||
case strings.HasPrefix(line, "=>"):
|
||||
return ParseLink(line)
|
||||
case strings.HasPrefix(line, "```"):
|
||||
return GemtextObject{Type: PREFORMATTED_TOGGLE, Literal: line}, nil
|
||||
return GemtextObject{Type: PREFORMATTED_TOGGLE, Literal: line, Text: line[3:]}, nil
|
||||
case strings.HasPrefix(line, "#"):
|
||||
return ParseHeading(line)
|
||||
case strings.HasPrefix(line, ">"):
|
||||
return GemtextObject{Type: QUOTE, Text: strings.TrimSpace(line[1:]), Literal: line}, nil
|
||||
case strings.HasPrefix(line, "*"):
|
||||
return GemtextObject{Type: LIST, Text: strings.TrimSpace(line[1:]), Literal: line}, nil
|
||||
case strings.HasPrefix(line, "* "): // Bullets require a space, per the spec
|
||||
return GemtextObject{Type: LIST, Text: line[2:], Literal: line}, nil
|
||||
}
|
||||
return GemtextObject{Type: TEXT, Text: line, Literal: line}, nil
|
||||
} else {
|
||||
|
@ -97,4 +97,4 @@ func ParseLine(line string, isPreformatted bool) (GemtextObject, error) {
|
|||
}
|
||||
|
||||
// ParsePage takes a string containing the contents of a gemtext page and returns a GemtextPage.
|
||||
func ParseFile() {}
|
||||
func ParsePage(p string) {}
|
||||
|
|
|
@ -11,6 +11,7 @@ type LineCase struct {
|
|||
func TestParseLine(t *testing.T) {
|
||||
cases := []LineCase{
|
||||
LineCase{Str: "```", Preformatted: false, Want: GemtextObject{Type: PREFORMATTED_TOGGLE, Literal: "```"}},
|
||||
LineCase{Str: "```alt", Preformatted: false, Want: GemtextObject{Type: PREFORMATTED_TOGGLE, Literal: "```alt", Text:"alt"}},
|
||||
LineCase{
|
||||
Str: "This is a test of a normal text line.",
|
||||
Preformatted: false,
|
||||
|
@ -84,9 +85,9 @@ func TestParseLine(t *testing.T) {
|
|||
Str: "*list item",
|
||||
Preformatted: false,
|
||||
Want: GemtextObject{
|
||||
Type: LIST,
|
||||
Type: TEXT,
|
||||
Literal: "*list item",
|
||||
Text: "list item"},
|
||||
Text: "*list item"},
|
||||
},
|
||||
LineCase{
|
||||
Str: "* list item",
|
||||
|
@ -96,14 +97,6 @@ func TestParseLine(t *testing.T) {
|
|||
Literal: "* list item",
|
||||
Text: "list item"},
|
||||
},
|
||||
LineCase{
|
||||
Str: "* list item",
|
||||
Preformatted: false,
|
||||
Want: GemtextObject{
|
||||
Type: LIST,
|
||||
Literal: "* list item",
|
||||
Text: "list item"},
|
||||
},
|
||||
LineCase{
|
||||
Str: ">quote",
|
||||
Preformatted: false,
|
||||
|
|
Reference in New Issue