Crayon Syntax Highlighter sanity check for Swift Programming Language
I have adapted Crayon Syntax Highlighter to process the Swift Programming Language. This page is where I do sanity check to my addition to the plugin. Nothing to see here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
// Single line Comments /* Multi-line Comments * =================== * Something about the comments */ /* Column ruler * ============ * Ruler to measure how many columns fit into the page. Depends on the site * theme, font type and font size. */ ---------1---------2---------3---------4---------5---------6---------7---------8---------9 // Code sample. More construct will be added on discovery. import Cocoa var someVariable : Double = 45 let someStr = "Blah" var intVariable = 10 someVariable = Double(intVariable) class NamedShape { var numberOfSides: Int = 0 var name: String init(name: String) { self.name = name } func simpleDescription() -> String { return "A shape with \(numberOfSides) sides." } } for index in 1...5 { println("\(index) times 5 is \(index * 5)") } class EquilateralTriangle: NamedShape { var sideLength: Double = 0.0 init(sideLength: Double, name: String) { self.sideLength = sideLength super.init(name: name) numberOfSides = 3 } var perimeter: Double { get { return 3.0 * sideLength * SideLength } set { sideLength = newValue / 3.0 } } override func simpleDescription() -> String { return "An equilateral triagle with sides of length \(sideLength)." } } var triangle = EquilateralTriangle(sideLength: 3.1, name: "a triangle") triangle.perimeter triangle.perimeter = 9.9 triangle.sideLength enum Rank: Int { case Ace = 1 case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten case Jack, Queen, King func simpleDescription() -> String { switch self { case .Ace: return "ace" case .Jack: return "jack" case .Queen: return "queen" case .King: return "king" default: return String(self.toRaw()) } } } protocol ExampleProtocol { var simpleDescription: String { get } mutating func adjust() } extension Int: ExampleProtocol { var simpleDescription: String { return "The number \(self)" } mutating func adjust() { self += 42 } } |