diff --git a/frontend/dist/index.html b/frontend/dist/index.html index 9e661d4..38bb3ef 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -6,7 +6,7 @@ {{ .Title }} - +

Hello, World!

diff --git a/frontend/dist/show.html b/frontend/dist/show.html index 291653d..a8b8c9d 100644 --- a/frontend/dist/show.html +++ b/frontend/dist/show.html @@ -14,13 +14,13 @@ rel="stylesheet"> {{ .Title }} - + -
-

{{.Title}}

-

{{.Author}} on {{.PublishDate}}

+
+

{{.Title}}

+

{{.Author}} on {{.PublishDate}}

{{.Paragraphs}}
diff --git a/frontend/show.html b/frontend/show.html index 246aee7..c18f52f 100644 --- a/frontend/show.html +++ b/frontend/show.html @@ -17,9 +17,9 @@ -
-

{{.Title}}

-

{{.Author}} on {{.PublishDate}}

+
+

{{.Title}}

+

{{.Author}} on {{.PublishDate}}

{{.Paragraphs}}
diff --git a/go.mod b/go.mod index d9130e8..72b5d34 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,13 @@ module github.com/medium.rip go 1.20 -require github.com/sirupsen/logrus v1.9.2 - require ( - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/gofiber/template v1.8.1 // indirect + github.com/gofiber/template v1.8.1 + github.com/sirupsen/logrus v1.9.2 ) +require github.com/fsnotify/fsnotify v1.6.0 // indirect + require ( github.com/andybalholm/brotli v1.0.5 // indirect github.com/gofiber/fiber/v2 v2.46.0 diff --git a/pkg/converters/paragraph_converter.go b/pkg/converters/paragraph_converter.go index 7661e9a..75d62e1 100644 --- a/pkg/converters/paragraph_converter.go +++ b/pkg/converters/paragraph_converter.go @@ -62,7 +62,13 @@ func ConvertParagraphs(paragraphs []entities.Paragraph) string { var ps strings.Builder + skipCount := 0 for i, p := range paragraphs { + if skipCount > 0 { + skipCount-- + continue + } + switch p.Type { case "BQ", "MIXTAPE_EMBED", "PQ": children := ConvertMarkup(p.Text, p.Markups) @@ -92,10 +98,12 @@ func ConvertParagraphs(paragraphs []entities.Paragraph) string { case "IMG": ps.WriteString(convertImg(p)) case "OLI": - listItems := convertOli(paragraphs[i:]) + listItems, skip := convertOli(paragraphs[i:]) + skipCount = skip ps.WriteString(fmt.Sprintf("
    %s
", listItems)) case "ULI": - listItems := convertUli(paragraphs[i:]) + listItems, skip := convertUli(paragraphs[i:]) + skipCount = skip ps.WriteString(fmt.Sprintf("", listItems)) case "P": children := ConvertMarkup(p.Text, p.Markups) @@ -115,7 +123,7 @@ func ConvertParagraphs(paragraphs []entities.Paragraph) string { func convertImg(p entities.Paragraph) string { if p.Metadata != nil { captionMarkup := ConvertMarkup(p.Text, p.Markups) - img := Image{ID : p.Metadata.ID} + img := Image{ID: p.Metadata.ID} img.Initialize(&p.Metadata.OriginalWidth, &p.Metadata.OriginalHeight) return fmt.Sprintf("
%s
", img.src(), img.width(), captionMarkup) } else { @@ -123,22 +131,39 @@ func convertImg(p entities.Paragraph) string { } } -func convertOli(ps []entities.Paragraph) string { - if len(ps) != 0 && ps[0].Type == "OLI" { - p := ps[0] - children := ConvertMarkup(p.Text, p.Markups) - return fmt.Sprintf("
  • %s
  • ", children) + convertOli(ps[1:]) - } else { - return "" +func convertOli(ps []entities.Paragraph) (string, int) { + var sb strings.Builder + count := 0 + + for _, p := range ps { + if p.Type == "OLI" { + children := ConvertMarkup(p.Text, p.Markups) + sb.WriteString(fmt.Sprintf("
  • %s
  • ", children)) + count++ + } else { + break + } } + + return sb.String(), count } -func convertUli(ps []entities.Paragraph) string { - if len(ps) != 0 && ps[0].Type == "ULI" { - p := ps[0] - children := ConvertMarkup(p.Text, p.Markups) - return fmt.Sprintf("
  • %s
  • ", children) + convertUli(ps[1:]) - } else { - return "" +func convertUli(ps []entities.Paragraph) (string, int) { + var sb strings.Builder + count := 0 + + for _, p := range ps { + if p.Type == "ULI" { + if p.Text == "Rename the example.env to .env." { + fmt.Println("HERE") + } + children := ConvertMarkup(p.Text, p.Markups) + sb.WriteString(fmt.Sprintf("
  • %s
  • ", children)) + count++ + } else { + break + } } + + return sb.String(), count }