Permalink
Browse files

minor change to beautifier - ignore colons inside strings

The new colon-based alignment was also aligning colons in strings, as follows:

   (&img style:(+ "height:60px; width:60px; "
                   "float:right; background-color:#FFF; "
                 "padding:0.5px; margin:5px; "
           "border-radius: 16.67%; "
              "box-shadow: 0px 0px 1px #AAA;")
           src:(app artworkUrl60:))

This didn't seem good to me, so now colons inside strings are ignored for the purposes of alignment.

   (&img style:(+ "height:60px; width:60px; "
                  "float:right; background-color:#FFF; "
                  "padding:0.5px; margin:5px; "
                  "border-radius: 16.67%; "
                  "box-shadow: 0px 0px 1px #AAA;")
           src:(app artworkUrl60:))
  • Loading branch information...
1 parent cf5c124 commit 7a99a850717ffc0979a4e033b116a03e925e8f59 @timburks committed Mar 12, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 nu/beautify.nu
View
@@ -20,6 +20,7 @@
(global SPACE ' ')
(global COLON ':')
(global TAB '\x09')
+(global DOUBLEQUOTE '"')
(class NSString
;; Make a string consisting of the specified number of spaces.
@@ -135,6 +136,7 @@
;; but if we have a label, we will try to align the colon
(set k j)
(while (and (< k (line length))
+ (ne (line characterAtIndex:k) DOUBLEQUOTE) ;; ignore colons inside strings
(ne (line characterAtIndex:k) SPACE)
(ne (line characterAtIndex:k) COLON))
(set k (+ k 1)))

0 comments on commit 7a99a85

Please sign in to comment.