Export back-ends: Install smart quotes module

* contrib/lisp/org-e-ascii.el (org-e-ascii-plain-text): Install smart
  quotes module.
* contrib/lisp/org-e-html.el (org-e-html-plain-text): Install smart
  quotes module.  Fix :preseve-breaks option.
(org-e-html--quotation-marks): Remove function.
(org-e-html-quotes): Remove variable.
* contrib/lisp/org-e-latex.el (org-e-latex-plain-text): Install smart
  quotes module.
(org-e-latex--quotation-marks): Remove function.
(org-e-latex-quotes): Remove variable.
* contrib/lisp/org-e-odt.el (org-e-odt-plain-text): Install smart
  quotes module.
(org-e-odt--quotation-marks): Remove function.
(org-e-odt-quotes): Remove variable.
* contrib/lisp/org-md.el (org-md-plain-text): Install smart quotes
  module.  Fix characters escaping.
* contrib/lisp/org-e-texinfo.el (org-e-texinfo-center-block,
  org-e-texinfo-special-block): new functions.
(org-e-texinfo-quotes): Remove variable.
(org-e-texinfo--quotations-marks): Remove function.
(org-e-texinfo-plain-text): Install smart quotes module.
* contrib/lisp/org-e-groff.el (org-e-groff-plain-text): Install smart
quotes module.  Fix line break preservation.
(org-e-groff--quotation-marks): Remove function.
(org-e-groff-quotes): Remove variable.
(org-e-groff-entity): Fix property name.
* contrib/lisp/org-e-man.el (org-e-man-entity): Fix property name.
(org-e-man-plain-text): Install smart quotes module.  Fix line break
preservation.
(org-e-man-quotes): Remove variable.
(org-e-man--quotation-marks): Remove function.
This commit is contained in:
Nicolas Goaziou 2012-10-27 00:36:00 +02:00
parent b2047a2565
commit f04a5bcea1
8 changed files with 142 additions and 436 deletions

View File

@ -1407,15 +1407,18 @@ 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 (plist-get info :with-special-strings)) text (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
(setq text (replace-regexp-in-string "\\\\-" "" text)) (when (and utf8p (plist-get info :with-smart-quotes))
(if (not (eq (plist-get info :ascii-charset) 'utf-8)) text (setq text (org-export-activate-smart-quotes text :utf-8 info)))
;; Usual replacements in utf-8 with proper option set. (if (not (plist-get info :with-special-strings)) text
(replace-regexp-in-string (setq text (replace-regexp-in-string "\\\\-" "" text))
"\\.\\.\\." "" (if (not utf8p) text
(replace-regexp-in-string ;; Usual replacements in utf-8 with proper option set.
"--" "" (replace-regexp-in-string
(replace-regexp-in-string "---" "" text)))))) "\\.\\.\\." ""
(replace-regexp-in-string
"--" ""
(replace-regexp-in-string "---" "" text)))))))
;;;; Planning ;;;; Planning

View File

@ -430,38 +430,6 @@ language.")
;;; Plain text ;;; Plain text
(defcustom org-e-groff-quotes
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "«~")
("\\(\\S-\\)\"" . "")
("\\(\\s-\\|(\\|^\\)'" . "'"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
("\\(\\S-\\)\"" . "''")
("\\(\\s-\\|(\\|^\\)'" . "`")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-groff
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
(defcustom org-e-groff-special-char (defcustom org-e-groff-special-char
'(("(c)" . "\\\\(co") '(("(c)" . "\\\\(co")
("(tm)" . "\\\\(tm") ("(tm)" . "\\\\(tm")
@ -553,20 +521,6 @@ For non-floats, see `org-e-groff--wrap-label'."
;; Standard caption format. ;; Standard caption format.
(t (format "\\fR%s\\fP" (org-export-data main info)))))) (t (format "\\fR%s\\fP" (org-export-data main info))))))
(defun org-e-groff--quotation-marks (text info)
"Export quotation marks depending on language conventions.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr (or (assoc (plist-get info :language) org-e-groff-quotes)
;; Falls back on English.
(assoc "en" org-e-groff-quotes))))
text)
(defun org-e-groff--wrap-label (element output) (defun org-e-groff--wrap-label (element output)
"Wrap label associated to ELEMENT around OUTPUT, if appropriate. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
This function shouldn't be used for floats. See This function shouldn't be used for floats. See
@ -919,7 +873,7 @@ holding contextual information. See `org-export-data'."
"Transcode an ENTITY object from Org to Groff. "Transcode an ENTITY object from Org to Groff.
CONTENTS are the definition itself. INFO is a plist holding CONTENTS are the definition itself. INFO is a plist holding
contextual information." contextual information."
(let ((ent (org-element-property :utf8 entity))) ent)) (org-element-property :utf-8 entity))
;;; Example Block ;;; Example Block
@ -1447,24 +1401,27 @@ contextual information."
"Transcode a TEXT string from Org to Groff. "Transcode a TEXT string from Org to Groff.
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."
;; Protect (let ((output text))
(setq text (replace-regexp-in-string ;; Protect various characters.
"\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)" (setq output (replace-regexp-in-string
"$\\" text nil t 1)) "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
;; Handle quotation marks "$\\" output nil t 1))
(setq text (org-e-groff--quotation-marks text info)) ;; Activate smart quotes. Be sure to provide original TEXT string
;; since OUTPUT may have been modified.
(when (plist-get info :with-smart-quotes)
(setq output (org-export-activate-smart-quotes output :utf-8 info text)))
;; Handle Special Characters ;; Handle Special Characters
(if org-e-groff-special-char (if org-e-groff-special-char
(dolist (special-char-list org-e-groff-special-char) (dolist (special-char-list org-e-groff-special-char)
(setq text (setq output
(replace-regexp-in-string (car special-char-list) (replace-regexp-in-string (car special-char-list)
(cdr special-char-list) text)))) (cdr special-char-list) output))))
;; 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 (setq output (replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" text))) "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n" output)))
;; Return value. ;; Return value.
text) output))
;;; Planning ;;; Planning

View File

@ -506,38 +506,6 @@ default we use here encompasses both."
:type '(repeat (cons (string :tag "Character") :type '(repeat (cons (string :tag "Character")
(string :tag "HTML equivalent")))) (string :tag "HTML equivalent"))))
(defcustom org-e-html-quotes
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "« ")
("\\(\\S-\\)\"" . " »")
("\\(\\s-\\|(\\|^\\)'" . "’"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "“")
("\\(\\S-\\)\"" . "”")
("\\(\\s-\\|(\\|^\\)'" . "‘")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-html
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
;;;; Src Block ;;;; Src Block
@ -1230,20 +1198,6 @@ Replaces invalid characters with \"_\"."
(date date) (date date)
(t (format-time-string "%Y-%m-%d %T %Z"))))) (t (format-time-string "%Y-%m-%d %T %Z")))))
(defun org-e-html--quotation-marks (text info)
"Export quotation marks depending on language conventions.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr (or (assoc (plist-get info :language) org-e-html-quotes)
;; Falls back on English.
(assoc "en" org-e-html-quotes))))
text)
;;; Template ;;; Template
@ -2402,19 +2356,23 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
"Transcode a TEXT string from Org to HTML. "Transcode a TEXT string from Org to HTML.
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."
;; Protect following characters: <, >, &. (let ((output text))
(setq text (org-e-html-encode-plain-text text)) ;; Protect following characters: <, >, &.
;; Handle quotation marks. (setq output (org-e-html-encode-plain-text output))
(setq text (org-e-html--quotation-marks text info)) ;; Handle smart quotes. Be sure to provide original string since
;; Handle special strings. ;; OUTPUT may have been modified.
(when (plist-get info :with-special-strings) (when (plist-get info :with-smart-quotes)
(setq text (org-e-html-convert-special-strings text))) (setq output (org-export-activate-smart-quotes output :html info text)))
;; Handle break preservation if required. ;; Handle special strings.
(when (plist-get info :preserve-breaks) (when (plist-get info :with-special-strings)
(setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" (setq output (org-e-html-convert-special-strings output)))
text))) ;; Handle break preservation if required.
;; Return value. (when (plist-get info :preserve-breaks)
text) (setq output
(replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
;; Return value.
output))
;; Planning ;; Planning

View File

@ -709,41 +709,6 @@ during latex export it will output
\\end{pythoncode}") \\end{pythoncode}")
;;;; Plain text
(defcustom org-e-latex-quotes
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "«~")
("\\(\\S-\\)\"" . "")
("\\(\\s-\\|(\\|^\\)'" . "'"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
("\\(\\S-\\)\"" . "''")
("\\(\\s-\\|(\\|^\\)'" . "`")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-latex
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
;;;; Compilation ;;;; Compilation
(defcustom org-e-latex-pdf-process (defcustom org-e-latex-pdf-process
@ -928,20 +893,6 @@ nil."
options options
",")) ","))
(defun org-e-latex--quotation-marks (text info)
"Export quotation marks depending on language conventions.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr (or (assoc (plist-get info :language) org-e-latex-quotes)
;; Falls back on English.
(assoc "en" org-e-latex-quotes))))
text)
(defun org-e-latex--wrap-label (element output) (defun org-e-latex--wrap-label (element output)
"Wrap label associated to ELEMENT around OUTPUT, if appropriate. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
This function shouldn't be used for floats. See This function shouldn't be used for floats. See
@ -1911,36 +1862,41 @@ 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))) (let ((specialp (plist-get info :with-special-strings))
(output text))
;; Protect %, #, &, $, ~, ^, _, { and }. ;; Protect %, #, &, $, ~, ^, _, { and }.
(while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text) (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" output)
(setq text (setq output
(replace-match (format "\\%s" (match-string 2 text)) nil t text 2))) (replace-match
(format "\\%s" (match-string 2 output)) nil t output 2)))
;; Protect \. If special strings are used, be careful not to ;; Protect \. If special strings are used, be careful not to
;; protect "\" in "\-" constructs. ;; protect "\" in "\-" constructs.
(let ((symbols (if specialp "-%$#&{}~^_\\" "%$#&{}~^_\\"))) (let ((symbols (if specialp "-%$#&{}~^_\\" "%$#&{}~^_\\")))
(setq text (setq output
(replace-regexp-in-string (replace-regexp-in-string
(format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols) (format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols)
"$\\backslash$" text nil t 1))) "$\\backslash$" output nil t 1)))
;; Activate smart quotes. Be sure to provide original TEXT string
;; since OUTPUT may have been modified.
(when (plist-get info :with-smart-quotes)
(setq output (org-export-activate-smart-quotes output :latex info text)))
;; 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))
(while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" text start) (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" output start)
(setq text (replace-match (setq output (replace-match
(format "\\%s{}" (match-string 1 text)) nil t text) (format "\\%s{}" (match-string 1 output)) nil t output)
start (match-end 0)))) start (match-end 0))))
;; Handle quotation marks.
(setq text (org-e-latex--quotation-marks text info))
;; Convert special strings. ;; Convert special strings.
(when specialp (when specialp
(setq text (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" text nil t))) (setq output
(replace-regexp-in-string "\\.\\.\\." "\\ldots{}" output nil t)))
;; 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 output (replace-regexp-in-string
text))) "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" output)))
;; Return value. ;; Return value.
text)) output))
;;;; Planning ;;;; Planning

View File

@ -205,44 +205,6 @@ during man export."
) )
;;; Plain text
(defcustom org-e-man-quotes
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "«~")
("\\(\\S-\\)\"" . "")
("\\(\\s-\\|(\\|^\\)'" . "'"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
("\\(\\S-\\)\"" . "''")
("\\(\\s-\\|(\\|^\\)'" . "`")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-man
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
;;; Compilation ;;; Compilation
(defcustom org-e-man-pdf-process (defcustom org-e-man-pdf-process
@ -291,7 +253,6 @@ These are the .aux, .log, .out, and .toc files."
;;; Internal Functions ;;; Internal Functions
(defun org-e-man--caption/label-string (element info) (defun org-e-man--caption/label-string (element info)
"Return caption and label Man string for ELEMENT. "Return caption and label Man string for ELEMENT.
@ -311,21 +272,6 @@ For non-floats, see `org-e-man--wrap-label'."
;; Standard caption format. ;; Standard caption format.
(t (format "\\fR%s\\fP" (org-export-data main info)))))) (t (format "\\fR%s\\fP" (org-export-data main info))))))
(defun org-e-man--quotation-marks (text info)
"Export quotation marks depending on language conventions.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr (or (assoc (plist-get info :language) org-e-man-quotes)
;; Falls back on English.
(assoc "en" org-e-man-quotes)))) text)
(defun org-e-man--wrap-label (element output) (defun org-e-man--wrap-label (element output)
"Wrap label associated to ELEMENT around OUTPUT, if appropriate. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
This function shouldn't be used for floats. See This function shouldn't be used for floats. See
@ -335,6 +281,7 @@ This function shouldn't be used for floats. See
output output
(concat (format "%s\n.br\n" label) output)))) (concat (format "%s\n.br\n" label) output))))
;;; Template ;;; Template
@ -448,7 +395,7 @@ holding contextual information. See `org-export-data'."
"Transcode an ENTITY object from Org to Man. "Transcode an ENTITY object from Org to Man.
CONTENTS are the definition itself. INFO is a plist holding CONTENTS are the definition itself. INFO is a plist holding
contextual information." contextual information."
(let ((ent (org-element-property :utf8 entity))) ent)) (org-element-property :utf-8 entity))
;;; Example Block ;;; Example Block
@ -461,6 +408,8 @@ information."
example-block example-block
(format ".RS\n.nf\n%s\n.fi\n.RE" (format ".RS\n.nf\n%s\n.fi\n.RE"
(org-export-format-code-default example-block info)))) (org-export-format-code-default example-block info))))
;;; Export Block ;;; Export Block
(defun org-e-man-export-block (export-block contents info) (defun org-e-man-export-block (export-block contents info)
@ -764,21 +713,21 @@ contextual information."
"Transcode a TEXT string from Org to Man. "Transcode a TEXT string from Org to Man.
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."
;; Protect (let ((output text))
(setq text (replace-regexp-in-string ;; Protect various chars.
"\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)" (setq output (replace-regexp-in-string
"$\\" text nil t 1)) "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
"$\\" output nil t 1))
;; Handle quotation marks ;; Activate smart quotes. Be sure to provide original TEXT string
(setq text (org-e-man--quotation-marks text info)) ;; since OUTPUT may have been modified.
(when (plist-get info :with-smart-quotes)
;; Handle break preservation if required. (setq output (org-export-activate-smart-quotes output :utf-8 info text)))
;; 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 output (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n"
text))) output)))
;; Return value. ;; Return value.
text) output))

View File

@ -770,42 +770,6 @@ Images in ODT export' for more information."
:version "24.1") :version "24.1")
;;;; Plain text
(defcustom org-e-odt-quotes
'(("fr"
("\\(\\s-\\|[[(]\\|^\\)\"" . "« ")
("\\(\\S-\\)\"" . "» ")
("\\(\\s-\\|(\\|^\\)'" . "'"))
("en"
("\\(\\s-\\|[[(]\\|^\\)\"" . "")
("\\(\\S-\\)\"" . "")
("\\(\\s-\\|(\\|^\\)'" . "")
("\\(\\S-\\)'" . "")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-odt
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
;;;; Src Block ;;;; Src Block
(defcustom org-e-odt-create-custom-styles-for-srcblocks t (defcustom org-e-odt-create-custom-styles-for-srcblocks t
@ -1477,10 +1441,6 @@ holding contextual information. See `org-export-data'."
"Transcode an ENTITY object from Org to ODT. "Transcode an ENTITY object from Org to ODT.
CONTENTS are the definition itself. INFO is a plist holding CONTENTS are the definition itself. INFO is a plist holding
contextual information." contextual information."
;; (let ((ent (org-element-property :latex entity)))
;; (if (org-element-property :latex-math-p entity)
;; (format "$%s$" ent)
;; ent))
(org-element-property :utf-8 entity)) (org-element-property :utf-8 entity))
@ -2609,40 +2569,29 @@ contextual information."
(if no-whitespace-filling text (if no-whitespace-filling text
(org-e-odt--encode-tabs-and-spaces text))) (org-e-odt--encode-tabs-and-spaces text)))
(defun org-e-odt--quotation-marks (text info)
"Export quotation marks depending on language conventions.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr (or (assoc (plist-get info :language) org-e-odt-quotes)
;; Falls back on English.
(assoc "en" org-e-odt-quotes))))
text)
(defun org-e-odt-plain-text (text info) (defun org-e-odt-plain-text (text info)
"Transcode a TEXT string from Org to ODT. "Transcode a TEXT string from Org to ODT.
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."
;; Protect &, < and >. (let ((output text))
(setq text (org-e-odt--encode-plain-text text t)) ;; Protect &, < and >.
;; Handle quotation marks (setq output (org-e-odt--encode-plain-text output t))
(setq text (org-e-odt--quotation-marks text info)) ;; Handle smart quotes. Be sure to provide original string since
;; Convert special strings. ;; OUTPUT may have been modified.
(when (plist-get info :with-special-strings) (setq output (org-export-activate-smart-quotes output :utf-8 info text))
(mapc ;; Convert special strings.
(lambda (pair) (when (plist-get info :with-special-strings)
(setq text (replace-regexp-in-string (car pair) (cdr pair) text t nil))) (mapc
org-e-odt-special-string-regexps)) (lambda (pair)
;; Handle break preservation if required. (setq output
(when (plist-get info :preserve-breaks) (replace-regexp-in-string (car pair) (cdr pair) output t nil)))
(setq text (replace-regexp-in-string org-e-odt-special-string-regexps))
"\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>\n" text t))) ;; Handle break preservation if required.
;; Return value. (when (plist-get info :preserve-breaks)
text) (setq output (replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>\n" output t)))
;; Return value.
output))
;;;; Planning ;;;; Planning

View File

@ -82,14 +82,11 @@
(footnote-definition . org-e-texinfo-footnote-definition) (footnote-definition . org-e-texinfo-footnote-definition)
(footnote-reference . org-e-texinfo-footnote-reference) (footnote-reference . org-e-texinfo-footnote-reference)
(headline . org-e-texinfo-headline) (headline . org-e-texinfo-headline)
(horizontal-rule . org-e-texinfo-horizontal-rule)
(inline-src-block . org-e-texinfo-inline-src-block) (inline-src-block . org-e-texinfo-inline-src-block)
(inlinetask . org-e-texinfo-inlinetask) (inlinetask . org-e-texinfo-inlinetask)
(italic . org-e-texinfo-italic) (italic . org-e-texinfo-italic)
(item . org-e-texinfo-item) (item . org-e-texinfo-item)
(keyword . org-e-texinfo-keyword) (keyword . org-e-texinfo-keyword)
(latex-environment . org-e-texinfo-latex-environment)
(latex-fragment . org-e-texinfo-latex-fragment)
(line-break . org-e-texinfo-line-break) (line-break . org-e-texinfo-line-break)
(link . org-e-texinfo-link) (link . org-e-texinfo-link)
(paragraph . org-e-texinfo-paragraph) (paragraph . org-e-texinfo-paragraph)
@ -104,7 +101,6 @@
(special-block . org-e-texinfo-special-block) (special-block . org-e-texinfo-special-block)
(src-block . org-e-texinfo-src-block) (src-block . org-e-texinfo-src-block)
(statistics-cookie . org-e-texinfo-statistics-cookie) (statistics-cookie . org-e-texinfo-statistics-cookie)
(strike-through . org-e-texinfo-strike-through)
(subscript . org-e-texinfo-subscript) (subscript . org-e-texinfo-subscript)
(superscript . org-e-texinfo-superscript) (superscript . org-e-texinfo-superscript)
(table . org-e-texinfo-table) (table . org-e-texinfo-table)
@ -113,7 +109,6 @@
(target . org-e-texinfo-target) (target . org-e-texinfo-target)
(template . org-e-texinfo-template) (template . org-e-texinfo-template)
(timestamp . org-e-texinfo-timestamp) (timestamp . org-e-texinfo-timestamp)
(underline . org-e-texinfo-underline)
(verbatim . org-e-texinfo-verbatim) (verbatim . org-e-texinfo-verbatim)
(verse-block . org-e-texinfo-verse-block)) (verse-block . org-e-texinfo-verse-block))
:export-block "TEXINFO" :export-block "TEXINFO"
@ -359,36 +354,6 @@ in order to mimic default behaviour:
;; ;;
;; Src Blocks are example blocks, except for LISP ;; Src Blocks are example blocks, except for LISP
;;; Plain text
(defcustom org-e-texinfo-quotes
'(("quotes"
("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
("\\(\\S-\\)\"" . "''")
("\\(\\s-\\|(\\|^\\)'" . "`")))
"Alist for quotes to use when converting english double-quotes.
The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.
For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."
:group 'org-export-e-texinfo
:type '(list
(cons :tag "Opening quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))
(cons :tag "Closing quote"
(string :tag "Regexp for char after ")
(string :tag "Replacement quote "))
(cons :tag "Single quote"
(string :tag "Regexp for char before")
(string :tag "Replacement quote "))))
;;; Compilation ;;; Compilation
(defcustom org-e-texinfo-info-process (defcustom org-e-texinfo-info-process
@ -445,18 +410,6 @@ nil."
options options
",")) ","))
(defun org-e-texinfo--quotation-marks (text info)
"Export quotation marks using ` and ' as the markers.
TEXT is a string containing quotation marks to be replaced. INFO
is a plist used as a communication channel."
(mapc (lambda(l)
(let ((start 0))
(while (setq start (string-match (car l) text start))
(let ((new-quote (concat (match-string 1 text) (cdr l))))
(setq text (replace-match new-quote t t text))))))
(cdr org-e-texinfo-quotes))
text)
(defun org-e-texinfo--text-markup (text markup) (defun org-e-texinfo--text-markup (text markup)
"Format TEXT depending on MARKUP text markup. "Format TEXT depending on MARKUP text markup.
See `org-e-texinfo-text-markup-alist' for details." See `org-e-texinfo-text-markup-alist' for details."
@ -790,10 +743,6 @@ holding export options."
;;; Transcode Functions ;;; Transcode Functions
;;; Babel Call
;;
;; Babel Calls are ignored.
;;; Bold ;;; Bold
(defun org-e-texinfo-bold (bold contents info) (defun org-e-texinfo-bold (bold contents info)
@ -803,8 +752,12 @@ contextual information."
(org-e-texinfo--text-markup contents 'bold)) (org-e-texinfo--text-markup contents 'bold))
;;; Center Block ;;; Center Block
;;
;; Center blocks are ignored (defun org-e-texinfo-center-block (center-block contents info)
"Transcode a CENTER-BLOCK element from Org to Texinfo.
CONTENTS holds the contents of the block. INFO is a plist used
as a communication channel."
contents)
;;; Clock ;;; Clock
@ -912,10 +865,6 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(org-e-texinfo--sanitize-content (org-e-texinfo--sanitize-content
(org-element-property :value fixed-width))))) (org-element-property :value fixed-width)))))
;;; Footnote Definition
;;
;; Footnote Definitions are ignored.
;;; Footnote Reference ;;; Footnote Reference
;; ;;
@ -1093,14 +1042,6 @@ holding contextual information."
(format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text (format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text
(concat pre-blanks contents)))))))) (concat pre-blanks contents))))))))
;;; Horizontal Rule
;;
;; Horizontal rules are ignored
;;; Inline Babel Call
;;
;; Inline Babel Calls are ignored.
;;; Inline Src Block ;;; Inline Src Block
(defun org-e-texinfo-inline-src-block (inline-src-block contents info) (defun org-e-texinfo-inline-src-block (inline-src-block contents info)
@ -1179,14 +1120,6 @@ CONTENTS is nil. INFO is a plist holding contextual information."
((string= key "TINDEX") (format "@tindex %s" value)) ((string= key "TINDEX") (format "@tindex %s" value))
((string= key "VINDEX") (format "@vindex %s" value))))) ((string= key "VINDEX") (format "@vindex %s" value)))))
;;; Latex Environment
;;
;; Latex environments are ignored
;;; Latex Fragment
;;
;; Latex fragments are ignored.
;;; Line Break ;;; Line Break
(defun org-e-texinfo-line-break (line-break contents info) (defun org-e-texinfo-line-break (line-break contents info)
@ -1335,25 +1268,30 @@ contextual information."
"Transcode a TEXT string from Org to Texinfo. "Transcode a TEXT string from Org to Texinfo.
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."
;; LaTeX into @LaTeX{} and TeX into @TeX{} ;; First protect @, { and }.
(let ((case-fold-search nil) (let ((output (org-e-texinfo--sanitize-content text)))
(start 0)) ;; Activate smart quotes. Be sure to provide original TEXT string
(while (string-match "\\(\\(?:La\\)?TeX\\)" text start) ;; since OUTPUT may have been modified.
(setq text (replace-match (when (plist-get info :with-smart-quotes)
(format "@%s{}" (match-string 1 text)) nil t text) (setq output
start (match-end 0)))) (org-export-activate-smart-quotes output :texinfo info text)))
;; Handle quotation marks ;; LaTeX into @LaTeX{} and TeX into @TeX{}
(setq text (org-e-texinfo--quotation-marks text info)) (let ((case-fold-search nil)
;; Convert special strings. (start 0))
(when (plist-get info :with-special-strings) (while (string-match "\\(\\(?:La\\)?TeX\\)" output start)
(while (string-match (regexp-quote "...") text) (setq output (replace-match
(setq text (replace-match "@dots{}" nil t text)))) (format "@%s{}" (match-string 1 output)) nil t output)
;; Handle break preservation if required. start (match-end 0))))
(when (plist-get info :preserve-breaks) ;; Convert special strings.
(setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " @*\n" (when (plist-get info :with-special-strings)
text))) (while (string-match (regexp-quote "...") output)
;; Return value with @ { and } protected. (setq output (replace-match "@dots{}" nil t output))))
(org-e-texinfo--sanitize-content text)) ;; Handle break preservation if required.
(when (plist-get info :preserve-breaks)
(setq output (replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" " @*\n" output)))
;; Return value.
output))
;;; Planning ;;; Planning
@ -1439,8 +1377,12 @@ holding contextual information."
contents) contents)
;;; Special Block ;;; Special Block
;;
;; Are ignored at the moment (defun org-e-texinfo-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to Texinfo.
CONTENTS holds the contents of the block. INFO is a plist used
as a communication channel."
contents)
;;; Src Block ;;; Src Block
@ -1467,10 +1409,6 @@ contextual information."
CONTENTS is nil. INFO is a plist holding contextual information." CONTENTS is nil. INFO is a plist holding contextual information."
(org-element-property :value statistics-cookie)) (org-element-property :value statistics-cookie))
;;; Strike-Through
;;
;; Strikethrough is ignored
;;; Subscript ;;; Subscript
(defun org-e-texinfo-subscript (subscript contents info) (defun org-e-texinfo-subscript (subscript contents info)
@ -1640,10 +1578,6 @@ information."
(format org-e-texinfo-inactive-timestamp-format value)) (format org-e-texinfo-inactive-timestamp-format value))
(t (format org-e-texinfo-diary-timestamp-format value))))) (t (format org-e-texinfo-diary-timestamp-format value)))))
;;; Underline
;;
;; Underline is ignored
;;; Verbatim ;;; Verbatim
(defun org-e-texinfo-verbatim (verbatim contents info) (defun org-e-texinfo-verbatim (verbatim contents info)

View File

@ -355,6 +355,8 @@ a communication channel."
"Transcode a TEXT string into Markdown format. "Transcode a TEXT string into Markdown format.
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."
(when (plist-get info :with-smart-quotes)
(setq text (org-export-activate-smart-quotes text :html info)))
;; Protect ambiguous #. This will protect # at the beginning of ;; Protect ambiguous #. This will protect # at the beginning of
;; a line, but not at the beginning of a paragraph. See ;; a line, but not at the beginning of a paragraph. See
;; `org-md-paragraph'. ;; `org-md-paragraph'.
@ -362,9 +364,7 @@ contextual information."
;; Protect ambiguous ! ;; Protect ambiguous !
(setq text (replace-regexp-in-string "\\(!\\)\\[" "\\\\!" text nil nil 1)) (setq text (replace-regexp-in-string "\\(!\\)\\[" "\\\\!" text nil nil 1))
;; Protect `, *, _ and \ ;; Protect `, *, _ and \
(setq text (setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
(replace-regexp-in-string
"[`*_\\]" (lambda (rep) (concat "\\\\" (match-string 1 rep))) text))
;; Handle special strings, if required. ;; Handle special strings, if required.
(when (plist-get info :with-special-strings) (when (plist-get info :with-special-strings)
(setq text (org-e-html-convert-special-strings text))) (setq text (org-e-html-convert-special-strings text)))