Author: Honza Pokorny <honza@redhat.com>
Clean up debug code in org rendering
pkg/bookends/bookends.go | 40 ++++++++++++++++++++++++++--------------
diff --git a/pkg/bookends/bookends.go b/pkg/bookends/bookends.go index ce0e324b9151116291e5b5abcf66a63f11ce7951..b7cc4af28b7ad27a44ec589d52ee90ab7d5b8d62 100644 --- a/pkg/bookends/bookends.go +++ b/pkg/bookends/bookends.go @@ -227,15 +227,25 @@ switch wt := w.(type) { case org.Text: fmt.Fprintln(rest, wt) case org.Emphasis: - fmt.Fprintf(rest, "<em>%s</em>", wt.Content[0].String()) + switch wt.Kind { + case "*": + fmt.Fprintf(rest, "<b>%s</b>", wt.Content[0].String()) + case "/": + fmt.Fprintf(rest, "<em>%s</em>", wt.Content[0].String()) + case "=": + fmt.Fprintf(rest, "<code>%s</code>", wt.Content[0].String()) + } case org.Timestamp: - fmt.Fprintln(rest, "timestamp par child", wt) + if wt.IsDate { + fmt.Fprintln(rest, wt.Time.Format("January 2, 2006")) + } else { + fmt.Fprintln(rest, wt.Time.Format("January 2, 2006 at 15:04")) + } case org.RegularLink: - fmt.Fprintf(rest, `<a href="%s">%s</a>`, wt.URL, wt.Description) + fmt.Fprintf(rest, `<a href="%s">%s</a>`, wt.URL, wt.Description[0]) case org.LineBreak: continue default: - fmt.Fprintln(rest, "def par", wt) } } fmt.Fprintln(rest, "</p>") @@ -244,29 +254,31 @@ case org.Block: if t.Name == "QUOTE" { fmt.Fprintln(rest, "<blockquote>") for _, p := range t.Children { - fmt.Fprintf(rest, "%s<br><br>", p) + fmt.Fprintf(rest, "%s<br>", p) } fmt.Fprintln(rest, "</blockquote>") } case org.List: - fmt.Fprint(rest, "<ul>") + if t.Kind == "ordered" { + fmt.Fprint(rest, "<ol>") + } else { + fmt.Fprint(rest, "<ul>") + } for _, w := range t.Items { switch wt := w.(type) { case org.ListItem: - fmt.Fprintf(rest, `<li>BBB (%s) %s</li>`, wt.Bullet, wt.Children[0].String()) - case org.DescriptiveListItem: - fmt.Fprintf(rest, `<li> desc %s</li>`, wt) + fmt.Fprintf(rest, `<li>%s</li>`, wt.Children[0].String()) default: - fmt.Fprintln(rest, "list item def par child", wt) } } - fmt.Fprintln(rest, "</ul>") + if t.Kind == "ordered" { + fmt.Fprint(rest, "</ol>") + } else { + fmt.Fprint(rest, "</ul>") + } case org.LineBreak: fmt.Fprintln(rest, "") - case org.Timestamp: - fmt.Fprintln(rest, "BRUH") - panic("") default: } }