File tree 2 files changed +28
-19
lines changed
2 files changed +28
-19
lines changed Original file line number Diff line number Diff line change 13
13
#import " Coding_FileManager.h"
14
14
#import " WebContentManager.h"
15
15
#import " FunctionTipsManager.h"
16
- #import < MMMarkdown/MMMarkdown.h>
17
16
#import " EaseToolBar.h"
18
17
19
18
#import " FileActivitiesViewController.h"
@@ -178,21 +177,14 @@ - (void)loadWebView:(NSURL *)fileUrl{
178
177
}];
179
178
}
180
179
if ([self .fileType isEqualToString: @" md" ]){
181
- NSError *error = nil ;
182
- NSString *htmlStr;
183
- @try {
184
- NSString *mdStr = [NSString stringWithContentsOfURL: fileUrl encoding: NSUTF8StringEncoding error: &error];
185
- htmlStr = [MMMarkdown HTMLStringWithMarkdown: mdStr error: &error];
186
- }
187
- @catch (NSException *exception ) {
188
- htmlStr = @" 加载失败!" ;
189
- }
190
-
191
- if (error) {
192
- htmlStr = @" 加载失败!" ;
193
- }
194
- NSString *contentStr = [WebContentManager markdownPatternedWithContent: htmlStr];
195
- [self .contentWebView loadHTMLString: contentStr baseURL: nil ];
180
+ NSString *mdStr = [NSString stringWithContentsOfURL: fileUrl encoding: NSUTF8StringEncoding error: nil ];
181
+ [self .activityIndicator startAnimating ];
182
+ [[Coding_NetAPIManager sharedManager ] request_MDHtmlStr_WithMDStr: mdStr inProject: nil andBlock: ^(id data, NSError *error) {
183
+ NSString *htmlStr;
184
+ htmlStr = data? data: @" 加载失败" ;
185
+ NSString *contentStr = [WebContentManager markdownPatternedWithContent: htmlStr];
186
+ [self .contentWebView loadHTMLString: contentStr baseURL: nil ];
187
+ }];
196
188
}else if ([self .fileType isEqualToString: @" html" ]){
197
189
NSString * htmlString = [NSString stringWithContentsOfURL: fileUrl encoding: NSUTF8StringEncoding error: nil ];
198
190
[self .contentWebView loadHTMLString: htmlString baseURL: nil ];
Original file line number Diff line number Diff line change 10
10
#import "JDStatusBarNotification.h"
11
11
#import "UnReadManager.h"
12
12
#import <NYXImagesKit/NYXImagesKit.h>
13
+ #import <MMMarkdown/MMMarkdown.h>
13
14
#import "MBProgressHUD+Add.h"
14
15
15
16
@implementation Coding_NetAPIManager
@@ -2172,16 +2173,32 @@ - (void)request_MDHtmlStr_WithMDStr:(NSString *)mdStr inProject:(Project *)proje
2172
2173
path = [NSString stringWithFormat:@"api/user/%@/project/%@/markdownNoAt", project.owner_user_name, project.name];
2173
2174
}
2174
2175
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:@{@"content" : mdStr} withMethodType:Post andBlock:^(id data, NSError *error) {
2175
- if (data) {
2176
- [MobClick event:kUmeng_Event_Request_Get label:@"md-html转化"];
2176
+ [MobClick event:kUmeng_Event_Request_Get label:@"md-html转化"];
2177
2177
2178
+ if (data) {
2178
2179
id resultData = [data valueForKeyPath:@"data"];
2179
2180
block(resultData, nil);
2180
2181
}else{
2181
- block(nil , error);
2182
+ block([self localMDHtmlStr_WithMDStr:mdStr] , error);
2182
2183
}
2183
2184
}];
2184
2185
}
2186
+
2187
+ - (NSString *)localMDHtmlStr_WithMDStr:(NSString *)mdStr{
2188
+ NSError *error = nil;
2189
+ NSString *htmlStr;
2190
+ @try {
2191
+ htmlStr = [MMMarkdown HTMLStringWithMarkdown:mdStr error:&error];
2192
+ }
2193
+ @catch (NSException *exception) {
2194
+ htmlStr = @"加载失败!";
2195
+ }
2196
+ if (error) {
2197
+ htmlStr = @"加载失败!";
2198
+ }
2199
+ return htmlStr;
2200
+ }
2201
+
2185
2202
- (void)request_VerifyTypeWithBlock:(void (^)(VerifyType type, NSError *error))block{
2186
2203
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/user/2fa/method" withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
2187
2204
if (data) {
You can’t perform that action at this time.
0 commit comments