注意要点: html
1.在iOS 能够依赖UIWebview 来实现git
2.丰富的UI样式依赖 html 的样式, js 调用插入markdown内容呈现出来github
3.实现markdown编辑快捷键:参考github 编辑内容的快捷键便可markdown
⚠️ 实现过程当中遇到一个问题,在github上 编辑好的文本,客户端在线预览的时候是空白的。。。调试了很久终于找到问题:同样的文本在pc端可能会生成\r,可是在iOS 客户端回车键只会是\n. 因此markdown文本在注入js前执行的过滤方案中我多加了一条过滤\r 即问题解决了测试
- (NSString *)getMarkdownContentWithMarkdowString:(NSString *)markdown { markdown = [markdown stringByReplacingOccurrencesOfString:@"\r"withString:@""];//⚠️防止不识别\r markdown = [markdown stringByReplacingOccurrencesOfString:@"\n"withString:@"\\n"]; markdown = [markdown stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; markdown = [markdown stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]; return markdown; }
测试复现这种状况 能够使用下面的测试文案:spa
(1)driving off the spleen and regulating the circulation.\r\n //没法显示 (2)driving off the spleen and regulating the circulation.\r //没法显示 (3)driving off the spleen and regulating the circulation.\n //正常 (4)driving off the spleen and regulating the circulation. //正常
markdown 编辑效果以下:调试
markdown 预览效果以下:code
参考项目:地址 https://github.com/Li-Qun/EditMarkdownDemo htm
欢迎给小星星✨✨✨鼓励哦😘😘😘blog