From c5d46d21b5a3f902cfd7b9d709660b493f67bd94 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sun, 3 Mar 2013 20:15:10 +0530 Subject: [PATCH 2/3] Always use utf-8 encoding for HTML export * ox-html.el (org-html-coding-system): Removed. Always use utf-8 for HTML export. (org-html--build-meta-info, org-html-template) (org-html-entity, org-html-export-to-html): Propagate above change. (org-html-table--table.el-table): Replace   with it's utf-8 equivalent. (org-html-special-string-regexps, org-html--tags) (org-html-format-headline, org-html--format-toc-headline) (org-html-checkbox, org-html-table-cell, org-html-timestamp) (org-html-verse-block): Replace numeric entities with their utf-8 equivalent. Mark ox-html.el as utf-8 encoded. --- lisp/ox-html.el | 55 +++++++++++++++++++++---------------------------------- 1 files changed, 21 insertions(+), 34 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 3a4c0e7..efd9b2f 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -136,10 +136,10 @@ (defvar htmlize-buffer-places) ; from htmlize.el (defconst org-html-special-string-regexps - '(("\\\\-" . "­") ; shy - ("---\\([^-]\\)" . "—\\1") ; mdash - ("--\\([^-]\\)" . "–\\1") ; ndash - ("\\.\\.\\." . "…")) ; hellip + '(("\\\\-" . "­") ; shy + ("---\\([^-]\\)" . "—\\1") ; mdash + ("--\\([^-]\\)" . "–\\1") ; ndash + ("\\.\\.\\." . "…")) ; hellip "Regular expressions for special string conversion.") (defconst org-html-scripts @@ -821,12 +821,6 @@ and corresponding declarations." (cons (string :tag "Extension") (string :tag "Declaration"))))) -(defcustom org-html-coding-system 'utf-8 - "Coding system for HTML export. -Use utf-8 as the default value." - :group 'org-export-html - :type 'coding-system) - (defcustom org-html-divs '("preamble" "content" "postamble") "The name of the main divs for HTML export. This is a list of three strings, the first one for the preamble @@ -1337,12 +1331,7 @@ INFO is a plist used as a communication channel." (keywords (plist-get info :keywords))) (concat (format "%s\n" title) - (format - "\n" - (or (and org-html-coding-system - (fboundp 'coding-system-get) - (coding-system-get org-html-coding-system 'mime-charset)) - "iso-8859-1")) + "\n" (format "\n" title) (format "\n") (and date (format "\n" date)) @@ -1515,10 +1504,7 @@ holding export options." (cdr (assoc "html" org-html-xml-declaration)) "") - (or (and org-html-coding-system - (fboundp 'coding-system-get) - (coding-system-get org-html-coding-system 'mime-charset)) - "iso-8859-1")) + "utf-8") "\n" "\n" @@ -1579,7 +1565,7 @@ INFO is a plist used as a communication channel." (concat org-html-tag-class-prefix (org-html-fix-class-name tag)) tag)) - tags " ")))) + tags " ")))) ;;;; Headline @@ -1593,7 +1579,7 @@ INFO is a plist used as a communication channel." (todo (org-html--todo todo)) (tags (org-html--tags tags))) (concat section-number todo (and todo " ") text - (and tags "   ") tags))) + (and tags "   ") tags))) ;;;; Src Code @@ -1780,7 +1766,7 @@ INFO is a plist used as a communication channel." (target . ignore)) (org-export-backend-translate-table 'html)) info) - (and tags "   ") (org-html--tags tags))))) + (and tags "   ") (org-html--tags tags))))) (defun org-html-list-of-listings (info) "Build a list of listings. @@ -1932,7 +1918,7 @@ holding contextual information. See `org-export-data'." "Transcode an ENTITY object from Org to HTML. CONTENTS are the definition itself. INFO is a plist holding contextual information." - (org-element-property :html entity)) + (org-element-property :utf-8 entity)) ;;;; Example Block @@ -2184,7 +2170,7 @@ contextual information." (defun org-html-checkbox (checkbox) (case checkbox (on "[X]") - (off "[ ]") + (off "[ ]") (trans "[-]") (t ""))) @@ -2856,7 +2842,7 @@ channel." " align=\"%s\"" " class=\"%s\"") (org-export-table-cell-alignment table-cell info))))) (when (or (not contents) (string= "" (org-trim contents))) - (setq contents " ")) + (setq contents " ")) (cond ((and (org-export-table-has-header-p table info) (= 1 (org-export-table-row-group table-row info))) @@ -2929,8 +2915,9 @@ communication channel." (re-search-forward "^[ \t]*|[^|]" nil t) (table-generate-source 'html outbuf)) (with-current-buffer outbuf - (prog1 (org-trim (buffer-string)) - (kill-buffer) ))))) + (prog1 (org-trim (replace-regexp-in-string + " " " " (buffer-string) nil t)) + (kill-buffer)))))) (defun org-html-table (table contents info) "Transcode a TABLE element from Org to HTML. @@ -3009,7 +2996,7 @@ information." (let ((value (org-html-plain-text (org-timestamp-translate timestamp) info))) (format "%s" - (replace-regexp-in-string "--" "–" value)))) + (replace-regexp-in-string "--" "–" value)))) ;;;; Underline @@ -3049,7 +3036,7 @@ contextual information." (while (string-match "^[ \t]+" contents) (let* ((num-ws (length (match-string 0 contents))) (ws (let (out) (dotimes (i num-ws out) - (setq out (concat out " ")))))) + (setq out (concat out " ")))))) (setq contents (replace-match ws nil t contents)))) (format "

\n%s

" contents)) @@ -3150,16 +3137,15 @@ file-local settings. Return output file's name." (interactive) (let* ((extension (concat "." org-html-extension)) - (file (org-export-output-file-name extension subtreep)) - (org-export-coding-system org-html-coding-system)) + (file (org-export-output-file-name extension subtreep))) (if async (org-export-async-start (lambda (f) (org-export-add-to-stack f 'html)) - (let ((org-export-coding-system org-html-coding-system)) + (let ((org-export-coding-system 'utf-8)) `(expand-file-name (org-export-to-file 'html ,file ,subtreep ,visible-only ,body-only ',ext-plist)))) - (let ((org-export-coding-system org-html-coding-system)) + (let ((org-export-coding-system 'utf-8)) (org-export-to-file 'html file subtreep visible-only body-only ext-plist))))) @@ -3199,6 +3185,7 @@ Return output file name." ;; Local variables: ;; generated-autoload-file: "org-loaddefs.el" +;; coding: utf-8 ;; End: ;;; ox-html.el ends here -- 1.7.2.5