Skip to content

Commit

Permalink
Don't warn about empty footnotes
Browse files Browse the repository at this point in the history
wp2hugo handled empty footnotes but it emitted a warning about "Error
unmarshalling footnotes". Now it skips them entirely.
  • Loading branch information
caboteria committed Aug 12, 2024
1 parent b9f591f commit 668b453
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<wp:meta_key><![CDATA[footnotes]]></wp:meta_key>
<wp:meta_value><![CDATA[[{"content":"Here we are: the footnote.","id":"082fba72-356e-41c6-acc1-ae0bc20828b2"}]]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key><![CDATA[footnotes]]></wp:meta_key>
<wp:meta_value><![CDATA[]]></wp:meta_value><!-- Empty Footnote -->
</wp:postmeta>
</item>
</channel>
</rss>
Expand Down
5 changes: 4 additions & 1 deletion src/wp2hugo/internal/wpparser/wp_parser_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ func getFootnotes(item *rss.Item) []Footnote {
if meta.Children["meta_key"][0].Value != "footnotes" {
continue
}
log.Warn().Msgf("ashishb_meta: %+v", meta)
if len(meta.Children["meta_value"][0].Value) == 0 {
continue
}
log.Debug().Msgf("ashishb_meta: %+v", meta)
footnoteJSON := meta.Children["meta_value"][0].Value
footnoteArr := make([]Footnote, 0)
if err := json.Unmarshal([]byte(footnoteJSON), &footnoteArr); err != nil {
Expand Down

0 comments on commit 668b453

Please sign in to comment.