Browse Source

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.
Nicolas Goaziou 12 years ago
parent
commit
f04a5bcea1

+ 12 - 9
contrib/lisp/org-e-ascii.el

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

+ 16 - 59
contrib/lisp/org-e-groff.el

@@ -430,38 +430,6 @@ language.")
 
 ;;; 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
   '(("(c)" . "\\\\(co")
     ("(tm)" . "\\\\(tm")
@@ -553,20 +521,6 @@ For non-floats, see `org-e-groff--wrap-label'."
 	  ;; Standard caption format.
 	  (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)
   "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
 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.
 CONTENTS are the definition itself.  INFO is a plist holding
 contextual information."
-  (let ((ent (org-element-property :utf8 entity))) ent))
+  (org-element-property :utf-8 entity))
 
 ;;; Example Block
 
@@ -1447,24 +1401,27 @@ contextual information."
   "Transcode a TEXT string from Org to Groff.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  ;; Protect
-  (setq text (replace-regexp-in-string
-              "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
-              "$\\" text nil t 1))
-  ;; Handle quotation marks
-  (setq text (org-e-groff--quotation-marks text info))
+(let ((output text))
+  ;; Protect various characters.
+  (setq output (replace-regexp-in-string
+		"\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
+		"$\\" 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 :utf-8 info text)))
   ;; Handle Special Characters
   (if org-e-groff-special-char
       (dolist (special-char-list org-e-groff-special-char)
-        (setq text
-              (replace-regexp-in-string (car special-char-list)
-                                        (cdr special-char-list) text))))
+	(setq output
+	      (replace-regexp-in-string (car special-char-list)
+					(cdr special-char-list) output))))
   ;; Handle break preservation if required.
   (when (plist-get info :preserve-breaks)
-    (setq text (replace-regexp-in-string
-		"\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" text)))
+    (setq output (replace-regexp-in-string
+		  "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n" output)))
   ;; Return value.
-  text)
+  output))
 
 ;;; Planning
 

+ 17 - 59
contrib/lisp/org-e-html.el

@@ -506,38 +506,6 @@ default we use here encompasses both."
   :type '(repeat (cons (string :tag "Character")
 		       (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
 
@@ -1230,20 +1198,6 @@ Replaces invalid characters with \"_\"."
      (date date)
      (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
@@ -2402,19 +2356,23 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
   "Transcode a TEXT string from Org to HTML.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  ;; Protect following characters: <, >, &.
-  (setq text (org-e-html-encode-plain-text text))
-  ;; Handle quotation marks.
-  (setq text (org-e-html--quotation-marks text info))
-  ;; Handle special strings.
-  (when (plist-get info :with-special-strings)
-    (setq text (org-e-html-convert-special-strings 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 ((output text))
+    ;; Protect following characters: <, >, &.
+    (setq output (org-e-html-encode-plain-text output))
+    ;; Handle smart quotes.  Be sure to provide original string since
+    ;; OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output (org-export-activate-smart-quotes output :html info text)))
+    ;; Handle special strings.
+    (when (plist-get info :with-special-strings)
+      (setq output (org-e-html-convert-special-strings output)))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output
+	    (replace-regexp-in-string
+	     "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
+    ;; Return value.
+    output))
 
 
 ;; Planning

+ 20 - 64
contrib/lisp/org-e-latex.el

@@ -709,41 +709,6 @@ during latex export it will output
   \\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
 
 (defcustom org-e-latex-pdf-process
@@ -928,20 +893,6 @@ nil."
 	     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)
   "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
 This function shouldn't be used for floats.  See
@@ -1911,36 +1862,41 @@ contextual information."
   "Transcode a TEXT string from Org to LaTeX.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  (let ((specialp (plist-get info :with-special-strings)))
+  (let ((specialp (plist-get info :with-special-strings))
+	(output text))
     ;; Protect %, #, &, $, ~, ^, _,  { and }.
-    (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text)
-      (setq text
-	    (replace-match (format "\\%s" (match-string 2 text)) nil t text 2)))
+    (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" output)
+      (setq output
+	    (replace-match
+	     (format "\\%s" (match-string 2 output)) nil t output 2)))
     ;; Protect \.  If special strings are used, be careful not to
     ;; protect "\" in "\-" constructs.
     (let ((symbols (if specialp "-%$#&{}~^_\\" "%$#&{}~^_\\")))
-      (setq text
+      (setq output
 	    (replace-regexp-in-string
 	     (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{}.
     (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)
+      (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" output start)
+	(setq output (replace-match
+		      (format "\\%s{}" (match-string 1 output)) nil t output)
 	      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)))
+      (setq output
+	    (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" output nil t)))
     ;; Handle break preservation if required.
     (when (plist-get info :preserve-breaks)
-      (setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
-					   text)))
+      (setq output (replace-regexp-in-string
+		    "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" output)))
     ;; Return value.
-    text))
+    output))
 
 
 ;;;; Planning

+ 19 - 70
contrib/lisp/org-e-man.el

@@ -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
 
 (defcustom org-e-man-pdf-process
@@ -291,7 +253,6 @@ These are the .aux, .log, .out, and .toc files."
 
 ;;; Internal Functions
 
-
 (defun org-e-man--caption/label-string (element info)
   "Return caption and label Man string for ELEMENT.
 
@@ -311,21 +272,6 @@ For non-floats, see `org-e-man--wrap-label'."
 	  ;; Standard caption format.
 	  (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)
   "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
 This function shouldn't be used for floats.  See
@@ -335,6 +281,7 @@ This function shouldn't be used for floats.  See
         output
       (concat (format "%s\n.br\n" label) output))))
 
+
 
 ;;; Template
 
@@ -448,7 +395,7 @@ holding contextual information.  See `org-export-data'."
   "Transcode an ENTITY object from Org to Man.
 CONTENTS are the definition itself.  INFO is a plist holding
 contextual information."
-  (let ((ent (org-element-property :utf8 entity))) ent))
+  (org-element-property :utf-8 entity))
 
 
 ;;; Example Block
@@ -461,6 +408,8 @@ information."
    example-block
    (format ".RS\n.nf\n%s\n.fi\n.RE"
            (org-export-format-code-default example-block info))))
+
+
 ;;; Export Block
 
 (defun org-e-man-export-block (export-block contents info)
@@ -764,21 +713,21 @@ contextual information."
   "Transcode a TEXT string from Org to Man.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  ;; Protect
-  (setq text (replace-regexp-in-string
-              "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
-              "$\\" text nil t 1))
-
-  ;; Handle quotation marks
-  (setq text (org-e-man--quotation-marks text info))
-
-  ;; 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 ((output text))
+    ;; Protect various chars.
+    (setq output (replace-regexp-in-string
+		  "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
+		  "$\\" 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 :utf-8 info text)))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n"
+					     output)))
+    ;; Return value.
+    output))
 
 
 

+ 19 - 70
contrib/lisp/org-e-odt.el

@@ -770,42 +770,6 @@ Images in ODT export' for more information."
   :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
 
 (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.
 CONTENTS are the definition itself.  INFO is a plist holding
 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))
 
 
@@ -2609,40 +2569,29 @@ contextual information."
   (if no-whitespace-filling 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)
   "Transcode a TEXT string from Org to ODT.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  ;; Protect &, < and >.
-  (setq text (org-e-odt--encode-plain-text text t))
-  ;; Handle quotation marks
-  (setq text (org-e-odt--quotation-marks text info))
-  ;; Convert special strings.
-  (when (plist-get info :with-special-strings)
-    (mapc
-     (lambda (pair)
-       (setq text (replace-regexp-in-string (car pair) (cdr pair) text t nil)))
-     org-e-odt-special-string-regexps))
-  ;; Handle break preservation if required.
-  (when (plist-get info :preserve-breaks)
-    (setq text (replace-regexp-in-string
-		"\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>\n" text t)))
-  ;; Return value.
-  text)
+  (let ((output text))
+    ;; Protect &, < and >.
+    (setq output (org-e-odt--encode-plain-text output t))
+    ;; Handle smart quotes.  Be sure to provide original string since
+    ;; OUTPUT may have been modified.
+    (setq output (org-export-activate-smart-quotes output :utf-8 info text))
+    ;; Convert special strings.
+    (when (plist-get info :with-special-strings)
+      (mapc
+       (lambda (pair)
+	 (setq output
+	       (replace-regexp-in-string (car pair) (cdr pair) output t nil)))
+       org-e-odt-special-string-regexps))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string
+		    "\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>\n" output t)))
+    ;; Return value.
+    output))
 
 
 ;;;; Planning

+ 36 - 102
contrib/lisp/org-e-texinfo.el

@@ -82,14 +82,11 @@
    (footnote-definition . org-e-texinfo-footnote-definition)
    (footnote-reference . org-e-texinfo-footnote-reference)
    (headline . org-e-texinfo-headline)
-   (horizontal-rule . org-e-texinfo-horizontal-rule)
    (inline-src-block . org-e-texinfo-inline-src-block)
    (inlinetask . org-e-texinfo-inlinetask)
    (italic . org-e-texinfo-italic)
    (item . org-e-texinfo-item)
    (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)
    (link . org-e-texinfo-link)
    (paragraph . org-e-texinfo-paragraph)
@@ -104,7 +101,6 @@
    (special-block . org-e-texinfo-special-block)
    (src-block . org-e-texinfo-src-block)
    (statistics-cookie . org-e-texinfo-statistics-cookie)
-   (strike-through . org-e-texinfo-strike-through)
    (subscript . org-e-texinfo-subscript)
    (superscript . org-e-texinfo-superscript)
    (table . org-e-texinfo-table)
@@ -113,7 +109,6 @@
    (target . org-e-texinfo-target)
    (template . org-e-texinfo-template)
    (timestamp . org-e-texinfo-timestamp)
-   (underline . org-e-texinfo-underline)
    (verbatim . org-e-texinfo-verbatim)
    (verse-block . org-e-texinfo-verse-block))
   :export-block "TEXINFO"
@@ -359,36 +354,6 @@ in order to mimic default behaviour:
 ;;
 ;; 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
 
 (defcustom org-e-texinfo-info-process
@@ -445,18 +410,6 @@ nil."
 	     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)
   "Format TEXT depending on MARKUP text markup.
 See `org-e-texinfo-text-markup-alist' for details."
@@ -790,10 +743,6 @@ holding export options."
 
 ;;; Transcode Functions
 
-;;; Babel Call
-;;
-;; Babel Calls are ignored.
-
 ;;; Bold
 
 (defun org-e-texinfo-bold (bold contents info)
@@ -803,8 +752,12 @@ contextual information."
   (org-e-texinfo--text-markup contents 'bold))
 
 ;;; 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
 
@@ -912,10 +865,6 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	   (org-e-texinfo--sanitize-content
 	    (org-element-property :value fixed-width)))))
 
-;;; Footnote Definition
-;;
-;; Footnote Definitions are ignored.
-
 ;;; Footnote Reference
 ;;
 
@@ -1093,14 +1042,6 @@ holding contextual information."
 	(format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text
 		(concat pre-blanks contents))))))))
 
-;;; Horizontal Rule
-;;
-;; Horizontal rules are ignored
-
-;;; Inline Babel Call
-;;
-;; Inline Babel Calls are ignored.
-
 ;;; Inline Src Block
 
 (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 "VINDEX") (format "@vindex %s" value)))))
 
-;;; Latex Environment
-;;
-;; Latex environments are ignored
-
-;;; Latex Fragment
-;;
-;; Latex fragments are ignored.
-
 ;;; Line Break
 
 (defun org-e-texinfo-line-break (line-break contents info)
@@ -1335,25 +1268,30 @@ contextual information."
   "Transcode a TEXT string from Org to Texinfo.
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
-  ;; 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-texinfo--quotation-marks text info))
-  ;; Convert special strings.
-  (when (plist-get info :with-special-strings)
-    (while (string-match (regexp-quote "...") text)
-      (setq text (replace-match "@dots{}" 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 with @ { and } protected.
-  (org-e-texinfo--sanitize-content text))
+  ;; First protect @, { and }.
+  (let ((output (org-e-texinfo--sanitize-content text)))
+    ;; 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 :texinfo info text)))
+    ;; LaTeX into @LaTeX{} and TeX into @TeX{}
+    (let ((case-fold-search nil)
+	  (start 0))
+      (while (string-match "\\(\\(?:La\\)?TeX\\)" output start)
+	(setq output (replace-match
+		      (format "@%s{}" (match-string 1 output)) nil t output)
+	      start (match-end 0))))
+    ;; Convert special strings.
+    (when (plist-get info :with-special-strings)
+      (while (string-match (regexp-quote "...") output)
+	(setq output (replace-match "@dots{}" nil t output))))
+    ;; 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
 
@@ -1439,8 +1377,12 @@ holding contextual information."
   contents)
 
 ;;; 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
 
@@ -1467,10 +1409,6 @@ contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (org-element-property :value statistics-cookie))
 
-;;; Strike-Through
-;;
-;; Strikethrough is ignored
-
 ;;; Subscript
 
 (defun org-e-texinfo-subscript (subscript contents info)
@@ -1640,10 +1578,6 @@ information."
 	   (format org-e-texinfo-inactive-timestamp-format value))
 	  (t (format org-e-texinfo-diary-timestamp-format value)))))
 
-;;; Underline
-;;
-;; Underline is ignored
-
 ;;; Verbatim
 
 (defun org-e-texinfo-verbatim (verbatim contents info)

+ 3 - 3
contrib/lisp/org-md.el

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