chockenberry / markdownattributedstring Goto Github PK
View Code? Open in Web Editor NEWAdding Markdown support to NSAttributedString.
Adding Markdown support to NSAttributedString.
See attached unit tests.
See attached unit tests.
Setting NSUnderlineStyleAttributeName
in MarkdownStyleEmphasisSingle
only seems to work if MarkdownStyleEmphasisDouble
is defined as well that contains a significant attributed style difference.
Use case underlining "bar" in "Foo bar".
Using SampleApp
's ViewController
, and enabling USE_STYLE_ATTRIBUTES
, I would expect the following style attributes to work:
@{
MarkdownStyleEmphasisSingle: @{
NSUnderlineStyleAttributeName: @1
}
}
However, this is insufficient to underline "bar" in the example. In order for the single emphasis style to take effect, one needs to add a MarkdownStyleEmphasisDouble
definition, which has a significant difference from the base attributes (font, foregroundColor, underline style all seem to do the trick).
Example:
[It's a link, but it won't be (converted) to NSAttributedString.Key.link](https://google.com)
In the function updateAttributedString():
endRange = [scanString rangeOfString:endMarker options:options range:remainingRange];
It doesn't check for an escaped endMarker:
if (hasCharacterRelative(scanString, endRange, -1, escapeCharacter)) { continueScan = YES; //scanEndIndex = endRange.location + endRange.length; scanEndIndex = endRange.location + 1; }
Therefore, it will fail to properly parse:
[\(\)](http://apple.com)
As this snippet shows if there is a styleAttributes
for links the url attribute is ignored.
MarkdownAttributedString/NSAttributedString+Markdown.m
Lines 474 to 479 in 750e8d5
I need to customise the link color and keep them tappable.
I'll send a PR soon.
The function:
static BOOL hasCharacterRelative(NSString *string, NSRange range, NSUInteger offset, unichar character)
takes a NSUInteger offset. Many clients of this call pass -1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.