mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
markup/goldmark: Change default cell alignment in table render hook
Change the default table cell alignment from "left" to an empty string. Closes #12886
This commit is contained in:
parent
d1ba52f3c3
commit
1158e63072
3 changed files with 14 additions and 6 deletions
|
@ -129,7 +129,7 @@ func (r *htmlRenderer) renderCell(w util.BufWriter, source []byte, node ast.Node
|
||||||
case gast.AlignCenter:
|
case gast.AlignCenter:
|
||||||
alignment = "center"
|
alignment = "center"
|
||||||
default:
|
default:
|
||||||
alignment = "left"
|
alignment = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
cell := hooks.TableCell{Text: hstring.HTML(text), Alignment: alignment}
|
cell := hooks.TableCell{Text: hstring.HTML(text), Alignment: alignment}
|
||||||
|
|
|
@ -65,8 +65,8 @@ Attributes: {{ .Attributes }}|
|
||||||
)
|
)
|
||||||
|
|
||||||
b.AssertFileContent("public/p1/index.html",
|
b.AssertFileContent("public/p1/index.html",
|
||||||
"table-1-thead: 0: 0: left: Month| 1: left: Savings|$",
|
"table-1-thead: 0: 0: : Month| 1: : 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-tbody: 0: 0: : January| 1: : $250| 1: 0: : February| 1: : $80| 2: 0: : March| 1: : $420|$",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
{{- range .THead }}
|
{{- range .THead }}
|
||||||
<tr>
|
<tr>
|
||||||
{{- range . }}
|
{{- range . }}
|
||||||
<th {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
|
<th
|
||||||
|
{{- with .Alignment }}
|
||||||
|
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
|
||||||
|
{{- end -}}
|
||||||
|
>
|
||||||
{{- .Text -}}
|
{{- .Text -}}
|
||||||
</th>
|
</th>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -19,7 +23,11 @@
|
||||||
{{- range .TBody }}
|
{{- range .TBody }}
|
||||||
<tr>
|
<tr>
|
||||||
{{- range . }}
|
{{- range . }}
|
||||||
<td {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
|
<td
|
||||||
|
{{- with .Alignment }}
|
||||||
|
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
|
||||||
|
{{- end -}}
|
||||||
|
>
|
||||||
{{- .Text -}}
|
{{- .Text -}}
|
||||||
</td>
|
</td>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue