]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
markup/goldmark: Change default cell alignment in table render hook
authorJoe Mooring <joe.mooring@veriphor.com>
Sat, 28 Sep 2024 19:06:09 +0000 (12:06 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 30 Sep 2024 06:44:14 +0000 (08:44 +0200)
Change the default table cell alignment from "left" to an empty string.

Closes #12886

markup/goldmark/tables/tables.go
markup/goldmark/tables/tables_integration_test.go
tpl/tplimpl/embedded/templates/_default/_markup/render-table.html

index 0aa6ee26947f6a6d8a4a02f5f2a042440ffccb4d..a7dfb8ee6ed598dc90047c8171afd18e84692b4d 100644 (file)
@@ -129,7 +129,7 @@ func (r *htmlRenderer) renderCell(w util.BufWriter, source []byte, node ast.Node
        case gast.AlignCenter:
                alignment = "center"
        default:
-               alignment = "left"
+               alignment = ""
        }
 
        cell := hooks.TableCell{Text: hstring.HTML(text), Alignment: alignment}
index dadce5c81fece5f7d89f45d94a492d2078af3783..85cf81c9d0449cab85de8961fb546a783d89ebde 100644 (file)
@@ -32,7 +32,7 @@ title = true
 | Item              | In Stock | Price |
 | :---------------- | :------: | ----: |
 | Python Hat        |   True   | 23.99 |
-| SQL **Hat**           |   True   | 23.99 |
+| SQL **Hat**       |   True   | 23.99 |
 | Codecademy Tee    |  False   | 19.99 |
 | Codecademy Hoodie |  False   | 42.99 |
 {.foo foo="bar"}
@@ -65,8 +65,8 @@ Attributes: {{ .Attributes }}|
        )
 
        b.AssertFileContent("public/p1/index.html",
-               "table-1-thead: 0: 0: left: Month| 1: left: Savings|$",
-               "table-1-tbody: 0: 0: left: January| 1: left: $250| 1: 0: left: February| 1: left: $80| 2: 0: left: March| 1: left: $420|$",
+               "table-1-thead: 0: 0: : Month| 1: : Savings|$",
+               "table-1-tbody: 0: 0: : January| 1: : $250| 1: 0: : February| 1: : $80| 2: 0: : March| 1: : $420|$",
        )
 }
 
index a0b0cc34d4c9aec90382a8f7369b04e39495555c..5fdd79ddb9ab309b012574fe606f249f2da0e9c2 100644 (file)
@@ -8,7 +8,11 @@
     {{- range .THead }}
       <tr>
         {{- range . }}
-          <th {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
+          <th
+            {{- with .Alignment }}
+              {{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
+            {{- end -}}
+          >
             {{- .Text -}}
           </th>
         {{- end }}
     {{- range .TBody }}
       <tr>
         {{- range . }}
-          <td {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
+          <td
+            {{- with .Alignment }}
+              {{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
+            {{- end -}}
+          >
             {{- .Text -}}
           </td>
         {{- end }}