Hi all,
I'm currently trying to build a small package `org-inline-block` that aims to provide a simple syntax for blocks (without begin/end) based on indentation (like plain lists). While it would be cleaner to properly extend `org-element` for the export part, I only plan to add a function to '`org-export-filter-body-functions`.
Here comes the function (simplified version that isolates the problem):
(defun org-latex-inline-block (text backend info)
"Manage inline block in LaTeX export, as part of body."
(when (org-export-derived-backend-p backend 'latex)
(let ((case-fold-search nil))
(replace-regexp-in-string
"\\([ \t]*\\)\\(\\(Question\\)\\( (\\([^()]*\\))\\)?\\.\\)\\(\\(.*$\\)\\([\n]\\(\\1[\t ]+.*\\)?\\)*\\)"
(lambda (substr) (format "\\begin{question}%s\\end{question}"
(org-inline-block-get-core substr)))
text nil t))))
with
(defun org-inline-block-get-core (s)
"Given >Question. abcde<, return >abcde<"
(let ((case-fold-search nil))
(string-match "Question\\( ([^()]*)\\)?\\. " s)
(if (> (match-end 0) 0) (substring s (match-end 0)) "")))
Here comes the unexpected behavior: if I try to export "Question. Where is Brian?", it will be exported to "\begin{question} Where is Brian? \end{question} **Where is Brian?** ", and I can't guess where this duplicate comes from... Any idea ?