public
Description: Markdown processing with Nu. Use with any Nu or Objective-C project. Created by Grayson Hansard.
Homepage: http://programming.nu/posts/2007/10/10/markdown-in-nu
Clone URL: git://github.com/timburks/numarkdown.git
Fixed markdown_Detab, down to 7 test failures.
timburks (author)
Tue Nov 06 16:11:08 -0800 2007
commit  e23b2e29d051b67d2f5252817a036ffc7aa77f82
tree    1e068d1c55dfb6ade4bcd8457f182a5eb4fad8b6
parent  0a7d18e83f9d5c9427b0fad3264378fdc05e0221
...
246
247
248
249
250
 
 
251
252
253
...
509
510
511
512
513
514
515
516
517
518
519
520
521
 
 
 
 
 
522
523
524
...
246
247
248
 
 
249
250
251
252
253
...
509
510
511
 
 
 
 
 
 
 
 
 
 
512
513
514
515
516
517
518
519
0
@@ -246,8 +246,8 @@
0
     \1      # Matching closer
0
     (?!`)END -"sx") findAllInString:str) each:
0
       (do (m)
0
- (set temp (/^[ \t]*/ replaceWithString:"" inString:(m groupAtIndex:2)))
0
- (set temp (/[ \t]*$/ replaceWithString:"" inString:temp))
0
+ (set temp (/^[ \t]*/ replaceWithString:"" inString:(m groupAtIndex:2)))
0
+ (set temp (/[ \t]*$/ replaceWithString:"" inString:temp))
0
           (str replaceOccurrencesOfString:(m group) withString:-"<code>#{(markdown_EncodeCode temp)}</code>")))
0
      str)
0
 
0
@@ -509,16 +509,11 @@
0
      result)
0
 
0
 (function markdown_Detab (str)
0
- ; I need a real detab method here!
0
- ((regex -"\t") replaceWithString:-" " inString:str)
0
- ; ((eregex -"^(\t|[ ]{1,4})" -"m") replaceWithString:-"" inString:str)
0
- ; ((eregex -"(.*?)\t}{$1.(' ' x (4 - length($1) % 4))" -"m") replaceWithString:-"" inString:str)
0
- ; (set str (NSMutableString stringWithString:str))
0
- ; (((eregex -"(.*?)\t" -"m") findAllInString:str) each:(do (m)
0
- ; (set tmp (m groupAtIndex:1))
0
- ; ))
0
- ; (str)
0
- )
0
+ ((/(.*?)\t/ findAllInString:str) each:
0
+ (do (m)
0
+ (str replaceOccurrencesOfString:(m group)
0
+ withString:"#{(m groupAtIndex:1)}#{(NSString spaces:(- 4 (NuMath integerMod:((m groupAtIndex:1) length) by:4)))}")))
0
+ str)
0
 
0
 (function markdown_DoCodeBlocks (str)
0
      (set str (NSMutableString stringWithString:str))

Comments

    No one has commented yet.