thabz / markdowntextview Goto Github PK
View Code? Open in Web Editor NEWDisplay Markdown in a UITextView without converting to HTML first
License: Other
Display Markdown in a UITextView without converting to HTML first
License: Other
See the description of an an issue in Branches that doesn't render correctly.
Made it work in Places, but didn't need the code after switching to libxml2. Here's the functioning code, that handles both decimal and hexadecimal escapes:
static private var HTMLNumericEntitiesRegExp: NSRegularExpression = {
let pattern = "&#(x?)(.+?);";
if let regexp = try? NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions()) {
return regexp
} else {
fatalError("Bad regexp")
}
}()
and
private func handleHTMLNumericEscapes(line: NSString) -> NSString {
let mutable = line.mutableCopy() as! NSMutableString
let range = NSMakeRange(0, mutable.length)
let matches = WebPageMetaBackend.HTMLNumericEntitiesRegExp.matchesInString(mutable as String, options: NSMatchingOptions(), range: range).reverse()
for match in matches {
let range = match.range // Whole matched range encompasses "å"
let isHex = !(mutable as NSString).substringWithRange(match.rangeAtIndex(1)).isEmpty
let escape = (mutable as NSString).substringWithRange(match.rangeAtIndex(2))
if let replacementUnicodeValue = Int(escape, radix: isHex ? 16 : 10) {
let replacement = String(Character(UnicodeScalar(replacementUnicodeValue)))
mutable.replaceCharactersInRange(range, withString: replacement)
}
}
return mutable
}
A code block on GitHub can have a little language prefix ````javascript` which we should ignore.
- (void)function:(NSString*)string
There shouldn't be a visible objc
above.
Does images work then?
Bitbucket Markdown supports a few macros for smilies.
https://bitbucket.org/DACOFFEY/wiki/wiki/BITBUCKET/EMOJI/Emoji
This thabz/Peopls#201 should be a link.
GitHub and GitLab has this, not sure about Bitbucket.
_ __ * ** /
marks bold and italic, but are GitHub and Bitbucket is agreement on what's used for what?
Backslash escapes should function non-bold (vs. bold) and non-italic (vs. italic).
GitHub supports multiple levels of bullet lists. Checked and numbered lists too.
See http://stackoverflow.com/a/30845969
Do we do the right thing? Make some tests to ensure this.
This is the kosher way. Maybe support Carthage.
The issues created by Crashlytics has that kind of headlines.
MarkdownTextAttachment should use a basic NSCache. See the closed issue 201 in Peopls. The comments contain some tall images, because of cell resuse the cells and images flickers when scrolling up and down.
A simple cache could fix this.
It's free for open source projects.
Example:
Argo uses Carthage for dependency management. Running bin/setup
will
install Carthage if it isn't already installed, then download the
dependencies.
These guys
<!-- comment -->
should be stripped from non-codeblocks. Like this:
But should be visible in inline code blocks like <!-- comment -->
...
This line
And this line
Gets smashes together.
It looks like “This lineAnd this lineGets smashes together.”
The last one or two lines can be missing. Rotating the device between landscape and portrait fixes the problem. So the extra relayout fixes things.
This is apparently not an issue when there are images in the text, so that extra asynchronous relayout the images cause fixes things. Maybe use the same thing on all text views – embedded images or not.
This is probably an issue with comments too.
Both Bitbucket and GitHub supports links to issues by just writing #1
which is rendered as #1.
The MarkdownTextStorage constructor should take an additional parameter: repository which is independent of the Repository class in Branches. It should contains service
, username
and repository
.
GitHub Markdown supports a few macros for smilies.
All supported macros, including non-Unicode, are at https://github.com/arvida/emoji-cheat-sheet.com
And here's some non-Unicode emojis supported on GitHub: https://github.com/gregburek/github-emoji-expansion-in-osx
GitHub doesn't does render strikethrough marked by double double tildes.
Support special GitLab Markdown extensions
Marks language inside code block like this:
#!swift
func inc(x: Int) -> Int {
return x + 1
}
We should ignore the #!lang
part but check the documentation first.
Lines starting with > is part of a quote section. Indent and lighten text. Can we set an opacity on the whole paragraph, so that links also gets lighter?
Why is the an extraneous ) at the end of the link: Static Overflow ...?
This'll make it look like on GitHub which is nicer than what we have now.
Just discovered non-capturing parentheses (?:...)
and look-behind assertion (?<= ... )
. Utilize those.
See descriptions for Foundation's NSRegularExpression and Ruby's RegExp.
See issue 117 in lunr.js for examples. Many issues in that project marks code sections that way.
Unicode emojis are > 32 bit and thus might cause troubles when we mix Swift String
and NSString
.
With a description.
What is going on here?
Examples on how GitHub renders them:
We should trim all double whitespaces as would automatically happen on the normal HTML output from Markdown.
Take the “Manually” description from https://github.com/onevcat/Kingfisher/blob/master/README.md and add it to our own README.md
<http://www.kalliope.org/>
renders as http://www.kalliope.org/[Link](<http://www.kalliope.org/>)
renders as Link with link part only http://www.kalliope.org/
GitHub and Bitbucket are in agreement on this.
We should handle bullet lists like:
We should do the html comment escaping before splitting into lines but after splitting by code-blocks.
If there are multiple rows with different images, they don't get shown. I think they basically don't make their containing tableviewcell resize or reload or re-something.
Above
Below
This got exposed when viewing an issue created by Crashlytics.
At least in the GibHub parser variant.
The second link in the following renders wrong. GitLab includes an issue tracker.
There's an API which looks more like GitHub than Bitbucket, so that's nice.
There's already an iOS app available, GitLab Control by Valerio Mazzeo, that's free with an in-app purchase for a pro license.
A commit SHA 3398d94 becomes a link in both GitHub and Bitbucket. Hex numbers abc112d that don't match a commit SHA doesn't become links on GitHub, which is harder to fix. They do become (dead) links to Bitbucket though.
Emoji present in Github but not in Unicode:
And some regional flags that might work:
• —
renders as • — in GitHub.
Bitbucket doesn't support those and renders them verbatim.
List of all List of XML and HTML character entity references on Wikipedia.
Implementation on Stackoverflow.
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.