@@ -39,8 +39,8 @@ func (Renderer) SanitizerRules() []setting.MarkupSanitizerRule {
3939 {Element : "table" , AllowAttr : "class" , Regexp : regexp .MustCompile (`data-table` )},
4040 {Element : "th" , AllowAttr : "class" , Regexp : regexp .MustCompile (`line-num` )},
4141 {Element : "td" , AllowAttr : "class" , Regexp : regexp .MustCompile (`line-num` )},
42- {Element : "div" , AllowAttr : "class" , Regexp : regexp .MustCompile (`tw-flex tw-justify-center tw-items-center` )},
43- {Element : "a" , AllowAttr : "href" , Regexp : regexp .MustCompile (`\?display=source ` )},
42+ {Element : "div" , AllowAttr : "class" , Regexp : regexp .MustCompile (`tw-flex tw-justify-center tw-items-center tw-py-4 tw-text-14 ` )},
43+ {Element : "a" , AllowAttr : "href" , Regexp : regexp .MustCompile (`` )},
4444 }
4545}
4646
@@ -81,7 +81,6 @@ func writeField(w io.Writer, element, class, field string) error {
8181// Render implements markup.Renderer
8282func (r Renderer ) Render (ctx * markup.RenderContext , input io.Reader , output io.Writer ) error {
8383 tmpBlock := bufio .NewWriter (output )
84- warnBlock := bufio .NewWriter (tmpBlock )
8584 maxSize := setting .UI .CSV .MaxFileSize
8685 maxRows := setting .UI .CSV .MaxRows
8786
@@ -129,23 +128,22 @@ func (r Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.W
129128 row ++
130129 }
131130
131+ if _ , err = tmpBlock .WriteString ("</table>" ); err != nil {
132+ return err
133+ }
134+
132135 // Check if maxRows or maxSize is reached, and if true, warn.
133136 if (row >= maxRows && maxRows != 0 ) || (rd .InputOffset () >= maxSize && maxSize != 0 ) {
134137 locale := ctx .Ctx .Value (translation .ContextKey ).(translation.Locale )
135138
136139 // Construct the HTML string
137- warn := `<div class="tw-flex tw-justify-center tw-items-center"><div>` + locale .TrString ("repo.file_too_large" ) + ` <a class="source" href="?display=source ">` + locale .TrString ("repo.file_view_source " ) + `</a></div></div>`
140+ warn := `<div class="tw-flex tw-justify-center tw-items-center tw-py-4 tw-text-14 "><div>` + locale .TrString ("repo.file_too_large" ) + ` <a class="source" href="` + ctx . Links . RawLink () + `/` + ctx . RelativePath + ` ">` + locale .TrString ("repo.file_view_raw " ) + `</a></div></div>`
138141
139142 // Write the HTML string to the output
140- if _ , err := warnBlock .WriteString (warn ); err != nil {
141- return err
142- }
143- if err = warnBlock .Flush (); err != nil {
143+ if _ , err := tmpBlock .WriteString (warn ); err != nil {
144144 return err
145145 }
146146 }
147- if _ , err = tmpBlock .WriteString ("</table>" ); err != nil {
148- return err
149- }
147+
150148 return tmpBlock .Flush ()
151149}
0 commit comments