add math label and untabify
This commit is contained in:
@@ -98,11 +98,13 @@
|
|||||||
(:rst-metadata nil "rst-metadata" org-rst-metadata)
|
(:rst-metadata nil "rst-metadata" org-rst-metadata)
|
||||||
(:rst-metadata-format nil nil org-rst-metadata-format)
|
(:rst-metadata-format nil nil org-rst-metadata-format)
|
||||||
(:rst-metadata-timestamp-format nil nil org-rst-metadata-timestamp-format)
|
(:rst-metadata-timestamp-format nil nil org-rst-metadata-timestamp-format)
|
||||||
|
(:rst-equation-reference-format "RST_EQUATION_REFERENCE_FORMAT" nil org-rst-equation-reference-format t)
|
||||||
(:rst-inline-images nil nil org-rst-inline-images)
|
(:rst-inline-images nil nil org-rst-inline-images)
|
||||||
(:rst-inline-image-rules nil nil org-rst-inline-image-rules)
|
(:rst-inline-image-rules nil nil org-rst-inline-image-rules)
|
||||||
(:rst-link-org-files-as-rst nil nil org-rst-link-org-files-as-rst)
|
(:rst-link-org-files-as-rst nil nil org-rst-link-org-files-as-rst)
|
||||||
(:rst-link-home "RST_LINK_HOME" nil org-rst-link-home)
|
(:rst-link-home "RST_LINK_HOME" nil org-rst-link-home)
|
||||||
(:rst-link-use-ref-role nil nil org-rst-link-use-ref-role)
|
(:rst-link-use-ref-role nil nil org-rst-link-use-ref-role)
|
||||||
|
(:rst-prefer-user-labels nil nil org-rst-prefer-user-labels)
|
||||||
(:rst-extension nil nil org-rst-extension)
|
(:rst-extension nil nil org-rst-extension)
|
||||||
(:rst-file-link-use-ref-role nil nil org-rst-file-link-use-ref-role)
|
(:rst-file-link-use-ref-role nil nil org-rst-file-link-use-ref-role)
|
||||||
(:rst-text-markup-alist nil nil org-rst-text-markup-alist)
|
(:rst-text-markup-alist nil nil org-rst-text-markup-alist)
|
||||||
@@ -123,6 +125,10 @@
|
|||||||
|
|
||||||
;;; Internal Variables
|
;;; Internal Variables
|
||||||
|
|
||||||
|
(defvar org-rst--id-attr-prefix "ID-"
|
||||||
|
"Prefix to use in ID attributes.
|
||||||
|
This affects IDs that are determined from the ID property.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; User Configurable Variables
|
;;; User Configurable Variables
|
||||||
@@ -238,8 +244,7 @@ contain these elements:
|
|||||||
%a stands for the author's name.
|
%a stands for the author's name.
|
||||||
%e stands for the author's email.
|
%e stands for the author's email.
|
||||||
%d stands for the date.
|
%d stands for the date.
|
||||||
%c will be replaced by `org-html-creator-string'.
|
%c will be replaced by `org-rst-creator-string'.
|
||||||
%v will be replaced by `org-html-validation-link'.
|
|
||||||
%T will be replaced by the export time.
|
%T will be replaced by the export time.
|
||||||
%C will be replaced by the last modification time.
|
%C will be replaced by the last modification time.
|
||||||
|
|
||||||
@@ -380,6 +385,25 @@ in order to mimic default behaviour:
|
|||||||
:group 'org-export-rst
|
:group 'org-export-rst
|
||||||
:type 'function)
|
:type 'function)
|
||||||
|
|
||||||
|
;;;; RST-specific
|
||||||
|
|
||||||
|
(defcustom org-rst-prefer-user-labels nil
|
||||||
|
"When non-nil use user-defined names and ID over internal ones.
|
||||||
|
|
||||||
|
By default, Org generates its own internal ID values during RST
|
||||||
|
export. This process ensures that these values are unique and
|
||||||
|
valid, but the keys are not available in advance of the export
|
||||||
|
process, and not so readable.
|
||||||
|
|
||||||
|
When this variable is non-nil, Org will use NAME keyword, or the
|
||||||
|
real name of the target to create the ID attribute.
|
||||||
|
|
||||||
|
Independently of this variable, however, CUSTOM_ID are always
|
||||||
|
used as a reference."
|
||||||
|
:group 'org-export-rst
|
||||||
|
:type 'boolean
|
||||||
|
:safe #'booleanp)
|
||||||
|
|
||||||
|
|
||||||
;;;; Inlinetasks
|
;;;; Inlinetasks
|
||||||
|
|
||||||
@@ -399,6 +423,26 @@ The function should return the string to be exported."
|
|||||||
:type 'function)
|
:type 'function)
|
||||||
|
|
||||||
|
|
||||||
|
;;;; LaTeX
|
||||||
|
|
||||||
|
(defcustom org-rst-equation-reference-format "\\eqref{%s}"
|
||||||
|
"The MathJax command to use when referencing equations.
|
||||||
|
|
||||||
|
This is a format control string that expects a single string argument
|
||||||
|
specifying the label that is being referenced. The argument is
|
||||||
|
generated automatically on export.
|
||||||
|
|
||||||
|
The default is to wrap equations in parentheses (using \"\\eqref{%s}\)\".
|
||||||
|
|
||||||
|
Most common values are:
|
||||||
|
|
||||||
|
\\eqref{%s} Wrap the equation in parentheses
|
||||||
|
\\ref{%s} Do not wrap the equation in parentheses"
|
||||||
|
:group 'org-export-rst
|
||||||
|
:type 'string
|
||||||
|
:safe #'stringp)
|
||||||
|
|
||||||
|
|
||||||
;;;; Src blocks
|
;;;; Src blocks
|
||||||
|
|
||||||
(defcustom org-rst-code-block 'code
|
(defcustom org-rst-code-block 'code
|
||||||
@@ -577,11 +621,11 @@ See `org-rst-text-markup-alist' for details."
|
|||||||
(defun org-rst--checkbox (item _info)
|
(defun org-rst--checkbox (item _info)
|
||||||
"Return checkbox string for ITEM or nil.
|
"Return checkbox string for ITEM or nil.
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
;(let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
|
;; (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
|
||||||
; (case (org-element-property :checkbox item)
|
;; (case (org-element-property :checkbox item)
|
||||||
; (on (if utf8p "☑ " "[X] "))
|
;; (on (if utf8p "☑ " "[X] "))
|
||||||
; (off (if utf8p "☐ " "[ ] "))
|
;; (off (if utf8p "☐ " "[ ] "))
|
||||||
; (trans (if utf8p "☒ " "[-] ")))))
|
;; (trans (if utf8p "☒ " "[-] ")))))
|
||||||
(cl-case (org-element-property :checkbox item)
|
(cl-case (org-element-property :checkbox item)
|
||||||
(on "☑ ")
|
(on "☑ ")
|
||||||
(off "☐ ")
|
(off "☐ ")
|
||||||
@@ -594,7 +638,6 @@ INFO is a plist used as a communication channel."
|
|||||||
(defun org-rst-format-spec (info)
|
(defun org-rst-format-spec (info)
|
||||||
"Return format specification for metadata.
|
"Return format specification for metadata.
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
;; (timestamp-format (plist-get info :html-metadata-timestamp-format))
|
|
||||||
;; org-export-date-timestamp-format
|
;; org-export-date-timestamp-format
|
||||||
(let ((timestamp-format (plist-get info :rst-metadata-timestamp-format)))
|
(let ((timestamp-format (plist-get info :rst-metadata-timestamp-format)))
|
||||||
`((?t . ,(org-export-data (plist-get info :title) info))
|
`((?t . ,(org-export-data (plist-get info :title) info))
|
||||||
@@ -798,7 +841,8 @@ information."
|
|||||||
(defun org-rst-export-block (export-block _contents _info)
|
(defun org-rst-export-block (export-block _contents _info)
|
||||||
"Transcode a EXPORT-BLOCK element from Org to reStructuredText.
|
"Transcode a EXPORT-BLOCK element from Org to reStructuredText.
|
||||||
CONTENTS is nil. INFO is a plist holding contextual information."
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(when (member (org-element-property :type export-block) '("RST" "REST" "RESTRUCTUREDTEXT"))
|
(when (member (org-element-property :type export-block)
|
||||||
|
'("RST" "REST" "RESTRUCTUREDTEXT"))
|
||||||
(org-element-property :value export-block)))
|
(org-element-property :value export-block)))
|
||||||
|
|
||||||
|
|
||||||
@@ -813,13 +857,13 @@ CONTENTS is nil. INFO is a plist holding contextual information."
|
|||||||
|
|
||||||
;;;; Footnote Definition
|
;;;; Footnote Definition
|
||||||
|
|
||||||
;(defun org-rst-footnote-definition (footnote-definition contents info)
|
;; (defun org-rst-footnote-definition (footnote-definition contents info)
|
||||||
; "Transcode a FOOTNOTE-DEFINITION element from Org to reStructuredText.
|
;; "Transcode a FOOTNOTE-DEFINITION element from Org to reStructuredText.
|
||||||
;CONTENTS is nil. INFO is a plist holding contextual information."
|
;; CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
; (replace-regexp-in-string
|
;; (replace-regexp-in-string
|
||||||
; "^" ".. "
|
;; "^" ".. "
|
||||||
; (org-remove-indentation
|
;; (org-remove-indentation
|
||||||
; (org-element-property :value footnote-definition))))
|
;; (org-element-property :value footnote-definition))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Footnote Reference
|
;;;; Footnote Reference
|
||||||
@@ -1019,12 +1063,11 @@ targets and targets."
|
|||||||
(org-element-property :value datum))
|
(org-element-property :value datum))
|
||||||
(org-element-property :name datum)
|
(org-element-property :name datum)
|
||||||
(when-let* ((id (org-element-property :ID datum)))
|
(when-let* ((id (org-element-property :ID datum)))
|
||||||
(concat org-html--id-attr-prefix id)))))
|
(concat org-rst--id-attr-prefix id)))))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((and user-label
|
((and user-label
|
||||||
(or ;; (plist-get info :html-prefer-user-labels)
|
(or (plist-get info :rst-prefer-user-labels)
|
||||||
nil
|
|
||||||
;; Used CUSTOM_ID property unconditionally.
|
;; Used CUSTOM_ID property unconditionally.
|
||||||
custom-id))
|
custom-id))
|
||||||
user-label)
|
user-label)
|
||||||
@@ -1044,7 +1087,7 @@ caption and \"id\" attribute."
|
|||||||
(if (org-string-nw-p label) (format " :label: %s\n" label) "")
|
(if (org-string-nw-p label) (format " :label: %s\n" label) "")
|
||||||
;; Caption.
|
;; Caption.
|
||||||
(if (not (org-string-nw-p caption)) ""
|
(if (not (org-string-nw-p caption)) ""
|
||||||
(format " :label:%s\n" caption))
|
(format " :label: %s\n :nowrap:\n" caption)) ;; todo: flag for nowrap?
|
||||||
;; Contents.
|
;; Contents.
|
||||||
(format "\n%s\n" (org-rst--indent-string
|
(format "\n%s\n" (org-rst--indent-string
|
||||||
(org-trim contents) org-rst-quote-margin))))
|
(org-trim contents) org-rst-quote-margin))))
|
||||||
@@ -1054,7 +1097,7 @@ caption and \"id\" attribute."
|
|||||||
Math environments match the regular expression defined in
|
Math environments match the regular expression defined in
|
||||||
`org-latex-math-environments-re'. This function is meant to be
|
`org-latex-math-environments-re'. This function is meant to be
|
||||||
used as a predicate for `org-export-get-ordinal' or a value to
|
used as a predicate for `org-export-get-ordinal' or a value to
|
||||||
`org-html-standalone-image-predicate'."
|
`org-rst-standalone-image-predicate'."
|
||||||
(string-match-p org-latex-math-environments-re
|
(string-match-p org-latex-math-environments-re
|
||||||
(org-element-property :value element)))
|
(org-element-property :value element)))
|
||||||
|
|
||||||
@@ -1068,7 +1111,7 @@ Starred and \"displaymath\" environments are not numbered."
|
|||||||
"Transcode a LATEX-ENVIRONMENT element from Org to reStructuredText.
|
"Transcode a LATEX-ENVIRONMENT element from Org to reStructuredText.
|
||||||
CONTENTS is nil. INFO is a plist holding contextual
|
CONTENTS is nil. INFO is a plist holding contextual
|
||||||
information."
|
information."
|
||||||
(let ((processing-type (plist-get info :with-latex))
|
(let ((processing-type t) ;; (plist-get info :with-latex)
|
||||||
(latex-frag (org-remove-indentation
|
(latex-frag (org-remove-indentation
|
||||||
(org-element-property :value latex-environment)))
|
(org-element-property :value latex-environment)))
|
||||||
(label (org-rst--reference latex-environment info t))
|
(label (org-rst--reference latex-environment info t))
|
||||||
@@ -1078,8 +1121,8 @@ information."
|
|||||||
(org-export-get-ordinal
|
(org-export-get-ordinal
|
||||||
latex-environment info nil
|
latex-environment info nil
|
||||||
(lambda (l _)
|
(lambda (l _)
|
||||||
(and (org-html--math-environment-p l)
|
(and (org-rst--math-environment-p l)
|
||||||
(org-html--latex-environment-numbered-p l))))))))
|
(org-rst--latex-environment-numbered-p l))))))))
|
||||||
(when processing-type
|
(when processing-type
|
||||||
;; latex-frag
|
;; latex-frag
|
||||||
(org-rst--wrap-latex-environment latex-frag info caption label))))
|
(org-rst--wrap-latex-environment latex-frag info caption label))))
|
||||||
@@ -1167,8 +1210,8 @@ INFO is a plist holding contextual information."
|
|||||||
(link-org-files-as-rst-maybe
|
(link-org-files-as-rst-maybe
|
||||||
(function
|
(function
|
||||||
(lambda (raw-path info)
|
(lambda (raw-path info)
|
||||||
"Treat links to `file.org' as links to `file.rst', if needed.
|
;; Treat links to `file.org' as links to `file.rst', if
|
||||||
See `org-rst-link-org-files-as-rst'."
|
;; needed. See `org-rst-link-org-files-as-rst'.
|
||||||
(cond
|
(cond
|
||||||
((and (plist-get info :rst-link-org-files-as-rst)
|
((and (plist-get info :rst-link-org-files-as-rst)
|
||||||
(string= ".org"
|
(string= ".org"
|
||||||
@@ -1272,8 +1315,16 @@ INFO is a plist holding contextual information."
|
|||||||
(format "`%s`_" (org-rst--build-title destination info nil))))
|
(format "`%s`_" (org-rst--build-title destination info nil))))
|
||||||
;; Fuzzy link points to a target.
|
;; Fuzzy link points to a target.
|
||||||
(otherwise
|
(otherwise
|
||||||
|
(if (and destination
|
||||||
|
(org-element-type-p destination 'latex-environment)
|
||||||
|
(eq 'math (org-latex--environment-type destination)))
|
||||||
|
;; Caption and labels are introduced within LaTeX
|
||||||
|
;; environment. Use "ref" or "eqref" macro, depending on user
|
||||||
|
;; preference to refer to those in the document.
|
||||||
|
(format (plist-get info :rst-equation-reference-format)
|
||||||
|
(org-rst--reference destination info))
|
||||||
(if (not desc) (format "`%s`_" raw-path)
|
(if (not desc) (format "`%s`_" raw-path)
|
||||||
(format "`%s <%s>`_" desc raw-path))))))
|
(format "`%s <%s>`_" desc raw-path)))))))
|
||||||
;; Coderef: replace link with the reference name or the
|
;; Coderef: replace link with the reference name or the
|
||||||
;; equivalent line number. It is not supported in ReST.
|
;; equivalent line number. It is not supported in ReST.
|
||||||
((string= type "coderef")
|
((string= type "coderef")
|
||||||
@@ -1287,8 +1338,8 @@ INFO is a plist holding contextual information."
|
|||||||
(format ":ref:`%s <%s>`" desc ref)
|
(format ":ref:`%s <%s>`" desc ref)
|
||||||
(format ":ref:`%s`" ref))))
|
(format ":ref:`%s`" ref))))
|
||||||
;; Link type is handled by a special function.
|
;; Link type is handled by a special function.
|
||||||
;((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
|
;; ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
|
||||||
; (funcall protocol (org-link-unescape path) desc 'latex))
|
;; (funcall protocol (org-link-unescape path) desc 'latex))
|
||||||
;; External link with a description part.
|
;; External link with a description part.
|
||||||
((and path desc) (format "`%s <%s>`_" desc path))
|
((and path desc) (format "`%s <%s>`_" desc path))
|
||||||
;; External link without a description part.
|
;; External link without a description part.
|
||||||
|
|||||||
Reference in New Issue
Block a user