What is the simplest implementation of Markdown for a Cocoa application?

前端 未结 6 1238
难免孤独
难免孤独 2020-11-30 18:45

I\'m writing a Cocoa application in Objective-C, and I would like to be able to incorporate Markdown. The user will enter text in Markdown syntax, click an \"export\" button

6条回答
  •  自闭症患者
    2020-11-30 19:15

    I found problems with processing large amounts of markdown with these C-based libraries.

    There's a very simple Obj-C library that worked for me here:

    https://github.com/mdiep/MMMarkdown


    Steps to use MMMarkdown:

    1. Build the OS X or iOS target

    2. Copy include/MMMarkdown.h and either lib/libMMMarkdown-Mac.a or lib/libMMMarkdown-iOS.a into your project

    3. Then the code is:

    #import "MMMarkdown.h"
    
    NSError  *error;
    NSString *markdown   = @"# Example\nWhat a library!";
    NSString *htmlString = [MMMarkdown HTMLStringWithMarkdown:markdown error:&error];
    // Returns @"

    Example

    \n

    What a library!

    "

提交回复
热议问题