From cd94dc00119b9bbe77897f49e44d4dec498c32fe Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 1 May 2020 22:58:33 +0200 Subject: [PATCH] Separated phonetics generation and org formatting --- funcs.el | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/funcs.el b/funcs.el index 0a7e601..8476fd9 100644 --- a/funcs.el +++ b/funcs.el @@ -336,8 +336,7 @@ Arguments: (defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant t-dorsal) - "Returns the phonetics equivalent of the Ñyqy `t-text', either -as a tooltip in HTML or plain text for LaTeX exports. + "Returns the phonetics equivalent of the Ñyqy `t-text'. Arguments: - `t-text': text to convert to phonetics @@ -350,20 +349,18 @@ Arguments: is required to be dorsal, `nil' otherwise" (interactive) (cond - ((eq nil t-phonetics) ;; first call to the function + + ;; first call to the function + ((eq nil t-phonetics) (conlanging/nyqy-to-phonetics t-text - (split-string (downcase t-text) - "" - t) + (split-string (downcase t-text) "" t) "")) - ((eq nil t-nyqy) ;; no more to convert - (progn - (format (concat "@@html:%s/%s/@@" - "@@latex:\\textit{%s} (/%s/)@@") - t-text - t-phonetics - t-text - t-phonetics))) + + ;; no more to convert + ((eq nil t-nyqy) + t-phonetics) + + ;; default option (t (let* ((cur-char (car t-nyqy)) ;; default option (cur-phon (seq-find (lambda (elt) (string= (car elt) @@ -387,3 +384,19 @@ Arguments: (conlanging//nyqy-get-phoneme cur-phon nil)) t-met-consonant t-dorsal)))))) + +(defun conlanging/nyqy-to-org (t-text) + "Returns the phonetics equivalent of the Ñygy `t-text' properly +formatted for org so it gets exported as a tooltip in HTML or as +LaTeX code for LaTeX exports. + +Arguments: +- `t-text': text to convert to phonetics" + (let ((phonetics (conlanging/nyqy-to-phonetics t-text)) + (text t-text)) + (format (concat "@@html:%s/%s/@@" + "@@latex:\\textit{%s} (/%s/)@@") + text + phonetics + text + phonetics)))