Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit bf263b7

Browse files
authored
Show empty string when no markdown (#1732)
1 parent 8c4e734 commit bf263b7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Classes/Issues/Comments/Markdown/CMarkParsing.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,20 @@ private extension Element {
319319
}
320320
}
321321

322+
private func emptyDescription(options: CMarkOptions) -> ListDiffable {
323+
let builder = StyledTextBuilder.markdownBase()
324+
.add(
325+
text: NSLocalizedString("No description provided.", comment: ""),
326+
traits: .traitItalic,
327+
attributes: [.foregroundColor: Styles.Colors.Gray.medium.color]
328+
)
329+
return StyledTextRenderer(
330+
string: builder.build(),
331+
contentSizeCategory: options.contentSizeCategory,
332+
inset: IssueCommentTextCell.inset
333+
).warm(width: options.width)
334+
}
335+
322336
func MarkdownModels(
323337
_ markdown: String,
324338
owner: String,
@@ -342,6 +356,11 @@ func MarkdownModels(
342356
viewerCanUpdate: viewerCanUpdate,
343357
contentSizeCategory: contentSizeCategory
344358
)
345-
return node.flatElements.compactMap { $0.model(options) }
359+
let models = node.flatElements.compactMap { $0.model(options) }
360+
if models.count == 0 {
361+
return [emptyDescription(options: options)]
362+
} else {
363+
return models
364+
}
346365
}
347366

0 commit comments

Comments
 (0)