Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Markdown from String not File #24

Closed
talezion opened this issue Feb 25, 2016 · 3 comments
Closed

Convert Markdown from String not File #24

talezion opened this issue Feb 25, 2016 · 3 comments

Comments

@talezion
Copy link

Hi,

Is there a way to convert Markdown directly from String instead of creating CMDocument? The reason is I have the markdown text in a String, so I need to save to local directory and then convert to CMDocument which is an expensive task. CMDocument can only take contentOfFile.

Thank you
Tal

@indragiek
Copy link
Owner

You can use -[CMDocument initWithData:options:]. For an NSString you have to convert it into an NSData first:

// Use appropriate encoding here
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
CMDocument *doc = [[CMDocument alloc] initWithData:data options:0];

@albertbori
Copy link

+1 Would be nice to have a convenience initializer.

@indragiek
Copy link
Owner

A convenience initializer was added as part of #52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants