From e08c31b895a68b586aef01a3265687d7e7190f96 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 8 Jul 2020 14:23:14 -0700 Subject: [PATCH] Minor tweaks in formatting --- go.mod | 2 +- go.sum | 2 ++ segments/blockquote.go | 5 +++-- segments/embed.go | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ef81479..3db38ab 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/diamondburned/arikawa v0.9.6 github.com/diamondburned/cchat v0.0.42 - github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851 + github.com/diamondburned/ningen v0.1.1-0.20200708211706-57c712372ede github.com/dustin/go-humanize v1.0.0 github.com/go-test/deep v1.0.6 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 2ae95fc..a7e2c42 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c h1:3h/kyk6H github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c/go.mod h1:FNezDLQIhoDS+RkXLSQ7dJNrt6BW/nVl1krzDgWMQwg= github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851 h1:xf1aLPnwK/Yn2z7dBIgQROSVOEc2wtivgnnwBItdEVM= github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851/go.mod h1:FNezDLQIhoDS+RkXLSQ7dJNrt6BW/nVl1krzDgWMQwg= +github.com/diamondburned/ningen v0.1.1-0.20200708211706-57c712372ede h1:qRmfQCOS+ZnH4G0+8O09PUx3HQTdQwzsDoo1ucTgm2E= +github.com/diamondburned/ningen v0.1.1-0.20200708211706-57c712372ede/go.mod h1:FNezDLQIhoDS+RkXLSQ7dJNrt6BW/nVl1krzDgWMQwg= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/segments/blockquote.go b/segments/blockquote.go index bfd2bf2..d690172 100644 --- a/segments/blockquote.go +++ b/segments/blockquote.go @@ -13,8 +13,9 @@ var _ text.Quoteblocker = (*BlockquoteSegment)(nil) func (r *TextRenderer) blockquote(n *ast.Blockquote, enter bool) ast.WalkStatus { if enter { - r.startBlock() - defer r.endBlock() + // Block formatting. + r.ensureBreak() + defer r.ensureBreak() // Create a segment. var seg = BlockquoteSegment{start: r.buf.Len()} diff --git a/segments/embed.go b/segments/embed.go index fbba624..a24c931 100644 --- a/segments/embed.go +++ b/segments/embed.go @@ -7,6 +7,7 @@ import ( "github.com/diamondburned/arikawa/discord" "github.com/diamondburned/arikawa/state" "github.com/diamondburned/cchat-discord/urlutils" + "github.com/diamondburned/cchat/text" "github.com/diamondburned/ningen/md" "github.com/dustin/go-humanize" ) @@ -48,6 +49,13 @@ func (r *TextRenderer) renderEmbed(embed discord.Embed, m *discord.Message, s st start, end := r.writeString(embed.Title) r.ensureBreak() + // Make the title bold. + r.append(InlineSegment{ + start: start, + end: end, + attributes: text.AttrBold, + }) + if embed.URL != "" { r.append(LinkSegment{ start,