I found no way of storing background colors for a template. How can i change the background of my existing cards?

From SuperMemopedia
Jump to navigation Jump to search

You may use the following lisp code to change the background color of your items. Use it at your own risk. If you haven't programmed before i recommend not to use it.

(asdf:operate 'asdf:load-op 'cl-ppcre) (asdf:operate 'asdf:load-op 'cl-fad) (defun insert-grey-background-in-supermemo-file (in-url)  ;; in-url will be overwritten!!! (print in-url) (let ( (copy-file-url "/home/user/tmp/copy.tmp") ) (cl-fad:copy-file in-url copy-file-url :overwrite :true) (with-open-file (in-stream copy-file-url :direction :input)  ;; function parameter in-url will be overwritten!! (with-open-file (out-stream in-url :direction :output :if-exists :supersede) (loop for line-in = (read-line in-stream nil) while line-in do  ;; desired color is d0d0d0 (write-line (cl-ppcre:regex-replace "contentEditable=false" line-in "bgcolor=\"d0d0d0\" contentEditable=false") out-stream))))) (print "done.") ) (defun main () (cl-fad:walk-directory "/home/user/tmp/workbench/test/test/" #'insert-grey-background-in-supermemo-file :test #'(lambda (name) (equal "HTM" (pathname-type name)))))