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

Commit 178d770

Browse files
authored
Remove MMMarkdown dependency (#1729)
* replace old markdown callsites * unit tests working * remove unused parsing * final removal of old parsing, build and tests succeed * remove dependency * capture readme ref branch
1 parent 92b4e94 commit 178d770

File tree

62 files changed

+5745
-11924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5745
-11924
lines changed

Classes/Issues/Comments/IssueCommentSectionController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,14 @@ final class IssueCommentSectionController:
200200

201201
func edit(markdown: String) {
202202
guard let width = collectionContext?.insetContainerSize.width else { return }
203-
let options = commentModelOptions(
203+
let bodyModels = MarkdownModels(
204+
markdown,
204205
owner: model.owner,
205206
repo: model.repo,
206-
contentSizeCategory: UIApplication.shared.preferredContentSizeCategory,
207-
width: width
207+
width: width,
208+
viewerCanUpdate: true,
209+
contentSizeCategory: UIApplication.shared.preferredContentSizeCategory
208210
)
209-
let bodyModels = CreateCommentModels(markdown: markdown, options: options, viewerCanUpdate: true)
210211
bodyEdits = (markdown, bodyModels)
211212
collapsed = false
212213
clearCollapseCells()

Classes/Issues/Comments/Markdown/CMarkParsing.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,15 @@ private extension Element {
256256
backgroundColor: .white
257257
).warm(width: options.width)
258258
return IssueCommentQuoteModel(level: level, string: string)
259-
case .image(let title, let url):
260-
return CreateImageModel(href: url, title: title)
259+
case .image(let title, let href):
260+
guard let url = URL(string: href) else { return nil }
261+
if url.pathExtension.lowercased() == "svg" {
262+
// hack to workaround the SDWebImage not supporting svg images
263+
// just render it in a webview
264+
return IssueCommentHtmlModel(html: "<img src=\(href) />")
265+
} else {
266+
return IssueCommentImageModel(url: url, title: title)
267+
}
261268
case .html(let text):
262269
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
263270
guard !trimmed.isEmpty else { return nil }
@@ -318,7 +325,8 @@ func MarkdownModels(
318325
repo: String,
319326
width: CGFloat,
320327
viewerCanUpdate: Bool,
321-
contentSizeCategory: UIContentSizeCategory
328+
contentSizeCategory: UIContentSizeCategory,
329+
branch: String = "master"
322330
) -> [ListDiffable] {
323331
let cleaned = markdown
324332
.replacingGithubEmojiRegex
@@ -329,7 +337,7 @@ func MarkdownModels(
329337
let options = CMarkOptions(
330338
owner: owner,
331339
repo: repo,
332-
branch: nil, // TODO pass in branch
340+
branch: branch,
333341
width: width,
334342
viewerCanUpdate: viewerCanUpdate,
335343
contentSizeCategory: contentSizeCategory

Classes/Issues/Comments/Markdown/CommentModelsFromMarkdown.swift

Lines changed: 0 additions & 328 deletions
This file was deleted.

0 commit comments

Comments
 (0)