loiclec / Apodimark

Fast, flexible markdown parser written in Swift
MIT License
0 stars 0 forks source link

Question on usage #11

Closed ncperry closed 7 years ago

ncperry commented 7 years ago

This looks like a really promising library that might solve a lot of problems for us. But I'm a little confused on usage. In the readme you say Apodimark is a markdown parser written in pure Swift 3. It is fast, flexible, easy to use, and works with indices instead of String, which is ideal for syntax highlighting.

I was wondering how you intended to perform syntax highlighting. I'm used to doing syntax highlighting using NSAttributedString, which uses NSString and NSRange which don't translate very well to UTF16View and Range. Is there a highlighting method that I am not aware of?

loiclec commented 7 years ago

To be honest, I should remove the "easy to use" part. To answer your question: NSString uses UTF16 internally and so the nth element of a String.UTF16View corresponds to the nth element of an NSString. If you look at the closed issue, someone asked me to provide an example app to show how to use the library, and I created a TestApodimark repo which shows how to provide some simplistic syntax highlighting. I did need a function to transform a Range of String.UTF16View.Index to an NSRange.

If you have any other question, don't hesitate to ask me :)

ncperry commented 7 years ago

That example helped me out a lot. That Swift Range to NSRange was just what I needed.