3 Commits 05180a4d4f ... ed9bdaa118

Author SHA1 Message Date
  Fred Gilham ed9bdaa118 Fix verse number formatting, indenting 3 weeks ago
  Fred Gilham 623249b5a9 Minor change: check for " " as well as " " 3 weeks ago
  Fred Gilham 29363a6f81 Try to make sense of formatting tags 3 weeks ago
1 changed files with 19 additions and 11 deletions
  1. 19 11
      bible-mode.el

+ 19 - 11
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.
@@ -1065,16 +1064,27 @@ In processing subnodes, each case will prepend a space if it needs it."
 	   (let* ((search-string (concat (car bm-current-book) " " (number-to-string bm-current-chapter) ":"))
 		  (match (string-match search-string subnode)))
 	     (when match
-	       (setf subnode (string-replace search-string "" subnode))
-	       (let ((match (string-match "[0-9]+:" subnode)))
-		 ;; Verse number
-		 (add-face-text-property (match-beginning 0) (match-end 0) '(:foreground "purple") nil subnode))))
+	       (setq subnode (string-replace search-string "" subnode))
+	       (setq match (string-match "[0-9]+:" subnode))
+	       ;; Verse number
+	       (add-face-text-property (match-beginning 0) (match-end 0) '(:foreground "purple") nil subnode)))
 	   ;; Red letter
 	   (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?) XXX still not right
+	  ((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)))))
+		      (when (= indent 2) (insert "\n\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 +1097,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) 
@@ -1169,6 +1176,7 @@ If VERSE is supplied, set cursor at verse."
 			    ("‘ " . "‘")
 ;;;			    (" ”" . "”")
 ;;;			    (" ’" . "’")
+			    ("   " . " ")
 			    ("  " . " ")
 			    )
 			  nil (point-min) (point-max))