md4tj/md4tj-util.el

37 lines
1002 B
EmacsLisp

;;; md4tj-util --- Summary
;; A collection of useful utilities that can be used by anything
;; relating to md4tj
;;; Commentary:
;;; Code:
(require 'cl-lib)
(defun md4tj-util-getline ()
"Get current line from loaded buffer."
(buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(defun md4tj-util-clean-multiline (line)
"Clean LINE of markdown syntax for ul's, ol's and code's."
(replace-regexp-in-string
"^```" ""
(replace-regexp-in-string
"^[0-9]+\\. " ""
(replace-regexp-in-string "^- " "" line))))
(defun md4tj-util-escape-chars (line)
"Escape characters in LINE that would be misinterpreted by the browser."
(string-replace
"<" "&lt;"
(string-replace ">" "&gt;" line)))
(defun md4tj-util-zip (ls)
"Turn list of lists LS into list of tuples."
(cl-labels ((zip-help (ll) (if (not (car ll)) nil (cons (cl-map 'listp #'car ll) (zip-help (cl-map 'listp 'cdr ll))))))
(zip-help ls)))
(provide 'md4tj-util)
;;; md4tj-util.el ends here