hanhphuc Posted September 24, 2018 Share Posted September 24, 2018 (edited) Hi guys, Quote Since CADTutor transitioned from vBulletin to the new Invision forum software, BBCode (e.g. color tags) are no longer permitted within code blocks and are consequently now displayed as part of the code itself i.e: previous codes with formatted BBcode tags became messy & erroneous! example: erroneous code copied from forum (setq [b] [color="blue"] pl [/color][/b]'((10. 50.)(20. 50.)(30. 50.)(40. 50.)(50. 50.))[color="green"]; point list[/color] ss ([color="blue"] ssget [/color] (append ([color="blue"] [b]vl-list*[/b] [/color] '(0 . [color="purple"] "CIRCLE,TEXT,INSERT" [/color] ) [color="green"]; filter [/color] '(-4 . "<OR")(apply 'append (mapcar ''((x) (list '(-4 . [color="purple"] "=,=,*" [/color] ) (cons 10 x))) [b] pl [/b])) ) '((-4 . "OR>")) ) ) ) ) After BB codes removed which contents within the brackets "[" "]". (setq pl '((10. 50.)(20. 50.)(30. 50.)(40. 50.)(50. 50.)); point list ss ( ssget (append ( vl-list* '(0 . "CIRCLE,TEXT,INSERT" ) ; filter '(-4 . "<OR")(apply 'append (mapcar ''((x) (list '(-4 . "=,=,*" ) (cons 10 x))) pl )) ) '((-4 . "OR>")) ) ) ) ) ATM i could only edit for single post using this simple code merely remove contents within the brackets "[" "]". Hope this help? here's is very basic idea with minimal error handling. you can put addition ideas in cond etc.. (defun c:forum (/ cbdata *error* $ fn fi fo l) ; example: [B] hanhphuc [/B] [Color=blue] defun [/color] ;; command: forum or command: BBCU (abbreviation of BBCode Unformat) - hanhphuc ;; babe see you (defun *error* (msg) (if fi (close fi))) ;;;http://www.theswamp.org/index.php?topic=21764.msg263322#msg263322 (defun cbdata (/ cb html) ;optimized hp (setq cb (vl-catch-all-apply 'vlax-invoke (list ((lambda (doc) (foreach x '(parentwindow clipboarddata) (setq doc (vlax-get doc x)) ) ) (setq html (vlax-create-object "htmlfile")) ) 'getdata "text" ) ) ) (vlax-release-object html) (if (not (vl-catch-all-error-p cb) ) cb ) ) (and (setq fn (strcat (getvar 'tempprefix) "tmp.txt") fi (open fn "w") ) (setq $ (cbdata)) (write-line $ fi) (progn (close fi) (setq fi (open fn "r"))) (while (setq $ (read-char fi)) (setq l (cons $ l))) (progn (if fi (close fi) ) (setq fn (strcat (getvar 'tempprefix) "cadtutor.lsp")) (setq fo (open fn "w")) ) (foreach x (vl-remove-if '(lambda ( x )(or (listp x) (> x 191 ))) (read (strcat "(" (apply 'strcat (mapcar '(lambda (x) (strcat (if (numberp x) (cond ((= 91 x) "(") ((= 93 x) ")") (t (itoa x)) ) x ) " " ) ) (reverse l) ) ) ")" ) ) ) (write-char x fo) ) (progn (if fo (close fo) ) (findfile fn) ) (vl-cmdf "_.SHELL" (strcat "CLIP < " fn )) (alert "[BBCode Tags] removed! Try [Ctrl^C] in the forum!") ) (princ) ) (defun c:BBCU () (c:forum)(princ)) Step 1.save the above lisp, save in your valid path. APPLOAD in ACAD active drawing. 2.copy any 'infected' codes from forum 3.load this "forum.lsp" invoke --> command: BBCU or command: forum 4. simply paste it back to forum active editor (for coders - if you wanna to modify your previous code) for user - paste it to notepad etc.. save your file as '*.lsp' extension. e.g: 'cadtutor.lsp' Any ideas for multiple editing? RegEx ? Here's another alternative removing color tags using Notepad++ by Lee Mac Edited December 16, 2019 by hanhphuc Code updated with clipboard function, lambda new comments 1 1 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.