[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Raw Org AST snippets for "impossible" markup
From: |
Max Nikulin |
Subject: |
Re: Raw Org AST snippets for "impossible" markup |
Date: |
Mon, 3 Jan 2022 21:34:16 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
On 10/12/2021 05:27, Juan Manuel Macías wrote:
Juan Manuel Macías writes:
Jumping into the "real world", how about these two examples of nested emphasis?
By the way, what do you think about allowing the use of some kind of
aliases, so that the aspect is less verbose?
I have no particular opinion concerning aliases, but certainly they
should not work through string search and replace when parsed tree is
available.
(defun orgia--transform-path (path)
(with-temp-buffer
(insert path)
(mapc (lambda (el)
(orgia-replace (concat "(" (car el) "::") (concat "(" (cadr el) " ()
")))
By the way, is there any problem with `replace-regexp-in-string'?
See the attached file for definitions of some helper functions. Final setup:
#+begin_src elisp :results silent
(setq orgia-demo-alias-alist
'((b . bold)
(i . italic)
(s . strike-through)
(_ . underline)))
(defun orgia-demo-alias-post-filter (node &optional _children)
(when (listp node)
(let ((sym (and (symbolp (car node))
(assq (car node) orgia-demo-alias-alist))))
(when sym
(setcar node (cdr sym)))))
node)
(defun orgia-demo-alias (tree)
(orgia-transform-tree-deep tree nil #'orgia-demo-alias-post-filter))
#+end_src
#+begin_src elisp :results silent
(require 'ox)
(add-to-list 'org-export-filter-parse-tree-functions
#'orgia-parse-tree-filter)
(org-link-set-parameters "orgia")
(require 'ob-org)
(add-to-list 'orgia-transform-functions #'orgia-demo-alias)
#+end_src
And a bit modified your test sample:
#+begin_src org :results latex :results replace
[[orgia:(i nil "The English versions of the " (b nil (i () "Iliad"))
" and the " (b () (i ()
"Odyssey")))]]
#+end_src
#+RESULTS:
#+begin_export latex
\emph{The English versions of the \textbf{\emph{Iliad}} and the
\textbf{\emph{Odyssey}}}
#+end_export
orgia-draft.el
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Raw Org AST snippets for "impossible" markup,
Max Nikulin <=