diff --git a/org-conlang.el b/org-conlang.el new file mode 100644 index 0000000..13e3bb4 --- /dev/null +++ b/org-conlang.el @@ -0,0 +1,39 @@ +;;; org-conlang.el --- Tools for my conlanging websites written in org -*- lexical-binding: t -*- + +;; Author: Lucien Cartier-Tilet +;; Maintainer: Lucien Cartier-Tilet +;; Version: 0.1.0 +;; Package-Requires: ((emacs "26.1") (org-mode "9.5")) +;; Homepage: homepage +;; Keywords: keywords + + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: + +;; commentary + +;;; Code: + +(require 'ol-conlang) +(require 'ox-conlang-json) +(require 'ox-conlang-md) + +(provide 'org-conlang) + +;;; org-conlang.el ends here diff --git a/ox-conlang-json.el b/ox-conlang-json.el new file mode 100644 index 0000000..5278fe0 --- /dev/null +++ b/ox-conlang-json.el @@ -0,0 +1,125 @@ +;;; ox-conlang-json.el --- Export conlang dictionaries to JSON -*- lexical-binding: t -*- + +;; Author: Lucien Cartier-Tilet +;; Maintainer: Lucien Cartier-Tilet +;; Version: 0.1.0 +;; Package-Requires: ((emacs "26.1") (org-mode "9.5")) +;; Homepage: homepage +;; Keywords: outlines + + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: + +;; commentary + +;;; Code: + +(require 'ox-publish) +(require 'ox-md) + +(org-export-define-derived-backend 'conlang-json 'md + :menu-entry + '(?C 1 + ((?J "To temporary JSON buffer" + (lambda (a s v _) (org-conlang-json-export-as-json a s v))) + (?j "To JSON file" + (lambda (a s v _) (org-conlang-json-export-to-json a s v))) + (?O "To JSON and open" + (lambda (a s v b) + (if a (org-conlang-json-export-to-json t s v b) + (org-conlang-json-export-to-md nil s v b))))))) + + +;;; Interactive Functions + +;;;###autoload +(defun org-conlang-json-export-as-json (&optional async subtreep visible-only) + "Export current buffer to a Conlang flavored JSON buffer. + +If narrowing is active in the current buffer, only export its +narrowed part. + +If a region is active, export that region. + +A non-nil optional argument ASYNC means the process should happen +asynchronously. The resulting buffer should be accessible through +the `org-export-stack' interface. + +When optional argument SUBTREEP is non-nil, export the sub-tree +at point, extracting information from the headline properties +first. + +When optional argument VISIBLE-ONLY is non-nil, don't export +contents of hidden elements. + +Export is done in a buffer named \"*Org Conlang JSON Export*\", +which will be displayed when +`org-export-show-temporary-export-buffer' is non-nil." + (interactive) + (org-export-to-buffer 'conlang-tsx "*Org Conlang JSON Export*" + async subtreep visible-only nil nil (lambda () (text-mode)))) + +;;;###autoload +(defun org-conlang-json-convert-region-to-json () + "Assume the current region has org-mode syntax, and convert it to Conlang flavored JSON. + +This can be used in any buffer. For example, you can write an +itemized list in org-mode syntax in a JSON buffer and use this +command to convert it." + (interactive) + (org-export-replace-region-by 'conlang-json)) + + +;;;###autoload +(defun org-conlang-json-export-to-json (&optional async subtreep visible-only ext-plist) + "Export current buffer to a Conlang flavored JSON file. + +If narrowing is active in the current buffer, only export its +narrowed part. + +If a region is active, export that region. + +A non-nil optional argument ASYNC means the process should happen +asynchronously. The resulting file should be accessible through +the `org-export-stack' interface. + +When optional argument SUBTREEP is non-nil, export the sub-tree +at point, extracting information from the headline properties +first. + +When optional argument VISIBLE-ONLY is non-nil, don't export +contents of hidden elements. + +Return output file's name." + (interactive) + (let* ((outfile (org-export-output-file-name ".json" subtreep))) + (org-export-to-file 'conlang-json outfile async subtreep visible-only))) + +;;;###autoload +(defun org-conlang-json-publish-to-json (plist filename pub-dir) + "Publish an org file to Conlang JSON. +FILENAME is the filename of the Org file to be published. PLIST +is the property list for the given project. PUB-DIR is the +publishing directory. +Return output file name." + (org-publish-org-to 'conlang-json filename ".json" plist pub-dir)) + +(provide 'ox-conlang-json) + +;;; ox-conlang-json.el ends here diff --git a/ox-conlang-md.el b/ox-conlang-md.el new file mode 100644 index 0000000..43a061b --- /dev/null +++ b/ox-conlang-md.el @@ -0,0 +1,143 @@ +;;; ox-conlang-md.el --- Markdown exporter for Phundrak’s org websites -*- lexical-binding: t -*- + +;; Author: Lucien Cartier-Tilet +;; Maintainer: Lucien Cartier-Tilet +;; Version: 0.1.0 +;; Package-Requires: ((emacs "26") (org-mode "9.5")) +;; Homepage: https://labs.phundrak.com/phundrak/org-conlang +;; Keywords: outlines + + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: + +;; This package exports org files to a special Markdown format used by +;; Phundrak’s front-end for org-mode generated websites. + +;;; Code: + +(require 'ox-publish) +(require 'ox-md) + +(org-export-define-derived-backend 'conlang-md 'md + :menu-entry + '(?C "Conlang exporters" + ((?M "To temporary markdown buffer" + (lambda (a s v _) (org-conlang-md-export-as-md a s v))) + (?m "To markdown file" + (lambda (a s v _) (org-conlang-md-export-to-md a s v))) + (?o "To markdown and open" + (lambda (a s v b) + (if a (org-conlang-md-export-to-md t s v b) + (org-conlang-md-export-to-md nil s v b)))))) + :options-alist + '((:conlang-home "CONLANG-HOME" nil nil t) + (:conlang-logo "CONLANG-LOGO" nil nil t) + (:conlang-dictionary "CONLANG-DICTIONARY" nil nil t)) + :translate-alist + '((table . org-conlang-md-table))) + + +;;; Transcode Functions + +;; Tables +(defun org-conlang-md-table (datum _contents info) + "Wrap DATUM in a table component for Vue. +DATUM, and INFO are then passed on HTML’s converter." + (format "%s
" + (org-export-data-with-backend datum 'html info))) + + +;;; Interactive Functions + +;;;###autoload +(defun org-conlang-md-export-as-md (&optional async subtreep visible-only) + "Export current buffer to a Conlang flavored MD buffer. + +If narrowing is active in the current buffer, only export its +narrowed part. + +If a region is active, export that region. + +A non-nil optional argument ASYNC means the process should happen +asynchronously. The resulting buffer should be accessible through +the `org-export-stack' interface. + +When optional argument SUBTREEP is non-nil, export the sub-tree +at point, extracting information from the headline properties +first. + +When optional argument VISIBLE-ONLY is non-nil, don't export +contents of hidden elements. + +Export is done in a buffer named \"*Org Conlang MD Export*\", +which will be displayed when +`org-export-show-temporary-export-buffer' is non-nil." + (interactive) + (org-export-to-buffer 'conlang-tsx "*Org Conlang MD Export*" + async subtreep visible-only nil nil (lambda () (text-mode)))) + +;;;###autoload +(defun org-conlang-md-convert-region-to-md () + "Assume the current region has org-mode syntax, and convert it to Conlang flavored MD. + +This can be used in any buffer. For example, you can write an +itemized list in org-mode syntax in a MD buffer and use +this command to convert it." + (interactive) + (org-export-replace-region-by 'conlang-md)) + + +;;;###autoload +(defun org-conlang-md-export-to-md (&optional async subtreep visible-only ext-plist) + "Export current buffer to a Conlang flavored MD file. + +If narrowing is active in the current buffer, only export its +narrowed part. + +If a region is active, export that region. + +A non-nil optional argument ASYNC means the process should happen +asynchronously. The resulting file should be accessible through +the `org-export-stack' interface. + +When optional argument SUBTREEP is non-nil, export the sub-tree +at point, extracting information from the headline properties +first. + +When optional argument VISIBLE-ONLY is non-nil, don't export +contents of hidden elements. + +Return output file's name." + (interactive) + (let* ((outfile (org-export-output-file-name ".md" subtreep))) + (org-export-to-file 'conlang-md outfile async subtreep visible-only))) + +;;;###autoload +(defun org-conlang-md-publish-to-md (plist filename pub-dir) + "Publish an org file to Conlang MD. +FILENAME is the filename of the Org file to be published. PLIST +is the property list for the given project. PUB-DIR is the +publishing directory. +Return output file name." + (org-publish-org-to 'conlang-md filename ".md" plist pub-dir)) + + +(provide 'ox-conlang-md) + +;;; ox-conlang-md.el ends here