Merge branch 'maint'
This commit is contained in:
commit
343417bcdb
|
@ -4675,47 +4675,51 @@ indentation removed from its contents."
|
|||
;; the beginnings of the contents or right after a line
|
||||
;; break.
|
||||
(lambda (blob first-flag min-ind)
|
||||
(catch 'zero
|
||||
(dolist (datum (org-element-contents blob) min-ind)
|
||||
(when first-flag
|
||||
(setq first-flag nil)
|
||||
(cond
|
||||
;; Objects cannot start with spaces: in this
|
||||
;; case, indentation is 0.
|
||||
((not (stringp datum)) (throw 'zero 0))
|
||||
((not (string-match
|
||||
"\\`\\([ \t]+\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum))
|
||||
(throw 'zero 0))
|
||||
((equal (match-string 2 datum) "\n")
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1) 'org-ind 'empty datum))
|
||||
(t
|
||||
(let ((i (string-width (match-string 1 datum))))
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1) 'org-ind i datum)
|
||||
(setq min-ind (min i min-ind))))))
|
||||
(dolist (datum (org-element-contents blob) min-ind)
|
||||
(when first-flag
|
||||
(setq first-flag nil)
|
||||
(cond
|
||||
((stringp datum)
|
||||
(let ((s 0))
|
||||
(while (string-match
|
||||
"\n\\([ \t]+\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum s)
|
||||
(setq s (match-end 1))
|
||||
(if (equal (match-string 2 datum) "\n")
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1)
|
||||
'org-ind 'empty
|
||||
datum)
|
||||
(let ((i (string-width (match-string 1 datum))))
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1) 'org-ind i datum)
|
||||
(setq min-ind (min i min-ind)))))))
|
||||
((eq (org-element-type datum) 'line-break)
|
||||
(setq first-flag t))
|
||||
((memq (org-element-type datum) org-element-recursive-objects)
|
||||
(setq min-ind
|
||||
(funcall find-min-ind datum first-flag min-ind))))))))
|
||||
(min-ind (funcall find-min-ind
|
||||
element (not ignore-first) most-positive-fixnum)))
|
||||
;; Objects cannot start with spaces: in this
|
||||
;; case, indentation is 0.
|
||||
((not (stringp datum)) (throw :zero 0))
|
||||
((not (string-match
|
||||
"\\`\\([ \t]+\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum))
|
||||
(throw :zero 0))
|
||||
((equal (match-string 2 datum) "\n")
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1) 'org-ind 'empty datum))
|
||||
(t
|
||||
(let ((i (string-width (match-string 1 datum))))
|
||||
(put-text-property
|
||||
(match-beginning 1) (match-end 1) 'org-ind i datum)
|
||||
(setq min-ind (min i min-ind))))))
|
||||
(cond
|
||||
((stringp datum)
|
||||
(let ((s 0))
|
||||
(while (string-match
|
||||
"\n\\([ \t]*\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum s)
|
||||
(setq s (match-end 1))
|
||||
(cond
|
||||
((equal (match-string 1 datum) "")
|
||||
(unless (member (match-string 2 datum) '("" "\n"))
|
||||
(throw :zero 0)))
|
||||
((equal (match-string 2 datum) "\n")
|
||||
(put-text-property (match-beginning 1) (match-end 1)
|
||||
'org-ind 'empty datum))
|
||||
(t
|
||||
(let ((i (string-width (match-string 1 datum))))
|
||||
(put-text-property (match-beginning 1) (match-end 1)
|
||||
'org-ind i datum)
|
||||
(setq min-ind (min i min-ind))))))))
|
||||
((eq (org-element-type datum) 'line-break)
|
||||
(setq first-flag t))
|
||||
((memq (org-element-type datum) org-element-recursive-objects)
|
||||
(setq min-ind
|
||||
(funcall find-min-ind datum first-flag min-ind)))))))
|
||||
(min-ind
|
||||
(catch :zero
|
||||
(funcall find-min-ind
|
||||
element (not ignore-first) most-positive-fixnum))))
|
||||
(if (or (zerop min-ind) (= min-ind most-positive-fixnum)) element
|
||||
;; Build ELEMENT back, replacing each string with the same
|
||||
;; string minus common indentation.
|
||||
|
|
|
@ -1567,21 +1567,26 @@ INFO is the current state of the export process, as a plist."
|
|||
(org-html-html5-p info)))
|
||||
|
||||
(defun org-html-close-tag (tag attr info)
|
||||
(concat "<" tag " " attr
|
||||
"Return close-tag for string TAG.
|
||||
ATTR specifies additional attributes. INFO is a property list
|
||||
containing current export state."
|
||||
(concat "<" tag
|
||||
(org-string-nw-p (concat " " attr))
|
||||
(if (org-html-xhtml-p info) " />" ">")))
|
||||
|
||||
(defun org-html-doctype (info)
|
||||
"Return correct html doctype tag from `org-html-doctype-alist',
|
||||
or the literal value of :html-doctype from INFO if :html-doctype
|
||||
is not found in the alist.
|
||||
INFO is a plist used as a communication channel."
|
||||
"Return correct HTML doctype tag.
|
||||
INFO is a plist used as a communication channel. Doctype tag is
|
||||
extracted from `org-html-doctype-alist', or the literal value
|
||||
of :html-doctype from INFO if :html-doctype is not found in the
|
||||
alist."
|
||||
(let ((dt (plist-get info :html-doctype)))
|
||||
(or (cdr (assoc dt org-html-doctype-alist)) dt)))
|
||||
|
||||
(defun org-html--make-attribute-string (attributes)
|
||||
"Return a list of attributes, as a string.
|
||||
ATTRIBUTES is a plist where values are either strings or nil. An
|
||||
attributes with a nil value will be omitted from the result."
|
||||
ATTRIBUTES is a plist where values are either strings or nil. An
|
||||
attribute with a nil value will be omitted from the result."
|
||||
(let (output)
|
||||
(dolist (item attributes (mapconcat 'identity (nreverse output) " "))
|
||||
(cond ((null item) (pop output))
|
||||
|
@ -3591,20 +3596,16 @@ information."
|
|||
"Transcode a VERSE-BLOCK element from Org to HTML.
|
||||
CONTENTS is verse block contents. INFO is a plist holding
|
||||
contextual information."
|
||||
;; Replace each newline character with line break. Also replace
|
||||
;; each blank line with a line break.
|
||||
(setq contents (replace-regexp-in-string
|
||||
"^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info))
|
||||
(replace-regexp-in-string
|
||||
"\\(\\\\\\\\\\)?[ \t]*\n"
|
||||
(format "%s\n" (org-html-close-tag "br" nil info)) contents)))
|
||||
;; Replace each white space at beginning of a line with a
|
||||
;; non-breaking space.
|
||||
(while (string-match "^[ \t]+" contents)
|
||||
(let* ((num-ws (length (match-string 0 contents)))
|
||||
(ws (org-html--make-string num-ws " ")))
|
||||
(setq contents (replace-match ws nil t contents))))
|
||||
(format "<p class=\"verse\">\n%s</p>" contents))
|
||||
(format "<p class=\"verse\">\n%s</p>"
|
||||
;; Replace leading white spaces with non-breaking spaces.
|
||||
(replace-regexp-in-string
|
||||
"^[ \t]+" (lambda (m) (org-html--make-string (length m) " "))
|
||||
;; Replace each newline character with line break. Also
|
||||
;; remove any trailing "br" close-tag so as to avoid
|
||||
;; duplicates.
|
||||
(let* ((br (org-html-close-tag "br" nil info))
|
||||
(re (format "\\(%s\\)[ \t]*$" (regexp-quote br))))
|
||||
(replace-regexp-in-string re br contents)))))
|
||||
|
||||
|
||||
;;; Filter Functions
|
||||
|
|
|
@ -3250,6 +3250,11 @@ Text
|
|||
(org-element-normalize-contents
|
||||
'(paragraph nil " Two spaces\n Three spaces"))
|
||||
'(paragraph nil "Two spaces\n Three spaces")))
|
||||
(should
|
||||
(equal
|
||||
(org-element-normalize-contents
|
||||
'(paragraph nil " Two spaces\nNo space"))
|
||||
'(paragraph nil " Two spaces\nNo space")))
|
||||
;; Ignore objects within contents when computing maximum common
|
||||
;; indentation. However, if contents start with an object, common
|
||||
;; indentation is 0.
|
||||
|
|
Loading…
Reference in New Issue