Added support for images and links
This commit is contained in:
		
							parent
							
								
									172973926d
								
							
						
					
					
						commit
						054f37b226
					
				@ -34,15 +34,26 @@ f;;; md4tj_parse --- Summary
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
(defun md4tj-process-line (line)
 | 
					(defun md4tj-process-line (line)
 | 
				
			||||||
  "Process all inline elements of the LINE, return HTML."
 | 
					  "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
 | 
						(replace-regexp-in-string
 | 
				
			||||||
	 "\\*\\(.*\\)\\*"
 | 
						 "\\*\\(.*\\)\\*"
 | 
				
			||||||
	 "<em>\\1</em>"
 | 
						 "<em>\\1</em>"
 | 
				
			||||||
 | 
						 ;; Then strong
 | 
				
			||||||
	 (replace-regexp-in-string
 | 
						 (replace-regexp-in-string
 | 
				
			||||||
	  "\\*\\*\\(.*\\)\\*\\*"
 | 
						  "\\*\\*\\(.*\\)\\*\\*"
 | 
				
			||||||
	  "<strong>\\1</strong>"
 | 
						  "<strong>\\1</strong>"
 | 
				
			||||||
 | 
						  ;; First code
 | 
				
			||||||
	  (replace-regexp-in-string
 | 
						  (replace-regexp-in-string
 | 
				
			||||||
	   "`\\(.*\\)`"
 | 
						   "`\\(.*\\)`"
 | 
				
			||||||
	 "<code>\\1</code>" line))))
 | 
						   "<code>\\1</code>" line))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;; Note: a "block" is the smallest unit of parsing
 | 
					;; Note: a "block" is the smallest unit of parsing
 | 
				
			||||||
;; It is normally a line of the code, but can be
 | 
					;; It is normally a line of the code, but can be
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user