Allow using refs for project local links
Sphinx is using refs to project internal targets in other files. This patch convert org mode file links to such refs. Enabled via setting.
This commit is contained in:
14
ox-rst.el
14
ox-rst.el
@@ -98,6 +98,7 @@
|
|||||||
(: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-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-text-markup-alist nil nil org-rst-text-markup-alist)
|
(:rst-text-markup-alist nil nil org-rst-text-markup-alist)
|
||||||
(:rst-quote-margin nil nil org-rst-quote-margin)
|
(:rst-quote-margin nil nil org-rst-quote-margin)
|
||||||
(:rst-headline-underline-characters nil nil org-rst-headline-underline-characters)
|
(:rst-headline-underline-characters nil nil org-rst-headline-underline-characters)
|
||||||
@@ -185,6 +186,11 @@ link's path."
|
|||||||
:group 'org-export-rst
|
:group 'org-export-rst
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
|
(defcustom org-rst-file-link-use-ref-role nil
|
||||||
|
"Non-nil means export internal file links using :ref: role."
|
||||||
|
:group 'org-export-rst
|
||||||
|
:type 'boolean)
|
||||||
|
|
||||||
(defcustom org-rst-text-markup-alist '((bold . "**%s**")
|
(defcustom org-rst-text-markup-alist '((bold . "**%s**")
|
||||||
(code . verb)
|
(code . verb)
|
||||||
(italic . "*%s*")
|
(italic . "*%s*")
|
||||||
@@ -947,6 +953,7 @@ INFO is a plist holding contextual information."
|
|||||||
(plist-get info :rst-extension)))
|
(plist-get info :rst-extension)))
|
||||||
(t raw-path)))))
|
(t raw-path)))))
|
||||||
(type (org-element-property :type link))
|
(type (org-element-property :type link))
|
||||||
|
(search-option (org-element-property :search-option link))
|
||||||
(raw-path (org-element-property :path link))
|
(raw-path (org-element-property :path link))
|
||||||
;; Ensure DESC really exists, or set it to nil.
|
;; Ensure DESC really exists, or set it to nil.
|
||||||
(desc (and (not (string= desc "")) desc))
|
(desc (and (not (string= desc "")) desc))
|
||||||
@@ -1050,6 +1057,13 @@ INFO is a plist holding contextual information."
|
|||||||
((string= type "coderef")
|
((string= type "coderef")
|
||||||
(format (org-export-get-coderef-format path desc)
|
(format (org-export-get-coderef-format path desc)
|
||||||
(org-export-resolve-coderef path info)))
|
(org-export-resolve-coderef path info)))
|
||||||
|
((and (plist-get info :rst-file-link-use-ref-role)
|
||||||
|
(string= type "file")
|
||||||
|
search-option)
|
||||||
|
(let ((ref (replace-regexp-in-string "^#" "" search-option)))
|
||||||
|
(if desc
|
||||||
|
(format ":ref:`%s <%s>`" desc 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))
|
||||||
|
|||||||
Reference in New Issue
Block a user