# HG changeset patch # User Mikael Berthe # Date 1494671798 -7200 # Node ID 4bf4f6ce268ee00b543183794a6e2d3a3b3acd86 # Parent 6461e0637767a1cc0868d7aba5764aaa85d78787 html2text: Try and handle one more mention case + switch to devel version diff -r 6461e0637767 -r 4bf4f6ce268e cmd/version.go --- a/cmd/version.go Sat May 13 11:56:52 2017 +0200 +++ b/cmd/version.go Sat May 13 12:36:38 2017 +0200 @@ -23,7 +23,7 @@ } // VERSION of the madonctl application -var VERSION = "1.1.0" +var VERSION = "1.1.1-dev" var versionCmd = &cobra.Command{ Use: "version", diff -r 6461e0637767 -r 4bf4f6ce268e printer/html2text/html2text.go --- a/printer/html2text/html2text.go Sat May 13 11:56:52 2017 +0200 +++ b/printer/html2text/html2text.go Sat May 13 12:36:38 2017 +0200 @@ -116,6 +116,11 @@ last = b.Bytes()[bl-1] } + // Add heading space if needed + if last != ' ' && last != '\n' && last != '#' && last != '@' { + b.WriteString(" ") + } + var tmpbuf bytes.Buffer for c := n.FirstChild; c != nil; c = c.NextSibling { process(c, &tmpbuf, class) @@ -126,11 +131,6 @@ return } - // Add heading space if needed - if last != ' ' && last != '\n' { - b.WriteString(" ") - } - s := tmpbuf.String() if strings.HasPrefix(s, "#") || strings.HasPrefix(s, "@") { b.WriteString(s) // Tag or mention: display content diff -r 6461e0637767 -r 4bf4f6ce268e printer/html2text/html2text_test.go --- a/printer/html2text/html2text_test.go Sat May 13 11:56:52 2017 +0200 +++ b/printer/html2text/html2text_test.go Sat May 13 12:36:38 2017 +0200 @@ -146,6 +146,16 @@ assert.Equal(t, expected, r) } +func TestTextifyMastodonMention(t *testing.T) { + expected := "La tête à @Toto \\o/" + + body := `

La tête à @Toto \o/

` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + func TestTextifyMastodonMentionAndTag(t *testing.T) { expected := "@ACh Mais heu ! Moi aussi je fais du #TootRadio de gens morts il y a 5 siècles. Gesulado, Charpentier, Mireille Mathieu..."