patch ox-rst to add caption for code-block
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
||||||
|
- create the patch using git
|
||||||
|
git diff lisp/ob-core.el > $HOME/.config/emacs/lisp/0patches/org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
||||||
- apply patch
|
- apply patch
|
||||||
patch -d "$HOME/.config/emacs/lisp/org" -p1 -i $HOME/.config/emacs/lisp/0patches/org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
patch -d "$HOME/.config/emacs/lisp/org" -p1 -i $HOME/.config/emacs/lisp/0patches/org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
||||||
- reverse patch
|
- reverse patch
|
||||||
@@ -6,3 +8,11 @@ org-ob-core.el-add-ability-to-use-closures-as-default-header-args.patch
|
|||||||
- https://orgmode.org/list/87ftflikkc.fsf@gmail.com/t/
|
- https://orgmode.org/list/87ftflikkc.fsf@gmail.com/t/
|
||||||
- https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00464.html
|
- https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00464.html
|
||||||
- https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/txtzi_PffIaG1.txt
|
- https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/txtzi_PffIaG1.txt
|
||||||
|
|
||||||
|
ox-rst_ox-rst.el_add-code-block-caption.patch
|
||||||
|
- create the patch using git
|
||||||
|
git diff lisp/ox-rst/ox-rst.el >lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch
|
||||||
|
- apply patch
|
||||||
|
patch -d . -p1 -i lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch
|
||||||
|
- reverse patch
|
||||||
|
patch -R -d . -p1 -i lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch
|
||||||
|
|||||||
45
lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch
Normal file
45
lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
diff --git a/lisp/ox-rst/ox-rst.el b/lisp/ox-rst/ox-rst.el
|
||||||
|
index 1d66f88d..fc423eac 100644
|
||||||
|
--- a/lisp/ox-rst/ox-rst.el
|
||||||
|
+++ b/lisp/ox-rst/ox-rst.el
|
||||||
|
@@ -1319,8 +1319,11 @@ holding contextual information."
|
||||||
|
"Transcode a SRC-BLOCK element from Org to reStructuredText.
|
||||||
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
||||||
|
contextual information."
|
||||||
|
+ ;; code is for inline within text
|
||||||
|
+ ;; code-block (or the alias sourcecode) are for a separate block
|
||||||
|
(when (org-string-nw-p (org-element-property :value src-block))
|
||||||
|
(let* ((lang (org-element-property :language src-block))
|
||||||
|
+ (caption (org-export-get-caption src-block))
|
||||||
|
(label (org-element-property :name src-block))
|
||||||
|
(value (org-remove-indentation
|
||||||
|
(org-element-property :value src-block)))
|
||||||
|
@@ -1330,7 +1333,7 @@ contextual information."
|
||||||
|
(org-export-read-attribute :attr_rst src-block))
|
||||||
|
(class (plist-get attributes :class)))
|
||||||
|
(cond
|
||||||
|
- ;; Case 1.
|
||||||
|
+ ;; Case 1. code-block directive.
|
||||||
|
((eq codeblockd 'code-block)
|
||||||
|
(let ((lst-lang
|
||||||
|
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
||||||
|
@@ -1339,9 +1342,10 @@ contextual information."
|
||||||
|
(when num-start (format " :lineno-start: %s\n" (1+ num-start)))
|
||||||
|
(when class (format " :class: %s\n" class))
|
||||||
|
(when label (format " :name: %s\n" label))
|
||||||
|
+ (when caption (format " :caption: %s\n" (org-export-data caption info)))
|
||||||
|
"\n"
|
||||||
|
(org-rst--indent-string value org-rst-quote-margin))))
|
||||||
|
- ;; Case 2. code.
|
||||||
|
+ ;; Case 2. code directive.
|
||||||
|
((eq codeblockd 'code)
|
||||||
|
(let ((lst-lang
|
||||||
|
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
||||||
|
@@ -1352,6 +1356,7 @@ contextual information."
|
||||||
|
(when label (format " :name: %s\n" label))
|
||||||
|
"\n"
|
||||||
|
(org-rst--indent-string value org-rst-quote-margin))))
|
||||||
|
+ ;; Case 3. literal block.
|
||||||
|
(t
|
||||||
|
(concat
|
||||||
|
"::\n"
|
||||||
@@ -1319,8 +1319,11 @@ holding contextual information."
|
|||||||
"Transcode a SRC-BLOCK element from Org to reStructuredText.
|
"Transcode a SRC-BLOCK element from Org to reStructuredText.
|
||||||
CONTENTS holds the contents of the item. INFO is a plist holding
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
||||||
contextual information."
|
contextual information."
|
||||||
|
;; code is for inline within text
|
||||||
|
;; code-block (or the alias sourcecode) are for a separate block
|
||||||
(when (org-string-nw-p (org-element-property :value src-block))
|
(when (org-string-nw-p (org-element-property :value src-block))
|
||||||
(let* ((lang (org-element-property :language src-block))
|
(let* ((lang (org-element-property :language src-block))
|
||||||
|
(caption (org-export-get-caption src-block))
|
||||||
(label (org-element-property :name src-block))
|
(label (org-element-property :name src-block))
|
||||||
(value (org-remove-indentation
|
(value (org-remove-indentation
|
||||||
(org-element-property :value src-block)))
|
(org-element-property :value src-block)))
|
||||||
@@ -1330,7 +1333,7 @@ contextual information."
|
|||||||
(org-export-read-attribute :attr_rst src-block))
|
(org-export-read-attribute :attr_rst src-block))
|
||||||
(class (plist-get attributes :class)))
|
(class (plist-get attributes :class)))
|
||||||
(cond
|
(cond
|
||||||
;; Case 1.
|
;; Case 1. code-block directive.
|
||||||
((eq codeblockd 'code-block)
|
((eq codeblockd 'code-block)
|
||||||
(let ((lst-lang
|
(let ((lst-lang
|
||||||
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
||||||
@@ -1339,9 +1342,10 @@ contextual information."
|
|||||||
(when num-start (format " :lineno-start: %s\n" (1+ num-start)))
|
(when num-start (format " :lineno-start: %s\n" (1+ num-start)))
|
||||||
(when class (format " :class: %s\n" class))
|
(when class (format " :class: %s\n" class))
|
||||||
(when label (format " :name: %s\n" label))
|
(when label (format " :name: %s\n" label))
|
||||||
|
(when caption (format " :caption: %s\n" (org-export-data caption info)))
|
||||||
"\n"
|
"\n"
|
||||||
(org-rst--indent-string value org-rst-quote-margin))))
|
(org-rst--indent-string value org-rst-quote-margin))))
|
||||||
;; Case 2. code.
|
;; Case 2. code directive.
|
||||||
((eq codeblockd 'code)
|
((eq codeblockd 'code)
|
||||||
(let ((lst-lang
|
(let ((lst-lang
|
||||||
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
(or (cadr (assq (intern lang) org-rst-pygments-langs)) lang)))
|
||||||
@@ -1352,6 +1356,7 @@ contextual information."
|
|||||||
(when label (format " :name: %s\n" label))
|
(when label (format " :name: %s\n" label))
|
||||||
"\n"
|
"\n"
|
||||||
(org-rst--indent-string value org-rst-quote-margin))))
|
(org-rst--indent-string value org-rst-quote-margin))))
|
||||||
|
;; Case 3. literal block.
|
||||||
(t
|
(t
|
||||||
(concat
|
(concat
|
||||||
"::\n"
|
"::\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user