0
(set nested_tags -"(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>])*>))*>))*>))*>))*>))*>)")
0
(set match (eregex <<-END
0
(?s: <! ( -- .*? -- \s* )+ > ) | # comment
0
- (?s: <? .*? ?> ) | # processing instruction
0
- (?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>]|(?:<[a-z/!$](?:[^<>])*>))*>))*>))*>))*>))*>)/ix; # nested tags
0
+ (?s: <\? .*? \?> ) | # processing instruction
0
((match findAllInString:str) each:
0
- (set whole_tag (m groupAtIndex:
1))
0
+ (set whole_tag (m groupAtIndex:
0))
0
(set sec_start (+ (head r) (head (tail r))))
0
(set tag_start (- sec_start (whole_tag length)))
0
(tokens addObject:(list -"text" (str substringWithRange:(list $pos (- tag_start $pos))))))
0
(tokens addObject:(list -"tag" (m group)))
0
- (set $pos
(+ $pos ((m group) length)))))
0
+ (set $pos
sec_start)))
0
(tokens addObject:(list -"text" (str substringFromIndex:$pos))))
0
(.+?) # $2 = The code block
0
- (?!`)END -"sx") findAllInString:str) each:(do (m)
0
- (str replaceOccurrencesOfString:(m group) withString:-"<code>#{(markdown_EncodeCode ((m groupAtIndex:2) strip))}</code>")))
0
+ (?!`)END -"sx") findAllInString:str) each:
0
+ (str replaceOccurrencesOfString:(m group) withString:-"<code>#{(markdown_EncodeCode ((m groupAtIndex:2) strip))}</code>")))
0
(function markdown_EncodeItalicsAndBolds (str)
0
(function markdown_FormParagraphs (str)
0
(set str (/(\A\n+)|(\n+\z)/ replaceWithString:"" inString:str))
0
(set paragraphs (/\n{2,}/ splitString:str))
0
(set paragraphs (paragraphs map:(do (paragraph)
0
(unless ($g_html_blocks valueForKey:paragraph)
0
(-"\`*_{}[]()>#+-.!" each: (do (c) ($g_escape_table setObject:"!!#{(c hash)}!!" forKey:c)))
0
(set $g_nested_brackets -"(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[\])*\])*\])*\])*\])*\])*")
0
- ;
From running from Markdown.php
0
+ ;
; From running from Markdown.php
0
- ; Standardize line endings
0
+ ;; Standardize line endings
0
(set str (/\r\n/ replaceWithString:"\n" inString:str)) ; Convert DOS to Unix
0
(set str (/\r/ replaceWithString:"\n" inString:str)) ; Convert Mac to Unix
0
- (str appendString:"\n\n") ; Make sure text ends with a couple of newlines
0
- (set str (markdown_Detab str)) ; convert tabs into 4 spaces
0
- (set str (/^[ \t]+$/ replaceWithString:"" inString:str)) ; Strip any lines consisting only of spaces and tabs.
0
- (set str (markdown_HashHTMLBlocks str)) ; Turn block-level HTML blocks into hash entries
0
- (set str (markdown_StripLinkDefinitions str)) ; Strip link definitions, store in hashes.
0
+ ;; Make sure text ends with a couple of newlines
0
+ (str appendString:"\n\n")
0
+ ;; Convert tabs into 4 spaces
0
+ (set str (markdown_Detab str))
0
+ ;; Strip any lines consisting only of spaces and tabs.
0
+ (set str (/^[ \t]+$/ replaceWithString:"" inString:str))
0
+ ;; Turn block-level HTML blocks into hash entries
0
+ (set str (markdown_HashHTMLBlocks str))
0
+ ;; Strip link definitions, store in hashes.
0
+ (set str (markdown_StripLinkDefinitions str))
0
(set str (markdown_RunBlockGamut str))
0
(set str (markdown_UnescapeSpecialChars str))
0
- (unless (eq (str lastCharacter) '\n') (str appendCharacter:'\n'))
0
+ (str appendCharacter:'\n')
0
(class NuMarkdown is NSObject
Comments
No one has commented yet.