emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Raw Org AST snippets for "impossible" markup


From: Juan Manuel Macías
Subject: Re: Raw Org AST snippets for "impossible" markup
Date: Thu, 09 Dec 2021 22:27:08 +0000

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? Maybe something like "(i::"
instead of "(italic () ..."? I came up with this hasty sketch over your
latest code, *just* to see how it looks (I don't know if I prefer it to
stay verbose):

#+begin_src emacs-lisp :results silent
 (setq orgia-alias-alist '(("i" "italic")
                           ("b" "bold")
                           ("u" "underline")
                           ("s" "strike-through")))

  (defun orgia-replace (before after)
    (interactive)
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward before nil t)
        (replace-match after t nil))))

  (defun orgia--transform-path (path)
    (with-temp-buffer
      (insert path)
      (mapc (lambda (el)
              (orgia-replace (concat "(" (car el) "::") (concat "(" (cadr el) " 
() ")))
            orgia-alias-alist)
      (buffer-string)))

  (defun orgia--transform-link (data)
    (if (not (string-equal "orgia" (org-element-property :type data)))
        data
      (let* ((path (org-element-property :path data)))
        (if (not (eq ?\( (aref path 0)))
            (or path (org-element-contents data))
          (read (orgia--transform-path path)))))) ;; <====
    ;;;;;;;;;;;;;;;;;;
 #+end_src

#+begin_src elisp
   (org-export-string-as "An <orgia:(\"in\" (s:: \"ter\"))>word"
'odt t)
#+end_src

#+RESULTS:
: 
: <text:p text:style-name="Text_20_body">An in<text:span 
text:style-name="Strikethrough">ter</text:span>word</text:p>


#+begin_src org :results latex :results replace
  [[orgia:(i:: "The English versions of the " (b:: (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


------------------------------------------------------
Juan Manuel Macías 

https://juanmanuelmacias.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]