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
1 changed files with 27 additions and 14 deletions

View File

@ -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:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
"@@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:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
"@@latex:\\textit{%s} (/%s/)@@")
text
phonetics
text
phonetics)))