44 "bytes"
55 "embed"
66 "fmt"
7+ "strings"
78 "text/template"
89
910 "github.com/ethereum/go-ethereum/common/hexutil"
@@ -132,8 +133,10 @@ func (r *TextRenderer) RenderDecodedCall(d *DecodedCall, ctx *FieldContext) stri
132133 if err := r .decodedCallTmpl .Execute (& buf , data ); err != nil {
133134 return fmt .Sprintf ("Error rendering decoded call: %v" , err )
134135 }
136+ out := buf .String ()
137+ out = strings .TrimSuffix (out , "\n " )
135138
136- return buf . String ()
139+ return out
137140}
138141
139142// RenderProposal renders a ProposalReport as plain text using templates
@@ -156,7 +159,12 @@ func (r *TextRenderer) RenderProposal(rep *ProposalReport, ctx *FieldContext) st
156159 return fmt .Sprintf ("Error rendering proposal: %v" , err )
157160 }
158161
159- return buf .String ()
162+ out := buf .String ()
163+ if ! strings .HasSuffix (out , "\n \n " ) { // assuming double newline means intentional spacing
164+ out = strings .TrimSuffix (out , "\n " )
165+ }
166+
167+ return out
160168}
161169
162170// RenderTimelockProposal renders a Timelock ProposalReport as plain text using templates
@@ -188,7 +196,12 @@ func (r *TextRenderer) RenderTimelockProposal(rep *ProposalReport, ctx *FieldCon
188196 return fmt .Sprintf ("Error rendering timelock: %v" , err )
189197 }
190198
191- return buf .String ()
199+ out := buf .String ()
200+ if ! strings .HasSuffix (out , "\n \n " ) { // assuming double newline means intentional spacing
201+ out = strings .TrimSuffix (out , "\n " )
202+ }
203+
204+ return out
192205}
193206
194207// RenderField renders a NamedField as plain text
@@ -225,66 +238,72 @@ func (r *TextRenderer) getChainNameOrEmpty(selector uint64) string {
225238// renderFieldValue renders any field value as plain text using templates
226239func (r * TextRenderer ) renderFieldValue (field FieldValue ) string {
227240 var buf bytes.Buffer
228-
241+ var out string
229242 switch f := field .(type ) {
230243 case AddressField :
231244 data := AddressFieldData {Value : f .GetValue ()}
232245 if err := r .addressFieldTmpl .Execute (& buf , data ); err != nil {
233246 return fmt .Sprintf ("Error rendering address field: %v" , err )
234247 }
235248
236- return buf .String ()
249+ out = buf .String ()
237250
238251 case ChainSelectorField :
239252 if err := r .chainSelectorFieldTmpl .Execute (& buf , f ); err != nil {
240253 return fmt .Sprintf ("Error rendering chain selector field: %v" , err )
241254 }
242255
243- return buf .String ()
256+ out = buf .String ()
244257
245258 case BytesField :
246259 if err := r .bytesFieldTmpl .Execute (& buf , f ); err != nil {
247260 return fmt .Sprintf ("Error rendering bytes field: %v" , err )
248261 }
249262
250- return buf .String ()
263+ out = buf .String ()
251264
252265 case ArrayField :
253266 if err := r .arrayFieldTmpl .Execute (& buf , f ); err != nil {
254267 return fmt .Sprintf ("Error rendering array field: %v" , err )
255268 }
256269
257- return buf .String ()
270+ out = buf .String ()
258271
259272 case StructField :
260273 if err := r .structFieldTmpl .Execute (& buf , f ); err != nil {
261274 return fmt .Sprintf ("Error rendering struct field: %v" , err )
262275 }
263276
264- return buf .String ()
277+ out = buf .String ()
265278
266279 case SimpleField :
267280 if err := r .simpleFieldTmpl .Execute (& buf , f ); err != nil {
268281 return fmt .Sprintf ("Error rendering simple field: %v" , err )
269282 }
270283
271- return buf .String ()
284+ out = buf .String ()
272285
273286 case YamlField :
274287 if err := r .yamlFieldTmpl .Execute (& buf , f ); err != nil {
275288 return fmt .Sprintf ("Error rendering yaml field: %v" , err )
276289 }
277290
278- return buf .String ()
291+ out = buf .String ()
279292
280293 case NamedField :
281294 if err := r .namedFieldTmpl .Execute (& buf , f ); err != nil {
282295 return fmt .Sprintf ("Error rendering named field: %v" , err )
283296 }
284297
285- return buf .String ()
298+ out = buf .String ()
286299
287300 default :
288301 return fmt .Sprintf ("<unknown field type: %s>" , field .GetType ())
289302 }
303+
304+ if ! strings .HasSuffix (out , "\n \n " ) { // assuming double newline means intentional spacing
305+ out = strings .TrimSuffix (out , "\n " )
306+ }
307+
308+ return out
290309}
0 commit comments