0

I want to have intra-word font changes in org mode -- eg. "Teacher vs teaching" -- works fine here in SE markdown. Doesn't in org.

There is this old question. Is it possible to combine two answers there? I want to use user81065's use of zero width space along with itsjeyd's suggestion to tweak org-emphasis-regexp-components. This is for org mode export in general. ie I'd rather avoid latex/html/odt specific methods (as some other answers suggest) and stick to pure org to work with any back-end.

Basically using zero width space shows as an ugly grey blob in odt export. Can we use the regexp-components to recognize the zero width space as a delimiter and then throw it away?

4
  • Please clarify the question, to cover what's needed from the other question. It's not clear just what you're doing. Where & when do you want these "font changes" - when doing what?
    – Drew
    Jul 9 at 15:38
  • I don't know but what's not clear. Anyways added an extra line in 1st & 2nd para
    – Rusi
    Jul 9 at 16:36
  • In LibreOffice, disable Menu Bar -> View -> Field Shadings. The "ugly grey blob" will go away. IOW, you have configured LIbreOffice to alert you about the presence of these characters, which are "normally" invisible. Jul 10 at 3:03
  • @whitetrillium One typically uses odt (doc) export to send the document to some vanilla non emacs user. So I don't merely ZWSP to dissappear; it should not be present -- just as org "disappears" stars #+BEGIN_XYZ and much else. IOW the ZWSP is an org-artifact not document-content
    – Rusi
    Jul 10 at 3:29

1 Answer 1

1

To get this

Intra-word emphasis using Zero Width Space

export the org snippet below after eval-ling the setup code.

(Note that both the setup code and org snippet have ZERO WIDTH SPACES and you CANNOT SEE these either in this stackexchange post or in your Emacs buffer. The fontification in Emacs buffer will give you a clue where the ZERO WIDTH SPACE characters are)

#+options: author:nil broken-links:nil c:nil creator:nil
#+title: Intra-word emphasis using Zero Width Spaces

Teach​*er* vs teach​*ing*

/Method/​-s and =Class=​es

- HiDPI :: *Hi*​gh *D*​ots *P*​er *I*​nch

#+begin_src emacs-lisp :exports results
  ;; Tell `whitespace-mode' that we are only interested
  ;; in ZERO WIDTH SPACE chars

  (custom-set-variables
   '(whitespace-display-mappings
     '((space-mark 8203
           [8857])))
   '(whitespace-space-regexp "\\(​+\\)")
   '(whitespace-style
     '(face spaces space-mark)))

  (custom-set-faces
   '(whitespace-space
     ((t
       (:background "yellow" :foreground "firebrick")))))

  ;; Put the `org' buffer in `whitespace-mode', so that we can 
  (whitespace-mode +1)

  ;; Use `C-x r i SPC' to insert ZERO WIDTH SPACE easily
  (set-register ?  "​")

  ;; Remove ZERO WIDTH SPACE from output
  (require 'ox)
  (add-to-list
   'org-export-filter-final-output-functions
   (defun my-org-export-filter-plain-text-functions
       (text backend _info)
     (replace-regexp-in-string "​" "" text t t)))

  ;; Report `org' version
  (format "Demo-ed with `Org-%s'" org-version)
#+end_src


Here I have extracted the setup emacs-lisp code separately


;; Tell `whitespace-mode' that we are only interested
;; in ZERO WIDTH SPACE chars
(custom-set-variables
 '(whitespace-display-mappings
   '((space-mark 8203
                 [8857])))
 '(whitespace-space-regexp "\\(​+\\)")
 '(whitespace-style
   '(face spaces space-mark)))

(custom-set-faces
 '(whitespace-space
   ((t
     (:background "yellow" :foreground "firebrick")))))

;; Put the `org' buffer in `whitespace-mode', so that we can 
(whitespace-mode +1)

;; Use `C-x r i SPC' to insert ZERO WIDTH SPACE easily
(set-register ?  "​")

;; Remove ZERO WIDTH SPACE from output
(require 'ox)
(add-to-list
 'org-export-filter-final-output-functions
 (defun my-org-export-filter-plain-text-functions
     (text backend _info)
   (replace-regexp-in-string "​" "" text t t)))

;; Report `org' version
(format "Demo-ed with `Org-%s'" org-version)


2
  • I guess the last 8-10 lines is what I'm looking for. The rest as I mentioned (other comment) is potentially useful but not quite my use case. I need to get onto a machine and try (bit later)
    – Rusi
    Jul 10 at 3:39
  • The last require... and add-to-list... seem to have worked -- Thanks! For now +1. [I only eval-ed that much] If you make that the main part of the answer (and the rest as auxiliary for those who may want) I'll accept as well. Thanks again!
    – Rusi
    Jul 10 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.