Skip to content

Instantly share code, notes, and snippets.

@guweigang
Created June 26, 2013 15:09
Show Gist options
  • Save guweigang/5868227 to your computer and use it in GitHub Desktop.
Save guweigang/5868227 to your computer and use it in GitHub Desktop.
(define-macro (doc func-name)
(let ((func-name (string func-name)))
(set 'f (read-file {/e:/newlisp/newlisp_manual.html}))
(set 'r (regex (string "<a name=\"" func-name "\"></a>") f))
(set 'n0 (r 1))
(set 'n1 ((regex "<a name=" f 0 (+ n0 (r 2))) 1))
(set 'html-text (slice f n0 (- n1 n0)))
(replace "<.*?>" html-text "" 0)
(replace "&lt;" html-text "<")
(replace "&gt;" html-text ">")
(replace "&amp;" html-text "&")
(replace "&nbsp;" html-text " ")
(replace "&mdash" html-text "...")
(replace "\n\n+" html-text "\n\n" 1)
(replace "^\n+|\n+$" html-text "" 1)
(println "--------------------------")
(println html-text)
(println "--------------------------")
'end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment