Browse code

The idea with four backticks was just stupid...

Nat! authored on 19-02-2015 22:52:28
Showing 24 changed files
... ...
@@ -24,8 +24,7 @@ To keep in sync with the archive version, the version nr. has been bumped to
24 24
 
25 25
 Improved the dependencyTable generation, by ignoring syntax errors.
26 26
 
27
-The documentation is now in a somewhat proprietary markdown format, because
28
-I use ```` instead of ```, but it should be harmless. With some hacking effort
27
+The documentation is now in markdown format. With some hacking effort
29 28
 the builtin webserver can now show the "Results" much nicer.
30 29
 
31 30
 Stole a CSS to make it look more nicey, nicey.
... ...
@@ -37,36 +37,36 @@ expression. The expresssion is evaluated and the resulting value is added to
37 37
 the output.
38 38
 
39 39
 #### Example 1
40
-````
40
+```
41 41
 name={{ name }}
42
-````
42
+```
43 43
 
44 44
 Expressions can be postprocessed with pipes.
45 45
 
46 46
 #### Example 2
47
-````
47
+```
48 48
 when={{ name | lowercaseString }}
49
-````
49
+```
50 50
 
51 51
 Pipes can also contain ObjC calls with parameters, where the left side of the
52 52
 pipe is substituted for self in the right side.
53 53
 
54 54
 
55 55
 #### Example 3
56
-````
56
+```
57 57
 when={{ name | [self stringByReplacingOccurrencesOfString:@" 1848" withString:@""] }}
58
-````
58
+```
59 59
 
60 60
 ## Key Value Coding
61 61
 
62 62
 As that can become unwieldy, you can use a ``define`` to make common calls nicer to read.
63 63
 
64 64
 #### Example 4
65
-````
65
+```
66 66
 {% define no1848 = [self stringByReplacingOccurrencesOfString:@" 1848"
67 67
                                                    withString:@""] %}
68 68
 when={{ name | no1848 }}
69
-````
69
+```
70 70
 
71 71
 
72 72
 You have full key value coding available. With ``for`` loops can you iterate over
... ...
@@ -75,14 +75,14 @@ collections just like **NSEnumerator** (it is in an **NSEnumerator** internally
75 75
 
76 76
 
77 77
 #### Example 5
78
-````
78
+```
79 79
 The bag contains {{ bag.@count }} entries
80 80
 {% if defined( "bag") %}
81 81
 {% for item in [bag allKeys] %}
82 82
    {{ [bag objectForKey:item] }}
83 83
 {% endfor %}
84 84
 {% endif %}
85
-````
85
+```
86 86
 
87 87
 But with dots separated by spaces you can do even more complicated KVC.
88 88
 
... ...
@@ -96,7 +96,7 @@ be written equivalently as
96 96
 
97 97
 
98 98
 #### Example 6
99
-````
99
+```
100 100
 The bag contains {{ bag.@count }} entries
101 101
 {%
102 102
    if defined( "bag")
... ...
@@ -105,7 +105,7 @@ The bag contains {{ bag.@count }} entries
105 105
       endfor
106 106
    endif
107 107
 %}
108
-````
108
+```
109 109
 
110 110
 Not all commands may appear in multiline commands. You can use
111 111
 
... ...
@@ -12,7 +12,7 @@ want to produce shell scripts using **MulleScion**.
12 12
 Lets run a simple example.
13 13
 
14 14
 #### Example
15
-````
15
+```
16 16
 {%
17 17
    file  = [NSFileHandle fileHandleForReadingAtPath:@"/etc/hostconfig"];
18 18
    data  = [file readDataToEndOfFile];
... ...
@@ -38,4 +38,4 @@ hostconfig:
38 38
 {% for key in [[dict allKeys] sortedArrayUsingSelector:@selector( compare:)] %}
39 39
    {{ key }} = {{ dict[ key] }}
40 40
 {% endfor %}
41
-````
41
+```
... ...
@@ -1,5 +1,5 @@
1 1
 #### Example 1
2
-````
2
+```
3 3
 {%
4 4
    [NSDateFormatter setDefaultFormatterBehavior:1000]
5 5
    [NSNumberFormatter setDefaultFormatterBehavior:1000]
... ...
@@ -7,11 +7,11 @@
7 7
    MulleScionDateFormat = @"--%y/%m/%d--"
8 8
 %}
9 9
 {{ [NSDate date] }}
10
-````
10
+```
11 11
 
12 12
 #### Example 2
13
-````
13
+```
14 14
 {% MulleScionNumberFormat = @"#0.00" %}
15 15
 {{ [NSNumber numberWithDouble:0.1234] }}
16
-````
16
+```
17 17
 
... ...
@@ -3,8 +3,8 @@ the template and you need **NSRange**: there is a **NSMakeRange** function
3 3
 built in.
4 4
 
5 5
 #### Example
6
-````
6
+```
7 7
 {{ [@"VfL Bochum 1848" substringWithRange:NSMakeRange( 4, 6)] }}
8 8
 {# stupid pet tricks, achived by a category on NSValue #}
9 9
 {{ [@"VfL Bochum 1848" rangeOfString:@"18"].location }}
10
-````
10
+```
... ...
@@ -1,18 +1,18 @@
1 1
 Within **MulleScion** you can use regular Objective-C method call syntax.
2 2
 
3 3
 #### Example 1
4
-````
4
+```
5 5
 {{ [NSDate date] }}
6
-````
6
+```
7 7
 
8 8
 But you can also use '[' ']' in the "modern" way, to access dictonaries and
9 9
 array. So if you don't want to write `objectAtIndex:` or `objectForKey:` you
10 10
 can also use:
11 11
 
12 12
 #### Example 2
13
-````
13
+```
14 14
 {{ bag[ "a" ] }}  # where bag is a NSDictionary
15 15
 {{ list[ 1] }}    # where list is a NSArray
16
-````
16
+```
17 17
 
18 18
 <cite>See [properties.plist](properties.plist) for the values used in this example.</cite>
... ...
@@ -3,16 +3,16 @@ isn't referenced anywhere else, nothing special happens and the contents are
3 3
 simply output.
4 4
 
5 5
 #### Example 1
6
-````
6
+```
7 7
 {% block myblock %}Like so my block{% endblock %}
8
-````
8
+```
9 9
 
10 10
 A `block` can share it's identifier, but this is more often than not a mistake :)
11 11
 
12 12
 #### Example 2
13
-````
13
+```
14 14
 {% block myblock %}Like this is so my other block{% endblock %}
15
-````
15
+```
16 16
 
17 17
 On it's own a `block`s contents are rendered as given into the template output.
18 18
 Only in conjunction with [`extends`](extends.scion?wrapper=_wrapper.scion) does
... ...
@@ -3,14 +3,14 @@ substituted into the expression. Subsitution is only within template brackets.
3 3
 Substitution is done during the compile stage of the template.
4 4
 
5 5
 #### Example 1
6
-````
6
+```
7 7
 {% define PC = [self stringByReplacingOccurrencesOfString:@"S04"
8 8
                                                withString:@"***"] %}
9 9
 
10 10
 {% filter PC %}
11 11
    VfL vs. S04 = 4:0
12 12
 {% endfilter %}
13
-````
13
+```
14 14
 
15 15
 `define` is a command, that can not appear in multi-line statements.
16 16
 `define` is something that is not in TWIG.
... ...
@@ -2,15 +2,15 @@ Dots between identifiers without spaces are your usual key value coding
2 2
 keypath. 
3 3
 
4 4
 #### Example 1
5
-````
5
+```
6 6
 {{ bag.a }}
7
-````
7
+```
8 8
 
9 9
 If you leave spaces between the dots, the functionality expands, so
10 10
 that you can interpose arbitrary objects
11 11
 
12 12
 #### Example 2
13
-````
13
+```
14 14
 {# Then you can also interpose methods if you want  #}
15 15
 {%
16 16
    z = [NSDictionary dictionaryWithObject:@"VfL Bochum 1848" forKey:@"c"]
... ...
@@ -19,6 +19,6 @@ that you can interpose arbitrary objects
19 19
    {{ x . a . b .c }}
20 20
    {{ x . a . [self objectForKey:@"b"] . c }}
21 21
 %}
22
-````
22
+```
23 23
 
24 24
 <cite>See [properties.plist](properties.plist) for the values used in this example.</cite>
... ...
@@ -14,18 +14,18 @@ General rule: After an ``extends``, there should be only other ``extends``and
14 14
 ``block`` definitons.
15 15
 
16 16
 #### Example 1
17
-````
17
+```
18 18
 {% extends "__demo.scion" %}
19 19
 {% block demo %}<blockquote>We override the contents</blockquote>{% endblock %}
20
-````
20
+```
21 21
 
22 22
 The example shows how anything besides `block` and `extends` statements get
23 23
 ignored. Because of the `extends` in Example 1, the example won't even show. And
24 24
 the text you are reading is ignored by MulleScion as well.
25 25
 
26 26
 #### Example 2
27
-````
27
+```
28 28
 You won't see me.
29
-````
29
+```
30 30
 
31 31
 `extends` can't be used in multi-line statements.
... ...
@@ -3,7 +3,7 @@
3 3
 to turn of filtering.
4 4
 
5 5
 #### Example 1
6
-````
6
+```
7 7
 {% filter lowercaseString|capitalizedString %}
8 8
 This is filtered and pushed through lowercaseString and then capitalizedString.
9 9
 {% filter uppercaseString %}
... ...
@@ -12,35 +12,35 @@ nesting.
12 12
    {% endfilter %}
13 13
 back to original.
14 14
 {% endfilter %}
15
-````
15
+```
16 16
 
17 17
 #### Example 2
18
-````
18
+```
19 19
 {% filter lowercaseString| [[self componentsSeparatedByString:@"/"] componentsJoinedByString:@"-"] %}
20 20
 THIS/IS/POSSIBLE
21 21
 {% endfilter %}
22
-````
22
+```
23 23
 
24 24
 There is also function `filter()` available. This will push a string argument
25 25
 through the currently active filter only (but not through the chain). If
26 26
 the filter ist stateful (like Hoedown), this may not produce an immediate result.
27 27
 
28 28
 #### Example 3
29
-````
29
+```
30 30
 {% filter uppercaseString %}
31 31
 {% lower=@"lower"
32 32
    upper = filter( lower) %}
33 33
 {% endfilter %}
34 34
 {{ lower }} becomes {{ upper }}
35
-````
35
+```
36 36
 
37 37
 You can give filter an array of keywords `output` and/or `plaintext` to tell it
38 38
 what to filter. The default is both.
39 39
 
40 40
 #### Example 4
41
-````
41
+```
42 42
 {% filter uppercaseString, (output) %}
43 43
 This won't get filtered, but {{ "this" }}. Convenient to wrap around HTML
44 44
 code for example and setting the filter to htmlEscapedString.
45 45
 {% endfilter %}
46
-````
46
+```
... ...
@@ -1,11 +1,11 @@
1 1
 This is an example of a ``for`` loop over an array.
2 2
 
3 3
 #### Example 1
4
-````
4
+```
5 5
 {% for item in @( "a", @"b", @"c") %}
6 6
 <b>{{ item }}</b>
7 7
 {% endfor %}
8
-````
8
+```
9 9
 
10 10
 You can write out the data in a more formatted kind of way, thanks to some
11 11
 built-in special variables that are used during a ``for`` loop.
... ...
@@ -39,15 +39,15 @@ Name                       | Description
39 39
 `MulleScionForCloser`      | The value for item#.footer for the last loop iteration
40 40
 
41 41
 #### Example 2
42
-````
42
+```
43 43
 {% MulleScionForOpener    = "[" %}
44 44
 {% MulleScionForSeparator = "/" %}
45 45
 {% MulleScionForCloser    = "]" %}
46 46
 {% for item in @( 1, 2, 3 ) %}{{ item#.header }}{{ item }}{{ item#.footer }}{% endfor %}
47
-````
47
+```
48 48
 
49 49
 #### Example 3
50
-````
50
+```
51 51
 {%
52 52
    MulleScionForOpener    = "OPEN"
53 53
    MulleScionForSeparator = "SEPA"
... ...
@@ -57,7 +57,7 @@ Name                       | Description
57 57
 {% for item in @( @"a", @"b", @"c") %}
58 58
 i={{ item#.i }}, header={{ item#.header }}, footer={{ item#.footer }}, division={{ item#.division }}, modulo={{ item#.modulo }}, isEven={{ item#.isEven }}, isFirst={{ item#.isFirst }}, isLast={{ item#.isLast }}, evenOdd={{ item#.evenOdd }}
59 59
 {% endfor %}
60
-````
60
+```
61 61
 
62 62
 There are a few other variables, that can be helpful dealing with row coloring
63 63
 for example:
... ...
@@ -72,7 +72,7 @@ Name                             | Description
72 72
 
73 73
 
74 74
 #### Example 4
75
-````
75
+```
76 76
 {%
77 77
    MulleScionForSubdivisionLength = 2
78 78
    MulleScionForSubdivisionOpener = "-["
... ...
@@ -86,7 +86,7 @@ Name                             | Description
86 86
       {{ item#.header }}{{ item }}{{ item#.footer }}
87 87
    endfor
88 88
 %}
89
-````
89
+```
90 90
 
91 91
 If the array over which to iterate in the `for` loop is empty, you can detect
92 92
 this by using `elsefor`. Here is a more complex example, that lists the
... ...
@@ -94,7 +94,7 @@ available NSTimeZones, also using `elsefor` in case none are available.
94 94
 
95 95
 
96 96
 #### Example 5
97
-````
97
+```
98 98
 {% MulleScionEven = "#DDDDDD"
99 99
    MulleScionOdd  = "#FFFFFF"
100 100
  %}
... ...
@@ -110,6 +110,6 @@ available NSTimeZones, also using `elsefor` in case none are available.
110 110
 {% elsefor %}
111 111
 Sorry, no timezone info available.
112 112
 {% endfor %}
113
-````
113
+```
114 114
 
115 115
 
... ...
@@ -1,37 +1,37 @@
1 1
 ``if`` ``then`` ``else`` are you standard conditionals.
2 2
 
3 3
 #### Example 1
4
-````
4
+```
5 5
 {% if YES %}
6 6
 t
7 7
 {% else %}
8 8
 f
9 9
 {% endif %}
10
-````
10
+```
11 11
 The boolean operations are limited to ``not`` ``and`` ``or``. Read from left to
12 12
 right as there is no precedence. If you need precedence use parentheses.
13 13
 
14 14
 #### Example 2
15
-````
15
+```
16 16
 {% if not YES and YES or NO %}
17 17
 t
18 18
 {% else %}
19 19
 f
20 20
 {% endif %}
21
-````
21
+```
22 22
 
23 23
 #### Example 3
24
-````
24
+```
25 25
 {% if not( YES and (YES or NO)) %}
26 26
 t
27 27
 {% else %}
28 28
 f
29 29
 {% endif %}
30
-````
30
+```
31 31
 
32 32
 If you need `if` `then` `else` within an expression use the `?` `:` conditional.
33 33
 
34 34
 #### Example 4
35
-````
35
+```
36 36
 {{ YES ? "yes" : "no" }}/{{ NO ? "yes" : "no" }}
37
-````
37
+```
... ...
@@ -8,15 +8,15 @@ a file but doesn't parse it.
8 8
 Here we include the file **set.scion** and have the comments parsed away
9 9
 
10 10
 #### Example 1
11
-````
11
+```
12 12
 {% includes "__demo.scion" %}
13
-````
13
+```
14 14
 
15 15
 and the file included verbatim
16 16
 
17 17
 #### Example 2
18
-````
18
+```
19 19
 {% includes verbatim "__demo.scion" %}
20
-````
20
+```
21 21
 
22 22
 ``includes`` can't be used in multi-line statements.
... ...
@@ -5,8 +5,8 @@ stderr.
5 5
 So you will only see the output of log in your logfiles or stderr.
6 6
 
7 7
 #### Example
8
-````
8
+```
9 9
 {% log @"you won't see this" %}
10
-````
10
+```
11 11
 
12 12
 
... ...
@@ -7,7 +7,7 @@ again from TWIG in that there is no *imports* facility.
7 7
 
8 8
 
9 9
 #### Example 1
10
-````
10
+```
11 11
 {# a macro by itself, produces no output #}
12 12
 {% macro table( border, cellpadding, list) %}
13 13
 <table border="{{border}}" cellpadding="{{ cellpadding }}">
... ...
@@ -16,21 +16,21 @@ again from TWIG in that there is no *imports* facility.
16 16
  {% endfor %}
17 17
 </table>
18 18
 {% endmacro %}
19
-````
19
+```
20 20
 
21 21
 #### Example 2
22
-````
22
+```
23 23
 This value {{ list }} is from the properties file
24
-````
24
+```
25 25
 
26 26
 #### Example 3
27
-````
27
+```
28 28
 {{ table( 1, 10, @( @"VfL", @"Bochum", @"1848")) }}
29
-````
29
+```
30 30
 
31 31
 #### Example 4
32
-````
32
+```
33 33
 And {{ list }} should now be as before the macro expansion
34
-````
34
+```
35 35
 
36 36
 Can macro/endmacro be used in multi-line statements ? Preferably not.
... ...
@@ -3,9 +3,9 @@ identifier matches, then the bundle will get loaded. The idea is to be able to
3 3
 load available functionality to a standalone script.
4 4
 
5 5
 #### Example
6
-````
6
+```
7 7
 {% requires "com.apple.Foundation" %}
8
-````
8
+```
9 9
 
10 10
 requires searches in the following places:
11 11
 
... ...
@@ -1,16 +1,16 @@
1 1
 self in a pipe or a dot expression is the result of the incoming string
2 2
 
3 3
 #### Example 1
4
-````
4
+```
5 5
 {{ @"xxx" | [self uppercaseString] }}
6
-````
6
+```
7 7
 
8 8
 otherwise it is a synonym for the datasource
9 9
 
10 10
 #### Example 2
11
-````
11
+```
12 12
 {{ [self valueForKey:@"name"] }} == {{ name }} == {{ self.name }}
13
-````
13
+```
14 14
 
15 15
 
16 16
 
... ...
@@ -2,11 +2,11 @@
2 2
 if you want.
3 3
 
4 4
 #### Example
5
-````
5
+```
6 6
 {% set foo = [NSMutableDictionary dictionary];
7 7
    foo[ @"key"] = @"a value"
8 8
 %}
9 9
 
10 10
 {{ foo[ @"key"] }}
11
-````
11
+```
12 12
 
... ...
@@ -1,5 +1,5 @@
1 1
 #### Example
2
-````
2
+```
3 3
 [{% verbatim %}[
4 4
 This just grabs all data between "{% verbatim %}" and "{% endverbatim %}" and
5 5
 doesn't interpret it.
... ...
@@ -8,6 +8,6 @@ doesn't interpret it.
8 8
 
9 9
 ]{% endverbatim %}]
10 10
 Back to business: {{ name }}
11
-````
11
+```
12 12
 
13 13
 Can verbatim/endverbatim be used in multi-line statements ? Preferably not.
... ...
@@ -1,5 +1,5 @@
1 1
 #### Example
2
-````
2
+```
3 3
 {# render an old skool HTML table with while #}
4 4
 <table>
5 5
    <tr><th>TimeZone</th></tr>
... ...
@@ -8,4 +8,4 @@
8 8
    <tr><td>{{ item }}</td></tr>
9 9
 {% endwhile %}
10 10
 </table>
11
-````
11
+```
... ...
@@ -3,6 +3,6 @@ string. The right side can be any method callable on NSString. But it can't have
3 3
 any parameters.
4 4
 
5 5
 #### Example 1
6
-````
6
+```
7 7
 {{ @"A STRING" | lowercaseString | uppercaseString }}
8
-````
8
+```
... ...
@@ -101,7 +101,7 @@
101 101
    NSMutableString   *buf;
102 102
    NSArray      *components;
103 103
    
104
-   components = [self componentsSeparatedByString:@"````"];  // 4 * '`'
104
+   components = [self componentsSeparatedByString:@"```"];  // 3 * '`'
105 105
    n = [components count];
106 106
    if( n <= 1)
107 107
       return( [self hoedownedString]);
... ...
@@ -44,7 +44,7 @@
44 44
    NSScanner         *scanner;
45 45
    
46 46
    // grab all stuff until # Example$
47
-   // throw it away, keep the header snarf up code until ```` has been
47
+   // throw it away, keep the header snarf up code until ``` has been
48 48
    // encountered a second time
49 49
    
50 50
    buf     = [NSMutableString string];
... ...
@@ -63,26 +63,26 @@
63 63
          s = [s substringFromIndex:range.location + 1];
64 64
       [buf appendString:s];
65 65
       
66
-      // scan up to first ```` and copy (including ````)
67
-      if( ! [scanner scanUpToString:@"````"
66
+      // scan up to first ``` and copy (including ```)
67
+      if( ! [scanner scanUpToString:@"```"
68 68
                          intoString:&s])
69 69
          break;
70 70
       [buf appendString:s];
71
-      [scanner scanString:@"````"
71
+      [scanner scanString:@"```"
72 72
                intoString:NULL];
73
-      [buf appendString:@"````"];
73
+      [buf appendString:@"```"];
74 74
       
75
-      // scan up to second ```` and copy (including ````)
75
+      // scan up to second ``` and copy (including ```)
76 76
       // weirdly code, because the NSScanner API is weird...
77
-      if( ! [scanner scanUpToString:@"````"
77
+      if( ! [scanner scanUpToString:@"```"
78 78
                          intoString:&s])
79 79
          s = @"";
80
-      if( ! [scanner scanString:@"````"
80
+      if( ! [scanner scanString:@"```"
81 81
                      intoString:NULL])
82 82
          break;
83 83
       
84 84
       [buf appendString:s];
85
-      [buf appendString:@"````\n"];
85
+      [buf appendString:@"```\n"];
86 86
    }
87 87
    
88 88
    return( buf);