forked from mirrors/org-mode
org-export: Handle "\-" as a special string
* contrib/lisp/org-export.el (org-export-with-special-strings): Fix docstring. * contrib/lisp/org-e-ascii.el (org-e-ascii-plain-text): Remove soft hyphens. * contrib/lisp/org-e-latex.el (org-e-latex-plain-text): Handle soft hyphens.
This commit is contained in:
parent
4d789f4c30
commit
86b1be57b9
|
@ -1361,15 +1361,15 @@ contextual information."
|
||||||
(defun org-e-ascii-plain-text (text info)
|
(defun org-e-ascii-plain-text (text info)
|
||||||
"Transcode a TEXT string from Org to ASCII.
|
"Transcode a TEXT string from Org to ASCII.
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
(if (not (and (eq (plist-get info :ascii-charset) 'utf-8)
|
(if (not (plist-get info :with-special-strings)) text
|
||||||
(plist-get info :with-special-strings)))
|
(setq text (replace-regexp-in-string "\\\\-" "" text))
|
||||||
text
|
(if (not (eq (plist-get info :ascii-charset) 'utf-8)) text
|
||||||
;; Usual replacements in utf-8 with proper option set.
|
;; Usual replacements in utf-8 with proper option set.
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"\\.\\.\\." "…"
|
"\\.\\.\\." "…"
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"--" "–"
|
"--" "–"
|
||||||
(replace-regexp-in-string "---" "—" text)))))
|
(replace-regexp-in-string "---" "—" text))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Planning
|
;;;; Planning
|
||||||
|
|
|
@ -1885,14 +1885,18 @@ contextual information."
|
||||||
"Transcode a TEXT string from Org to LaTeX.
|
"Transcode a TEXT string from Org to LaTeX.
|
||||||
TEXT is the string to transcode. INFO is a plist holding
|
TEXT is the string to transcode. INFO is a plist holding
|
||||||
contextual information."
|
contextual information."
|
||||||
|
(let ((specialp (plist-get info :with-special-strings)))
|
||||||
;; Protect %, #, &, $, ~, ^, _, { and }.
|
;; Protect %, #, &, $, ~, ^, _, { and }.
|
||||||
(while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text)
|
(while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text)
|
||||||
(setq text
|
(setq text
|
||||||
(replace-match (format "\\%s" (match-string 2 text)) nil t text 2)))
|
(replace-match (format "\\%s" (match-string 2 text)) nil t text 2)))
|
||||||
;; Protect \
|
;; Protect \. If special strings are used, be careful not to
|
||||||
(setq text (replace-regexp-in-string
|
;; protect "\" in "\-" constructs.
|
||||||
"\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
|
(let ((symbols (if specialp "-%$#&{}~^_\\" "%$#&{}~^_\\")))
|
||||||
"$\\backslash$" text nil t 1))
|
(setq text
|
||||||
|
(replace-regexp-in-string
|
||||||
|
(format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols)
|
||||||
|
"$\\backslash$" text nil t 1)))
|
||||||
;; LaTeX into \LaTeX{} and TeX into \TeX{}.
|
;; LaTeX into \LaTeX{} and TeX into \TeX{}.
|
||||||
(let ((case-fold-search nil)
|
(let ((case-fold-search nil)
|
||||||
(start 0))
|
(start 0))
|
||||||
|
@ -1900,18 +1904,17 @@ contextual information."
|
||||||
(setq text (replace-match
|
(setq text (replace-match
|
||||||
(format "\\%s{}" (match-string 1 text)) nil t text)
|
(format "\\%s{}" (match-string 1 text)) nil t text)
|
||||||
start (match-end 0))))
|
start (match-end 0))))
|
||||||
;; Handle quotation marks
|
;; Handle quotation marks.
|
||||||
(setq text (org-e-latex--quotation-marks text info))
|
(setq text (org-e-latex--quotation-marks text info))
|
||||||
;; Convert special strings.
|
;; Convert special strings.
|
||||||
(when (plist-get info :with-special-strings)
|
(when specialp
|
||||||
(while (string-match (regexp-quote "...") text)
|
(setq text (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" text nil t)))
|
||||||
(setq text (replace-match "\\ldots{}" nil t text))))
|
|
||||||
;; Handle break preservation if required.
|
;; Handle break preservation if required.
|
||||||
(when (plist-get info :preserve-breaks)
|
(when (plist-get info :preserve-breaks)
|
||||||
(setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
|
(setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
|
||||||
text)))
|
text)))
|
||||||
;; Return value.
|
;; Return value.
|
||||||
text)
|
text))
|
||||||
|
|
||||||
|
|
||||||
;;;; Planning
|
;;;; Planning
|
||||||
|
|
|
@ -488,16 +488,16 @@ This option can also be set with the #+SELECT_TAGS: keyword."
|
||||||
:type '(repeat (string :tag "Tag")))
|
:type '(repeat (string :tag "Tag")))
|
||||||
|
|
||||||
(defcustom org-export-with-special-strings t
|
(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:
|
When this option is turned on, these strings will be exported as:
|
||||||
|
|
||||||
Org HTML LaTeX
|
Org HTML LaTeX UTF-8
|
||||||
-----+----------+--------
|
-----+----------+--------+-------
|
||||||
\\- ­ \\-
|
\\- ­ \\-
|
||||||
-- – --
|
-- – -- –
|
||||||
--- — ---
|
--- — --- —
|
||||||
... … \ldots
|
... … \\ldots …
|
||||||
|
|
||||||
This option can also be set with the #+OPTIONS line,
|
This option can also be set with the #+OPTIONS line,
|
||||||
e.g. \"-:nil\"."
|
e.g. \"-:nil\"."
|
||||||
|
|
Loading…
Reference in New Issue