diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el index ad0f1b3c5..5d3afae5b 100644 --- a/contrib/lisp/org-e-ascii.el +++ b/contrib/lisp/org-e-ascii.el @@ -1361,15 +1361,15 @@ contextual information." (defun org-e-ascii-plain-text (text info) "Transcode a TEXT string from Org to ASCII. INFO is a plist used as a communication channel." - (if (not (and (eq (plist-get info :ascii-charset) 'utf-8) - (plist-get info :with-special-strings))) - text - ;; Usual replacements in utf-8 with proper option set. - (replace-regexp-in-string - "\\.\\.\\." "…" - (replace-regexp-in-string - "--" "–" - (replace-regexp-in-string "---" "—" text))))) + (if (not (plist-get info :with-special-strings)) text + (setq text (replace-regexp-in-string "\\\\-" "" text)) + (if (not (eq (plist-get info :ascii-charset) 'utf-8)) text + ;; Usual replacements in utf-8 with proper option set. + (replace-regexp-in-string + "\\.\\.\\." "…" + (replace-regexp-in-string + "--" "–" + (replace-regexp-in-string "---" "—" text)))))) ;;;; Planning diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el index f2b8e9230..f67b523e8 100644 --- a/contrib/lisp/org-e-latex.el +++ b/contrib/lisp/org-e-latex.el @@ -1885,33 +1885,36 @@ contextual information." "Transcode a TEXT string from Org to LaTeX. TEXT is the string to transcode. INFO is a plist holding contextual information." - ;; Protect %, #, &, $, ~, ^, _, { and }. - (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text) - (setq text - (replace-match (format "\\%s" (match-string 2 text)) nil t text 2))) - ;; Protect \ - (setq text (replace-regexp-in-string - "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)" - "$\\backslash$" text nil t 1)) - ;; LaTeX into \LaTeX{} and TeX into \TeX{}. - (let ((case-fold-search nil) - (start 0)) - (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" text start) - (setq text (replace-match - (format "\\%s{}" (match-string 1 text)) nil t text) - start (match-end 0)))) - ;; Handle quotation marks - (setq text (org-e-latex--quotation-marks text info)) - ;; Convert special strings. - (when (plist-get info :with-special-strings) - (while (string-match (regexp-quote "...") text) - (setq text (replace-match "\\ldots{}" nil t text)))) - ;; Handle break preservation if required. - (when (plist-get info :preserve-breaks) - (setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" - text))) - ;; Return value. - text) + (let ((specialp (plist-get info :with-special-strings))) + ;; Protect %, #, &, $, ~, ^, _, { and }. + (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text) + (setq text + (replace-match (format "\\%s" (match-string 2 text)) nil t text 2))) + ;; Protect \. If special strings are used, be careful not to + ;; protect "\" in "\-" constructs. + (let ((symbols (if specialp "-%$#&{}~^_\\" "%$#&{}~^_\\"))) + (setq text + (replace-regexp-in-string + (format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols) + "$\\backslash$" text nil t 1))) + ;; LaTeX into \LaTeX{} and TeX into \TeX{}. + (let ((case-fold-search nil) + (start 0)) + (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" text start) + (setq text (replace-match + (format "\\%s{}" (match-string 1 text)) nil t text) + start (match-end 0)))) + ;; Handle quotation marks. + (setq text (org-e-latex--quotation-marks text info)) + ;; Convert special strings. + (when specialp + (setq text (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" text nil t))) + ;; Handle break preservation if required. + (when (plist-get info :preserve-breaks) + (setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" + text))) + ;; Return value. + text)) ;;;; Planning diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 86fc10470..52874e202 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -488,16 +488,16 @@ This option can also be set with the #+SELECT_TAGS: keyword." :type '(repeat (string :tag "Tag"))) (defcustom org-export-with-special-strings t - "Non-nil means interpret \"\-\", \"--\" and \"---\" for export. + "Non-nil means interpret \"\\-\", \"--\" and \"---\" for export. When this option is turned on, these strings will be exported as: - Org HTML LaTeX - -----+----------+-------- - \\- ­ \\- - -- – -- - --- — --- - ... … \ldots + Org HTML LaTeX UTF-8 + -----+----------+--------+------- + \\- ­ \\- + -- – -- – + --- — --- — + ... … \\ldots … This option can also be set with the #+OPTIONS line, e.g. \"-:nil\"."