Added support for images and links

This commit is contained in:
j4nk 2022-12-28 15:18:47 -05:00
parent 172973926d
commit 054f37b226
1 changed files with 17 additions and 6 deletions

View File

@ -34,15 +34,26 @@ f;;; md4tj_parse --- Summary
(defun md4tj-process-line (line)
"Process all inline elements of the LINE, return HTML."
;; Finally links
(replace-regexp-in-string
"\\[\\(.*\\)\\](\\(.*\\))"
(concat (md4tj-begin-tag "a" (list '("href" "\\2"))) "\\1" (md4tj-end-tag "a"))
;; Then images
(replace-regexp-in-string
"!\\[\\(.*\\)\\](\\(.*\\))"
(md4tj-begin-tag "img" (list '("src" "\\2") '("alt" "\\1")))
;; Then emphasis
(replace-regexp-in-string
"\\*\\(.*\\)\\*"
"<em>\\1</em>"
;; Then strong
(replace-regexp-in-string
"\\*\\*\\(.*\\)\\*\\*"
"<strong>\\1</strong>"
;; First code
(replace-regexp-in-string
"`\\(.*\\)`"
"<code>\\1</code>" line))))
"<code>\\1</code>" line))))))
;; Note: a "block" is the smallest unit of parsing
;; It is normally a line of the code, but can be