Skip to content

[iOS] 单表格渲染如果存在inline code时,foundInlineCode越界 #55

@weirui-kong

Description

@weirui-kong

构造如下markdown内容:

|模块|子模块|功能|状态|优先级|
|---|---|---|---|---|
|用户管理|登录|用户名密码登录|已完成|P0|
|用户管理|登录|第三方登录|进行中|P1|
|用户管理|注册|邮箱注册|已完成|P0|
|用户管理|注册|手机号注册|待开始|P1|
|消息管理|发送|文本消息|已完成|P0|
|消息管理|发送|图片消息|进行中|P1|
|消息管理|接收|Markdown渲染|已完成|P0|
|消息管理|接收|内容1<br>内容2<br>内容3|已完成|P0|
|消息管理|接收|**加粗内容**|已完成|P0|
|消息管理|接收|*斜体内容*|已完成|P0|
|消息管理|接收|`行内代码`|已完成|P0|  

- (void)parser:(CMParser *)parser foundInlineCode:(NSString *)code
{
    [self.attributeStack pushAttributes:_attributes.inlineCodeAttributes];
    if(code && [code length] > 0)
    {
        NSString* codeStr = [NSString stringWithFormat:@"\u00A0%@\u00A0", code];
        [self appendString:codeStr];
        NSDictionary* spaceAttr = @{NSKernAttributeName:@(6),NSFontAttributeName:[UIFont systemFontOfSize:2.f]};
        [self.buffer addAttributes:spaceAttr range:NSMakeRange(self.buffer.length - codeStr.length, 1)];
        [self.buffer addAttributes:spaceAttr range:NSMakeRange(self.buffer.length - 1, 1)];
    }
    [self.attributeStack pop];
}

中,此时buffer内容为空,会发生越界错误,导致无法正常渲染显示。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions