diff options
author | Bastien <bzg@gnu.org> | 2019-12-03 23:27:04 +0100 |
---|---|---|
committer | Bastien <bzg@gnu.org> | 2019-12-03 23:27:04 +0100 |
commit | 165f7383822086d465519ebe6e4283723923f097 (patch) | |
tree | 820be9480e3d571d766483f564c963037192f6ec /lisp/org/ox-html.el | |
parent | 821de968434d2096bdea67dd24301bf6b517aef1 (diff) | |
download | emacs-165f7383822086d465519ebe6e4283723923f097.tar.gz emacs-165f7383822086d465519ebe6e4283723923f097.tar.bz2 emacs-165f7383822086d465519ebe6e4283723923f097.zip |
Update Org to 9.3
Diffstat (limited to 'lisp/org/ox-html.el')
-rw-r--r-- | lisp/org/ox-html.el | 457 |
1 files changed, 281 insertions, 176 deletions
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el index 8445f236bae..83d0fd2e9c5 100644 --- a/lisp/org/ox-html.el +++ b/lisp/org/ox-html.el @@ -152,6 +152,7 @@ (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format) (:html-postamble-format nil nil org-html-postamble-format) (:html-preamble-format nil nil org-html-preamble-format) + (:html-self-link-headlines nil nil org-html-self-link-headlines) (:html-table-align-individual-fields nil nil org-html-table-align-individual-fields) (:html-table-caption-above nil nil org-html-table-caption-above) @@ -171,6 +172,7 @@ (:html-table-row-open-tag nil nil org-html-table-row-open-tag) (:html-table-row-close-tag nil nil org-html-table-row-close-tag) (:html-xml-declaration nil nil org-html-xml-declaration) + (:html-wrap-src-lines nil nil org-html-wrap-src-lines) (:html-klipsify-src nil nil org-html-klipsify-src) (:html-klipse-css nil nil org-html-klipse-css) (:html-klipse-js nil nil org-html-klipse-js) @@ -215,7 +217,7 @@ (defconst org-html-html5-elements '("article" "aside" "audio" "canvas" "details" "figcaption" "figure" "footer" "header" "menu" "meter" "nav" "output" - "progress" "section" "video") + "progress" "section" "summary" "video") "New elements in html5. For blocks that should contain headlines, use the HTML_CONTAINER @@ -430,6 +432,19 @@ for the JavaScript code in this tag. .footdef { margin-bottom: 1em; } .figure { padding: 1em; } .figure p { text-align: center; } + .equation-container { + display: table; + text-align: center; + width: 100%; + } + .equation { + vertical-align: middle; + } + .equation-label { + display: table-cell; + text-align: right; + vertical-align: middle; + } .inlinetask { padding: 10px; border: 2px solid gray; @@ -789,6 +804,13 @@ but without \"name\" attribute." :package-version '(Org . "8.0") :type 'boolean) +(defcustom org-html-self-link-headlines nil + "When non-nil, the headlines contain a hyperlink to themselves." + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'boolean + :safe #'booleanp) + ;;;; Inlinetasks (defcustom org-html-format-inlinetask-function @@ -863,6 +885,7 @@ link to the image." (defcustom org-html-inline-image-rules '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") + ("attachment" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")) "Rules characterizing image files that can be inlined into HTML. @@ -910,6 +933,15 @@ in all modes you want. Then, use the command :group 'org-export-html :type 'string) +(defcustom org-html-wrap-src-lines nil + "If non-nil, wrap individual lines of source blocks in \"code\" elements. +In this case, add line number in attribute \"data-ox-html-linenr\" when line +numbers are enabled." + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'boolean + :safe t) + ;;;; Table (defcustom org-html-table-default-attributes @@ -1693,7 +1725,7 @@ object unless a different class is specified with an attribute." (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. -ELEMENT is either a src block or an example block." +ELEMENT is either a source or an example block." (let* ((code (car (org-export-unravel-code element))) (attr (org-export-read-attribute :attr_html element))) (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>" @@ -1736,8 +1768,8 @@ If you then set `org-html-htmlize-output-type' to `css', calls to the function `org-html-htmlize-region-for-paste' will produce code that uses these same face definitions." (interactive) - (or (require 'htmlize nil t) - (error "Please install htmlize from https://github.com/hniksic/emacs-htmlize")) + (unless (require 'htmlize nil t) + (error "htmlize library missing. Aborting")) (and (get-buffer "*html*") (kill-buffer "*html*")) (with-temp-buffer (let ((fl (face-list)) @@ -1751,12 +1783,12 @@ produce code that uses these same face definitions." (htmlize-region (point-min) (point-max)))) (pop-to-buffer-same-window "*html*") (goto-char (point-min)) - (if (re-search-forward "<style" nil t) - (delete-region (point-min) (match-beginning 0))) - (if (re-search-forward "</style>" nil t) - (delete-region (1+ (match-end 0)) (point-max))) + (when (re-search-forward "<style" nil t) + (delete-region (point-min) (match-beginning 0))) + (when (re-search-forward "</style>" nil t) + (delete-region (1+ (match-end 0)) (point-max))) (beginning-of-line 1) - (if (looking-at " +") (replace-match "")) + (when (looking-at " +") (replace-match "")) (goto-char (point-min))) (defun org-html--make-string (n string) @@ -1771,33 +1803,38 @@ Replaces invalid characters with \"_\"." (defun org-html-footnote-section (info) "Format the footnote section. INFO is a plist used as a communication channel." - (let* ((fn-alist (org-export-collect-footnote-definitions info)) - (fn-alist - (cl-loop for (n _type raw) in fn-alist collect - (cons n (if (eq (org-element-type raw) 'org-data) - (org-trim (org-export-data raw info)) - (format "<div class=\"footpara\">%s</div>" - (org-trim (org-export-data raw info)))))))) - (when fn-alist + (pcase (org-export-collect-footnote-definitions info) + (`nil nil) + (definitions (format (plist-get info :html-footnotes-section) (org-html--translate "Footnotes" info) (format "\n%s\n" (mapconcat - (lambda (fn) - (let ((n (car fn)) (def (cdr fn))) - (format - "<div class=\"footdef\">%s %s</div>\n" - (format - (plist-get info :html-footnote-format) - (org-html--anchor - (format "fn.%d" n) - n - (format " class=\"footnum\" href=\"#fnr.%d\"" n) - info)) - def))) - fn-alist + (lambda (definition) + (pcase definition + (`(,n ,_ ,def) + ;; `org-export-collect-footnote-definitions' can return + ;; two kinds of footnote definitions: inline and blocks. + ;; Since this should not make any difference in the HTML + ;; output, we wrap the inline definitions within + ;; a "footpara" class paragraph. + (let ((inline? (not (org-element-map def org-element-all-elements + #'identity nil t))) + (anchor (org-html--anchor + (format "fn.%d" n) + n + (format " class=\"footnum\" href=\"#fnr.%d\"" n) + info)) + (contents (org-trim (org-export-data def info)))) + (format "<div class=\"footdef\">%s %s</div>\n" + (format (plist-get info :html-footnote-format) anchor) + (format "<div class=\"footpara\">%s</div>" + (if (not inline?) contents + (format "<p class=\"footpara\">%s</p>" + contents)))))))) + definitions "\n")))))) @@ -1957,44 +1994,42 @@ communication channel." (creator (cdr (assq ?c spec))) (validation-link (cdr (assq ?v spec)))) (concat - (when (and (plist-get info :with-date) - (org-string-nw-p date)) - (format "<p class=\"date\">%s: %s</p>\n" - (org-html--translate "Date" info) - date)) - (when (and (plist-get info :with-author) - (org-string-nw-p author)) - (format "<p class=\"author\">%s: %s</p>\n" - (org-html--translate "Author" info) - author)) - (when (and (plist-get info :with-email) - (org-string-nw-p email)) - (format "<p class=\"email\">%s: %s</p>\n" - (org-html--translate "Email" info) - email)) - (when (plist-get info :time-stamp-file) - (format - "<p class=\"date\">%s: %s</p>\n" - (org-html--translate "Created" info) - (format-time-string - (plist-get info :html-metadata-timestamp-format)))) - (when (plist-get info :with-creator) - (format "<p class=\"creator\">%s</p>\n" creator)) - (format "<p class=\"validation\">%s</p>\n" - validation-link)))) - (t (format-spec - (or (cadr (assoc-string - (plist-get info :language) - (eval (intern - (format "org-html-%s-format" type))) - t)) - (cadr - (assoc-string - "en" - (eval - (intern (format "org-html-%s-format" type))) - t))) - spec)))))) + (and (plist-get info :with-date) + (org-string-nw-p date) + (format "<p class=\"date\">%s: %s</p>\n" + (org-html--translate "Date" info) + date)) + (and (plist-get info :with-author) + (org-string-nw-p author) + (format "<p class=\"author\">%s: %s</p>\n" + (org-html--translate "Author" info) + author)) + (and (plist-get info :with-email) + (org-string-nw-p email) + (format "<p class=\"email\">%s: %s</p>\n" + (org-html--translate "Email" info) + email)) + (and (plist-get info :time-stamp-file) + (format + "<p class=\"date\">%s: %s</p>\n" + (org-html--translate "Created" info) + (format-time-string + (plist-get info :html-metadata-timestamp-format)))) + (and (plist-get info :with-creator) + (org-string-nw-p creator) + (format "<p class=\"creator\">%s</p>\n" creator)) + (and (org-string-nw-p validation-link) + (format "<p class=\"validation\">%s</p>\n" + validation-link))))) + (t + (let ((formats (plist-get info (if (eq type 'preamble) + :html-preamble-format + :html-postamble-format))) + (language (plist-get info :language))) + (format-spec + (cadr (or (assoc-string language formats t) + (assoc-string "en" formats t))) + spec))))))) (let ((div (assq type (plist-get info :html-divs)))) (when (org-string-nw-p section-contents) (concat @@ -2089,12 +2124,12 @@ holding export options." ;; Postamble. (org-html--build-pre/postamble 'postamble info) ;; Possibly use the Klipse library live code blocks. - (if (plist-get info :html-klipsify-src) - (concat "<script>" (plist-get info :html-klipse-selection-script) - "</script><script src=\"" - org-html-klipse-js - "\"></script><link rel=\"stylesheet\" type=\"text/css\" href=\"" - org-html-klipse-css "\"/>")) + (when (plist-get info :html-klipsify-src) + (concat "<script>" (plist-get info :html-klipse-selection-script) + "</script><script src=\"" + org-html-klipse-js + "\"></script><link rel=\"stylesheet\" type=\"text/css\" href=\"" + org-html-klipse-css "\"/>")) ;; Closing document. "</body>\n</html>")) @@ -2160,12 +2195,10 @@ is the language used for CODE, as a string, or nil." ;; Plain text explicitly set. ((not org-html-htmlize-output-type) (org-html-encode-plain-text code)) ;; No htmlize library or an inferior version of htmlize. - ((not (and (or (require 'htmlize nil t) - (error "Please install htmlize from \ -https://github.com/hniksic/emacs-htmlize")) - (fboundp 'htmlize-region-for-paste))) + ((not (progn (require 'htmlize nil t) + (fboundp 'htmlize-region-for-paste))) ;; Emit a warning. - (message "Cannot fontify src block (htmlize.el >= 1.34 required)") + (message "Cannot fontify source block (htmlize.el >= 1.34 required)") (org-html-encode-plain-text code)) (t ;; Map language @@ -2208,14 +2241,15 @@ https://github.com/hniksic/emacs-htmlize")) (if (and beg end) (substring code beg end) code))))))))) (defun org-html-do-format-code - (code &optional lang refs retain-labels num-start) + (code &optional lang refs retain-labels num-start wrap-lines) "Format CODE string as source code. -Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are, -respectively, the language of the source code, as a string, an +Optional arguments LANG, REFS, RETAIN-LABELS, NUM-START, WRAP-LINES +are, respectively, the language of the source code, as a string, an alist between line numbers and references (as returned by `org-export-unravel-code'), a boolean specifying if labels should -appear in the source code, and the number associated to the first -line of code." +appear in the source code, the number associated to the first +line of code, and a boolean specifying if lines of code should be +wrapped in code elements." (let* ((code-lines (split-string code "\n")) (code-length (length code-lines)) (num-fmt @@ -2233,7 +2267,13 @@ line of code." (format "<span class=\"linenr\">%s</span>" (format num-fmt line-num))) ;; Transcoded src line. - loc + (if wrap-lines + (format "<code%s>%s</code>" + (if num-start + (format " data-ox-html-linenr=\"%s\"" line-num) + "") + loc) + loc) ;; Add label, if needed. (when (and ref retain-labels) (format " (%s)" ref)))) ;; Mark transcoded line as an anchor, if needed. @@ -2244,18 +2284,20 @@ line of code." (defun org-html-format-code (element info) "Format contents of ELEMENT as source code. -ELEMENT is either an example block or a src block. INFO is -a plist used as a communication channel." +ELEMENT is either an example or a source block. INFO is a plist +used as a communication channel." (let* ((lang (org-element-property :language element)) ;; Extract code and references. (code-info (org-export-unravel-code element)) (code (car code-info)) (refs (cdr code-info)) - ;; Does the src block contain labels? + ;; Does the source block contain labels? (retain-labels (org-element-property :retain-labels element)) ;; Does it have line numbers? - (num-start (org-export-get-loc element info))) - (org-html-do-format-code code lang refs retain-labels num-start))) + (num-start (org-export-get-loc element info)) + ;; Should lines be wrapped in code elements? + (wrap-lines (plist-get info :html-wrap-src-lines))) + (org-html-do-format-code code lang refs retain-labels num-start wrap-lines))) ;;; Tables of Contents @@ -2580,18 +2622,12 @@ holding contextual information." (full-text (funcall (plist-get info :html-format-headline-function) todo todo-type priority text tags info)) (contents (or contents "")) - (ids (delq nil - (list (org-element-property :CUSTOM_ID headline) - (org-export-get-reference headline info) - (org-element-property :ID headline)))) - (preferred-id (car ids)) - (extra-ids - (mapconcat - (lambda (id) - (org-html--anchor - (if (org-uuidgen-p id) (concat "ID-" id) id) - nil nil info)) - (cdr ids) ""))) + (id (or (org-element-property :CUSTOM_ID headline) + (org-export-get-reference headline info))) + (formatted-text + (if (plist-get info :html-self-link-headlines) + (format "<a href=\"#%s\">%s</a>" id full-text) + full-text))) (if (org-export-low-level-p headline info) ;; This is a deep sub-tree: export it as a list item. (let* ((html-type (if numberedp "ol" "ul"))) @@ -2600,15 +2636,16 @@ holding contextual information." (apply #'format "<%s class=\"org-%s\">\n" (make-list 2 html-type))) (org-html-format-list-item - contents (if numberedp 'ordered 'unordered) - nil info nil - (concat (org-html--anchor preferred-id nil nil info) - extra-ids - full-text)) "\n" + contents (if numberedp 'ordered 'unordered) + nil info nil + (concat (org-html--anchor id nil nil info) formatted-text)) "\n" (and (org-export-last-sibling-p headline info) (format "</%s>\n" html-type)))) ;; Standard headline. Export it as a section. - (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) + (let ((extra-class + (org-element-property :HTML_CONTAINER_CLASS headline)) + (headline-class + (org-element-property :HTML_HEADLINE_CLASS headline)) (first-content (car (org-element-contents headline)))) (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n" (org-html--container headline info) @@ -2617,17 +2654,18 @@ holding contextual information." (concat (format "outline-%d" level) (and extra-class " ") extra-class) - (format "\n<h%d id=\"%s\">%s%s</h%d>\n" + (format "\n<h%d id=\"%s\"%s>%s</h%d>\n" level - preferred-id - extra-ids + id + (if (not headline-class) "" + (format " class=\"%s\"" headline-class)) (concat (and numberedp (format "<span class=\"section-number-%d\">%s</span> " level (mapconcat #'number-to-string numbers "."))) - full-text) + formatted-text) level) ;; When there is no section, pretend there is an ;; empty one to get the correct <div @@ -2795,8 +2833,13 @@ CONTENTS is nil. INFO is a plist holding contextual information." ((string-match "\\<headlines\\>" value) (let ((depth (and (string-match "\\<[0-9]+\\>" value) (string-to-number (match-string 0 value)))) - (localp (string-match-p "\\<local\\>" value))) - (org-html-toc depth info (and localp keyword)))) + (scope + (cond + ((string-match ":target +\\(\".+?\"\\|\\S-+\\)" value) ;link + (org-export-resolve-link + (org-strip-quotes (match-string 1 value)) info)) + ((string-match-p "\\<local\\>" value) keyword)))) ;local + (org-html-toc depth info scope))) ((string= "listings" value) (org-html-list-of-listings info)) ((string= "tables" value) (org-html-list-of-tables info)))))))) @@ -2837,26 +2880,73 @@ INFO is a plist containing export properties." "Creating LaTeX Image..." nil processing-type) (buffer-string)))) +(defun org-html--wrap-latex-environment (contents _ &optional caption label) + "Wrap CONTENTS string within appropriate environment for equations. +When optional arguments CAPTION and LABEL are given, use them for +caption and \"id\" attribute." + (format "\n<div%s class=\"equation-container\">\n%s%s\n</div>" + ;; ID. + (if (org-string-nw-p label) (format " id=\"%s\"" label) "") + ;; Contents. + (format "<span class=\"equation\">\n%s\n</span>" contents) + ;; Caption. + (if (not (org-string-nw-p caption)) "" + (format "\n<span class=\"equation-label\">\n%s\n</span>" + caption)))) + +(defun org-html--math-environment-p (element &optional _) + "Non-nil when ELEMENT is a LaTeX math environment. +Math environments match the regular expression defined in +`org-latex-math-environments-re'. This function is meant to be +used as a predicate for `org-export-get-ordinal' or a value to +`org-html-standalone-image-predicate'." + (string-match-p org-latex-math-environments-re + (org-element-property :value element))) + +(defun org-html--unlabel-latex-environment (latex-frag) + "Change environment in LATEX-FRAG string to an unnumbered one. +For instance, change an 'equation' environment to 'equation*'." + (replace-regexp-in-string + "\\`[ \t]*\\\\begin{\\([^*]+?\\)}" + "\\1*" + (replace-regexp-in-string "^[ \t]*\\\\end{\\([^*]+?\\)}[ \r\t\n]*\\'" + "\\1*" + latex-frag nil nil 1) + nil nil 1)) + (defun org-html-latex-environment (latex-environment _contents info) "Transcode a LATEX-ENVIRONMENT element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." (let ((processing-type (plist-get info :with-latex)) (latex-frag (org-remove-indentation (org-element-property :value latex-environment))) - (attributes (org-export-read-attribute :attr_html latex-environment))) + (attributes (org-export-read-attribute :attr_html latex-environment)) + (label (and (org-element-property :name latex-environment) + (org-export-get-reference latex-environment info))) + (caption (number-to-string + (org-export-get-ordinal + latex-environment info nil + #'org-html--math-environment-p)))) (cond ((memq processing-type '(t mathjax)) - (org-html-format-latex latex-frag 'mathjax info)) + (org-html-format-latex + (if (org-string-nw-p label) + (replace-regexp-in-string "\\`.*" + (format "\\&\n\\\\label{%s}" label) + latex-frag) + latex-frag) + 'mathjax info)) ((assq processing-type org-preview-latex-process-alist) (let ((formula-link - (org-html-format-latex latex-frag processing-type info))) - (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) - ;; Do not provide a caption or a name to be consistent with - ;; `mathjax' handling. - (org-html--wrap-image - (org-html--format-image - (match-string 1 formula-link) attributes info) info)))) - (t latex-frag)))) + (org-html-format-latex + (org-html--unlabel-latex-environment latex-frag) + processing-type info))) + (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) + (org-html--wrap-latex-environment + (org-html--format-image + (match-string 1 formula-link) attributes info) + info caption label)))) + (t (org-html--wrap-latex-environment latex-frag info caption label))))) ;;;; Latex Fragment @@ -2972,7 +3062,7 @@ INFO is a plist holding contextual information. See (path (cond ((member type '("http" "https" "ftp" "mailto" "news")) - (url-encode-url (org-link-unescape (concat type ":" raw-path)))) + (url-encode-url (concat type ":" raw-path))) ((string= type "file") ;; During publishing, turn absolute file names belonging ;; to base directory into relative file names. Otherwise, @@ -2994,30 +3084,31 @@ INFO is a plist holding contextual information. See ;; relative to a custom-id, a headline title, a name or ;; a target. (let ((option (org-element-property :search-option link))) - (cond ((not option) raw-path) - ;; Since HTML back-end use custom-id value as-is, - ;; resolving is them is trivial. - ((eq (string-to-char option) ?#) (concat raw-path option)) - (t - (concat raw-path - "#" - (org-publish-resolve-external-link - option - (org-element-property :path link))))))) + (if (not option) raw-path + (let ((path (org-element-property :path link))) + (concat raw-path + "#" + (org-publish-resolve-external-link option path t)))))) (t raw-path))) - ;; Extract attributes from parent's paragraph. HACK: Only do - ;; this for the first link in parent (inner image link for - ;; inline images). This is needed as long as attributes - ;; cannot be set on a per link basis. (attributes-plist - (let* ((parent (org-export-get-parent-element link)) - (link (let ((container (org-export-get-parent link))) - (if (and (eq (org-element-type container) 'link) - (org-html-inline-image-p link info)) - container - link)))) - (and (eq (org-element-map parent 'link 'identity info t) link) - (org-export-read-attribute :attr_html parent)))) + (org-combine-plists + ;; Extract attributes from parent's paragraph. HACK: Only + ;; do this for the first link in parent (inner image link + ;; for inline images). This is needed as long as + ;; attributes cannot be set on a per link basis. + (let* ((parent (org-export-get-parent-element link)) + (link (let ((container (org-export-get-parent link))) + (if (and (eq 'link (org-element-type container)) + (org-html-inline-image-p link info)) + container + link)))) + (and (eq link (org-element-map parent 'link #'identity info t)) + (org-export-read-attribute :attr_html parent))) + ;; Also add attributes from link itself. Currently, those + ;; need to be added programmatically before `org-html-link' + ;; is invoked, for example, by backends building upon HTML + ;; export. + (org-export-read-attribute :attr_html link))) (attributes (let ((attr (org-html--make-attribute-string attributes-plist))) (if (org-string-nw-p attr) (concat " " attr) "")))) @@ -3081,23 +3172,37 @@ INFO is a plist holding contextual information. See (format "<a href=\"#%s\"%s>%s</a>" href attributes desc))) ;; Fuzzy link points to a target or an element. (_ - (let* ((ref (org-export-get-reference destination info)) - (org-html-standalone-image-predicate - #'org-html--has-caption-p) - (number (cond - (desc nil) - ((org-html-standalone-image-p destination info) - (org-export-get-ordinal - (org-element-map destination 'link - #'identity info t) - info 'link 'org-html-standalone-image-p)) - (t (org-export-get-ordinal - destination info nil 'org-html--has-caption-p)))) - (desc (cond (desc) - ((not number) "No description for this link") - ((numberp number) (number-to-string number)) - (t (mapconcat #'number-to-string number "."))))) - (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc)))))) + (if (and destination + (memq (plist-get info :with-latex) '(mathjax t)) + (eq 'latex-environment (org-element-type destination)) + (eq 'math (org-latex--environment-type destination))) + ;; Caption and labels are introduced within LaTeX + ;; environment. Use "eqref" macro to refer to those in + ;; the document. + (format "\\eqref{%s}" + (org-export-get-reference destination info)) + (let* ((ref (org-export-get-reference destination info)) + (org-html-standalone-image-predicate + #'org-html--has-caption-p) + (counter-predicate + (if (eq 'latex-environment (org-element-type destination)) + #'org-html--math-environment-p + #'org-html--has-caption-p)) + (number + (cond + (desc nil) + ((org-html-standalone-image-p destination info) + (org-export-get-ordinal + (org-element-map destination 'link #'identity info t) + info 'link 'org-html-standalone-image-p)) + (t (org-export-get-ordinal + destination info nil counter-predicate)))) + (desc + (cond (desc) + ((not number) "No description for this link") + ((numberp number) (number-to-string number)) + (t (mapconcat #'number-to-string number "."))))) + (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc))))))) ;; Coderef: replace link with the reference name or the ;; equivalent line number. ((string= type "coderef") @@ -3111,18 +3216,18 @@ INFO is a plist holding contextual information. See (format (org-export-get-coderef-format path desc) (org-export-resolve-coderef path info))))) ;; External link with a description part. - ((and path desc) (format "<a href=\"%s\"%s>%s</a>" - (org-html-encode-plain-text path) - attributes - desc)) + ((and path desc) + (format "<a href=\"%s\"%s>%s</a>" + (org-html-encode-plain-text path) + attributes + desc)) ;; External link without a description part. - (path (let ((path (org-html-encode-plain-text path))) - (format "<a href=\"%s\"%s>%s</a>" - path - attributes - (org-link-unescape path)))) + (path + (let ((path (org-html-encode-plain-text path))) + (format "<a href=\"%s\"%s>%s</a>" path attributes path))) ;; No path, only description. Try to do something useful. - (t (format "<i>%s</i>" desc))))) + (t + (format "<i>%s</i>" desc))))) ;;;; Node Property @@ -3665,8 +3770,8 @@ contextual information." (with-temp-buffer (insert contents) (set-auto-mode t) - (if (plist-get info :html-indent) - (indent-region (point-min) (point-max))) + (when (plist-get info :html-indent) + (indent-region (point-min) (point-max))) (buffer-substring-no-properties (point-min) (point-max)))) |