ox-org.el 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ;;; ox-org.el --- Org Back-End for Org Export Engine
  2. ;; Copyright (C) 2013 Free Software Foundation, Inc.
  3. ;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
  4. ;; Keywords: org, wp
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;; This library implements an Org back-end for Org exporter. Since
  17. ;; its usage is mainly internal, it doesn't provide any interactive
  18. ;; function.
  19. ;;; Code:
  20. (require 'ox)
  21. (org-export-define-backend org
  22. ((babel-call . org-org-identity)
  23. (bold . org-org-identity)
  24. (center-block . org-org-identity)
  25. (clock . org-org-identity)
  26. (code . org-org-identity)
  27. (comment . (lambda (&rest args) ""))
  28. (comment-block . (lambda (&rest args) ""))
  29. (diary-sexp . org-org-identity)
  30. (drawer . org-org-identity)
  31. (dynamic-block . org-org-identity)
  32. (entity . org-org-identity)
  33. (example-block . org-org-identity)
  34. (fixed-width . org-org-identity)
  35. (footnote-definition . org-org-identity)
  36. (footnote-reference . org-org-identity)
  37. (headline . org-org-headline)
  38. (horizontal-rule . org-org-identity)
  39. (inline-babel-call . org-org-identity)
  40. (inline-src-block . org-org-identity)
  41. (inlinetask . org-org-identity)
  42. (italic . org-org-identity)
  43. (item . org-org-identity)
  44. (keyword . org-org-keyword)
  45. (latex-environment . org-org-identity)
  46. (latex-fragment . org-org-identity)
  47. (line-break . org-org-identity)
  48. (link . org-org-identity)
  49. (node-property . org-org-identity)
  50. (paragraph . org-org-identity)
  51. (plain-list . org-org-identity)
  52. (planning . org-org-identity)
  53. (property-drawer . org-org-identity)
  54. (quote-block . org-org-identity)
  55. (quote-section . org-org-identity)
  56. (radio-target . org-org-identity)
  57. (section . org-org-identity)
  58. (special-block . org-org-identity)
  59. (src-block . org-org-identity)
  60. (statistics-cookie . org-org-identity)
  61. (strike-through . org-org-identity)
  62. (subscript . org-org-identity)
  63. (superscript . org-org-identity)
  64. (table . org-org-identity)
  65. (table-cell . org-org-identity)
  66. (table-row . org-org-identity)
  67. (target . org-org-identity)
  68. (timestamp . org-org-identity)
  69. (underline . org-org-identity)
  70. (verbatim . org-org-identity)
  71. (verse-block . org-org-identity)))
  72. (defun org-org-identity (blob contents info)
  73. "Transcode BLOB element or object back into Org syntax."
  74. (funcall
  75. (intern (format "org-element-%s-interpreter" (org-element-type blob)))
  76. blob contents))
  77. (defun org-org-headline (headline contents info)
  78. "Transcode HEADLINE element back into Org syntax."
  79. (unless (plist-get info :with-todo-keywords)
  80. (org-element-put-property headline :todo-keyword nil))
  81. (unless (plist-get info :with-tags)
  82. (org-element-put-property headline :tags nil))
  83. (unless (plist-get info :with-priority)
  84. (org-element-put-property headline :priority nil))
  85. (org-element-headline-interpreter headline contents))
  86. (defun org-org-keyword (keyword contents info)
  87. "Transcode KEYWORD element back into Org syntax.
  88. Ignore keywords targeted at other export back-ends."
  89. (unless (member (org-element-property :key keyword)
  90. (mapcar
  91. (lambda (block-cons)
  92. (and (eq (cdr block-cons) 'org-element-export-block-parser)
  93. (car block-cons)))
  94. org-element-block-name-alist))
  95. (org-element-keyword-interpreter keyword nil)))
  96. ;;;###autoload
  97. (defun org-org-publish-to-org (plist filename pub-dir)
  98. "Publish an org file to org.
  99. FILENAME is the filename of the Org file to be published. PLIST
  100. is the property list for the given project. PUB-DIR is the
  101. publishing directory.
  102. Return output file name."
  103. (org-publish-org-to 'org filename ".org" plist pub-dir))
  104. (provide 'ox-org)
  105. ;; Local variables:
  106. ;; generated-autoload-file: "org-loaddefs.el"
  107. ;; End:
  108. ;;; ox-org.el ends here