-
Notifications
You must be signed in to change notification settings - Fork 76
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
Apply NSParagraphStyleAttributeName to list items via listAttributes #50
Comments
Hello @nateirwin, I haven't tried
|
Hey @Coeur, thanks for getting back to me. Adding the code from your post does work correctly, so it definitely seems like there's something going on with |
@nateirwin, did you find a reason or a workaround? |
Nope, no more progress on this. It isn't a show stopper for us, though it would be nice to be able to apply different styling to lists. |
This seems to be an issue with NSAttributedString. Applying the paragraph style for each bulleted line does not work. Instead, the style needs to be applied across all the bulleted lines. A workaround might be to use a separate attributed string for bulleted lists. |
@Coeur Any progress on this issue? or workaround? |
@kyledold @Coeur actually this works fine right now in my App if I simply set it for the listAttributes. NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; So I think this issue can be closed? |
So my issue was setting the NSParagraphStyleAttributeName attribute for the "listAttributes" property of the parser wasn't having any effect, even after trying @BobDG's example. The only way I could get this to work was to set the NSParagraphStyleAttributeName attribute of the "defaultAttributes" property. |
@kyledold hm strange, it works perfectly for me. Only for bullet lists unordered though, nut numbered lists because the regex doesn't take those into account. |
@BobDG which version are you using? I've got v2.1.3 |
@kyledold me too.. what you can check is perhaps if the regex actually captures your lists by putting some logs at the right places? |
I am also having this issue. Version 2.1.3. Things look great when applying the style to the whole string using defaultAttributes but using listAttributes doesn't seem to do anything once the string wraps. I think this may be a mutable string bug though. I have experienced issues in the past trying to apply multiple paragraph styles to a attributed string. Kind of a huge bummer because it makes an existing view more complicated to break out all the strings into their own labels. |
@khill25 @BobDG I found the only way to get NSParagraphStyleAttributeName set for list elements is to create your own version of the TSMarkdownParser object and then in the init method where you add all the parsing logic you need to replace the "addListParsingWithMaxLevel" method with the following:
Not the cleanest solution but it works. |
@kyledold ok nice you got it working! If I look at the code I still don't understand why mine is working without any adaptations and that you need these changes. But I'm glad it works for you now :) |
I'm trying to add consistent indentation to ordered and unordered list items coming down in a Markdown string. If I change the
defaultAttributes
property on the TSMarkdownParser instance, adding an NSParagraphStyleAttributeName, the indentation settings work but are applied to all of the Markdown text. What I'm hoping to do is only apply the NSParagraphStyleAttributeName to the text that's associated with a Markdown list.Pared down code here:
Hopefully this explanation makes sense. I'm an Objective-C newb.
The text was updated successfully, but these errors were encountered: