Separated phonetics generation and org formatting

This commit is contained in:
Lucien Cartier-Tilet 2020-05-01 22:58:33 +02:00
parent b9fff85970
commit cd94dc0011
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -336,8 +336,7 @@ Arguments:
(defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant (defun conlanging/nyqy-to-phonetics (t-text &optional t-nyqy t-phonetics t-met-consonant
t-dorsal) t-dorsal)
"Returns the phonetics equivalent of the Ñyqy `t-text', either "Returns the phonetics equivalent of the Ñyqy `t-text'.
as a tooltip in HTML or plain text for LaTeX exports.
Arguments: Arguments:
- `t-text': text to convert to phonetics - `t-text': text to convert to phonetics
@ -350,20 +349,18 @@ Arguments:
is required to be dorsal, `nil' otherwise" is required to be dorsal, `nil' otherwise"
(interactive) (interactive)
(cond (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 (conlanging/nyqy-to-phonetics t-text
(split-string (downcase t-text) (split-string (downcase t-text) "" t)
""
t)
"")) ""))
((eq nil t-nyqy) ;; no more to convert
(progn ;; no more to convert
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@" ((eq nil t-nyqy)
"@@latex:\\textit{%s} (/%s/)@@") t-phonetics)
t-text
t-phonetics ;; default option
t-text
t-phonetics)))
(t (let* ((cur-char (car t-nyqy)) ;; default option (t (let* ((cur-char (car t-nyqy)) ;; default option
(cur-phon (seq-find (lambda (elt) (cur-phon (seq-find (lambda (elt)
(string= (car elt) (string= (car elt)
@ -387,3 +384,19 @@ Arguments:
(conlanging//nyqy-get-phoneme cur-phon nil)) (conlanging//nyqy-get-phoneme cur-phon nil))
t-met-consonant t-met-consonant
t-dorsal)))))) 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:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
"@@latex:\\textit{%s} (/%s/)@@")
text
phonetics
text
phonetics)))