Browse Source

Try to make sense of formatting tags

Fred Gilham 4 days ago
parent
commit
29363a6f81
1 changed files with 16 additions and 7 deletions
  1. 16 7
      bible-mode.el

+ 16 - 7
bible-mode.el

@@ -1051,9 +1051,8 @@ buffer)."
 
 (defun bm--insert-domnode-recursive (node &optional iproperties notitle)
   "Recursively parses a domnode from `libxml-parse-html-region's usage on text
-produced by `bm--exec-diatheke'. Outputs text to active buffer 
-with properties.
-In processing subnodes, each case will prepend a space if it needs it."
+produced by `bm--exec-diatheke'. INSERTS text into active buffer with properties.
+XXX In processing subnodes, each case will prepend a space if it needs it."
 
   (when (and bm-red-letter-enabled (equal (dom-attr node 'who) "Jesus"))
     ;; For red-letter display.
@@ -1073,8 +1072,21 @@ In processing subnodes, each case will prepend a space if it needs it."
 	   (when (plist-get iproperties 'jesus)
 	     (add-face-text-property 0 (length subnode) '(:foreground "red") nil subnode))
 	   (insert subnode))
+;;;;	  Maybe process these at some point? Include footnotes etc.
 ;;;	  ((eq (dom-tag subnode) 'node) nil)
 ;;;	  ((eq (dom-tag subnode) 'lb) nil)
+	  ;; These tags appear in ESV modules (and maybe others?)
+	  ((eq (dom-tag subnode) 'l)
+	   (let ((attributes (dom-attributes subnode)))
+	     (cond ((equal (cdr (assoc 'type attributes)) "x-br")
+		    (bm-new-line))
+		   ((equal (cdr (assoc 'type attributes)) "x-indent")
+		    (insert "\t"))
+		   ((assoc 'level attributes)
+		    (let ((indent (- (string-to-number (cdr (assoc 'level attributes))) 1)))
+		      (when (> indent 0)	
+			(bm-new-line)
+			(dotimes (i indent) (insert "\t"))))))))
 	  ((eq (dom-tag subnode) 'title)
 	   (when (not notitle) (setq bm-chapter-title subnode) (bm-new-line)))
 	  ((eq (dom-tag subnode) 'body) (bm--insert-domnode-recursive subnode iproperties notitle))
@@ -1087,10 +1099,7 @@ In processing subnodes, each case will prepend a space if it needs it."
 	  ((eq (dom-tag subnode) 'w)
 	   (insert " ")
 	   (bm--process-word subnode iproperties))
-	  ((and (eq (dom-tag subnode) 'l) (equal (cdr (assoc 'type (dom-attributes subnode))) "x-br"))
-	   (bm-new-line))
-	  ((and (eq (dom-tag subnode) 'l) (equal (cdr (assoc 'type (dom-attributes subnode))) "x-indent"))
-	   (insert "	"))
+	  ;; Some modules use this for line breaks and such.
 	  ((and (eq (dom-tag subnode) 'milestone) (equal (cdr (assoc 'type (dom-attributes subnode))) "line"))
 	   (bm-new-line))
 	  ((or (eq (dom-tag subnode) 'transchange)