diff --git a/md4tj_parse.el b/md4tj_parse.el
index 94f431a..87c2e1f 100644
--- a/md4tj_parse.el
+++ b/md4tj_parse.el
@@ -91,6 +91,19 @@
(md4tj-begin-tag "p" (list (list "id" "lastupdated")))
"Last updated: " (current-time-string)
(md4tj-end-tag "p")))
+ ((and (string-match "^$$.*$$" line) (eq (nth 1 state) 'normal)) ;; LaTeX formula
+ (shell-command (concat "./pnglatex"
+ " -d 300"
+ " -f "
+ "\""
+ (string-replace "$$" "" line)
+ "\""
+ " -o "
+ "./teximg/"
+ (md5 (string-replace "$$" "" line)) ".png"))
+ (md4tj-begin-tag "img" (list (list "class" "teximg") ;; give teximgs their own class
+ (list "src" (concat "./teximg/" (md5 (string-replace "$$" "" line)) ".png"))
+ (list "alt" (string-replace "$$" "" line)))))
;; If this is some other signal, ignore
((string-match "^@@" line) "")
;; Otherwise, process as normal
@@ -146,7 +159,9 @@
(t 'normal))))
(defun md4tj-begin ()
- "Insert beginning code for all html."
+ "Insert beginning code for all html, initialize."
+ (shell-command "mkdir -p ./teximg") ;; Ensure ./teximg folder exists
+ (shell-command "rm ./teximg/*") ;; Clear everything from the folder
(concat "\n"
(md4tj-begin-tag "html"
(list (list "lang"
diff --git a/test_css.css b/test_css.css
index bcbac00..8c42a07 100644
--- a/test_css.css
+++ b/test_css.css
@@ -9,3 +9,11 @@ video {
outline: dashed 1px black;
text-align: center;
}
+
+.teximg {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ width: 5%;
+ height: auto;
+}
diff --git a/test_file.html b/test_file.html
index b40edf2..825aa30 100644
--- a/test_file.html
+++ b/test_file.html
@@ -70,6 +70,7 @@ int main() {
Dungeon Crawl Stone Soup - My favorite FOSS roguelike (Yes, I know the greatest roguelike of all time is NetHack, I don't care).
-Last updated: Wed Jan 4 13:40:47 2023
+ +Last updated: Wed Jan 4 14:56:23 2023