From 5df9c44a5c8d424ac958ba64aab6a77033eaed70 Mon Sep 17 00:00:00 2001 From: Edward Loveall Date: Wed, 20 Oct 2021 20:40:43 -0400 Subject: [PATCH] Support null text on paragraphs I think this was an old feature on medium, but you can see examples of null text on this post: https://medium.com/message/the-joy-of-typing-fd8d091ab8ef --- src/classes/markup_converter.cr | 5 +++-- src/models/post_response.cr | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/classes/markup_converter.cr b/src/classes/markup_converter.cr index 5a47460..dbbe6a4 100644 --- a/src/classes/markup_converter.cr +++ b/src/classes/markup_converter.cr @@ -12,11 +12,12 @@ class MarkupConverter getter markups : Array(PostResponse::Markup) getter text : String - def self.convert(text : String, markups : Array(PostResponse::Markup)) + def self.convert(text : String?, markups : Array(PostResponse::Markup)) new(text, markups).convert end - def initialize(@text : String, @markups : Array(PostResponse::Markup)) + def initialize(text : String?, @markups : Array(PostResponse::Markup)) + @text = text || "" end def convert : Array(Child) diff --git a/src/models/post_response.cr b/src/models/post_response.cr index 1088d25..bf0c66c 100644 --- a/src/models/post_response.cr +++ b/src/models/post_response.cr @@ -32,7 +32,7 @@ class PostResponse end class Paragraph < Base - property text : String + property text : String? property type : ParagraphType property markups : Array(Markup) property iframe : IFrame?