Make a String() function for AlignmentFlags
Implement the TODO and a method `String()` that returns a string for AlignmentFlags. Pondered doing the same for Matters and CitationTypes, but those are more renderer dependent (and not standard). Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
3b95c4fb8e
commit
543ba837f9
13
ast/node.go
13
ast/node.go
|
@ -28,6 +28,19 @@ const (
|
||||||
TableAlignmentCenter = (TableAlignmentLeft | TableAlignmentRight)
|
TableAlignmentCenter = (TableAlignmentLeft | TableAlignmentRight)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (a CellAlignFlags) String() string {
|
||||||
|
switch a {
|
||||||
|
case TableAlignmentLeft:
|
||||||
|
return "left"
|
||||||
|
case TableAlignmentRight:
|
||||||
|
return "right"
|
||||||
|
case TableAlignmentCenter:
|
||||||
|
return "center"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DocumentMatters holds the type of a {front,main,back}matter in the document
|
// DocumentMatters holds the type of a {front,main,back}matter in the document
|
||||||
type DocumentMatters int
|
type DocumentMatters int
|
||||||
|
|
||||||
|
|
|
@ -358,20 +358,6 @@ func skipParagraphTags(para *ast.Paragraph) bool {
|
||||||
return tightOrTerm
|
return tightOrTerm
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change this to be ast.CellAlignFlags.ToString()
|
|
||||||
func cellAlignment(align ast.CellAlignFlags) string {
|
|
||||||
switch align {
|
|
||||||
case ast.TableAlignmentLeft:
|
|
||||||
return "left"
|
|
||||||
case ast.TableAlignmentRight:
|
|
||||||
return "right"
|
|
||||||
case ast.TableAlignmentCenter:
|
|
||||||
return "center"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Renderer) out(w io.Writer, d []byte) {
|
func (r *Renderer) out(w io.Writer, d []byte) {
|
||||||
r.lastOutputLen = len(d)
|
r.lastOutputLen = len(d)
|
||||||
if r.disableTags > 0 {
|
if r.disableTags > 0 {
|
||||||
|
@ -807,7 +793,7 @@ func (r *Renderer) tableCell(w io.Writer, tableCell *ast.TableCell, entering boo
|
||||||
if tableCell.IsHeader {
|
if tableCell.IsHeader {
|
||||||
openTag = "<th"
|
openTag = "<th"
|
||||||
}
|
}
|
||||||
align := cellAlignment(tableCell.Align)
|
align := tableCell.Align.String()
|
||||||
if align != "" {
|
if align != "" {
|
||||||
attrs = append(attrs, fmt.Sprintf(`align="%s"`, align))
|
attrs = append(attrs, fmt.Sprintf(`align="%s"`, align))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue