ZeeZide/CodeEditor

Can this support markdown (MD) files ?

pkasson opened this issue · 11 comments

Can this support markdown (MD) files ?
helje5 commented

static var markdown = CodeEditor.Language(rawValue: "markdown")

My bad ... was looking at the theme instead of language.

Choosing MD, it does colorize things, but not formatting I think (attached code and screen shots below)

CodeEditor(source : $activeItemModel.item.body, language : .markdown, theme : model.selectedTheme, flags : [ .selectable, .editable, .smartIndent ], autoPairs: [ "{": "}", "<": ">", "'": "'" ]

Screenshot 2023-05-01 at 11 16 51 AM

helje5 commented

Correct, this is a CodeEditor, not a WYSIWYG editor.

understood this is not an editor - but didn't know, if I could extend something to allow it to render MD

helje5 commented

Sure, you can!

Any insights on how to proceed ? would certainly push it back as a PR

helje5 commented

As mentioned such a PR would be out of scope, this isn't supposed to be a WYSIWYG editor for any format. If you want to add this in a fork, that is perfectly fine and you are welcome. You'd have to do the necessary processing and apply the styles to the textstorage. TBH that feels quite different to this project though (which is about syntax highlighting), I would recommend to just implement it for MD from the start then. A sensible markdown editor is no small task though.

Understood - the use case I have is more of a renderer than editor.

helje5 commented

A Markdown renderer is directly built into the latest SwiftUI versions.

I did try that (Text component) but it is not perfect .. but better than nothing for now, I guess.

helje5 commented

For display I just use swift-markdown and a WKWebView, e.g. in SwiftPM Catalog.