emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] Few small fixes to html header
@ 2014-03-27 19:57 Marcin Antczak
  2014-03-28  7:59 ` Rainer M Krug
  2014-03-28 14:43 ` Rick Frankel
  0 siblings, 2 replies; 8+ messages in thread
From: Marcin Antczak @ 2014-03-27 19:57 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]


I've attached patch below, but I'm affraid that there is something wrong
with indentation.
I'm not sure if there is problem with my settings or just entire
ox-html.el is indented badly.

I've been trying to indent file with the default parameters.
I started Emacs with -Q parameter and as I can see there is
a .dir-locals.el in org-mode repo.

So, everything should be ok. Unfortunately there are some differences related to indentation in my patch.

Please review and accept this patch, or enlighten me how to set
indentation properly.


My patch fixes HTML meta data produced on export by ox-html.el

1. Meta charset definition should be set before title as document title can contain
some unicode symbols etc.

2. Added viewport declaration as described here:

https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/html.md

here:

https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html

3. Fixed unnecessary "\n" at the end of Description meta.
4. Removed unnecessary spaces in meta tags.



Marcin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch --]
[-- Type: text/x-diff, Size: 11402 bytes --]

From 2df844b2a14e823fa2020cc425ad5ede75f12534 Mon Sep 17 00:00:00 2001
From: Marcin Antczak <marcin.antczak@neutrico-themes.pl>
Date: Thu, 27 Mar 2014 19:29:41 +0100
Subject: [PATCH] Few small fixes to html header.

* ox-html.el: Few small fixes to meta tags defined by org-html--build-meta-info function.

1. Meta charset should be set before title of html document.
2. Added meta viewport declaration.
3. Fixed unnecessary "\n" at the end of Description meta.
4. Removed unnecessary spaces in meta tags.

---
 lisp/ox-html.el | 130 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 66 insertions(+), 64 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index a843441..39967e1 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -235,7 +235,7 @@ for the JavaScript code in this tag.
   .todo   { font-family: monospace; color: red; }
   .done   { color: green; }
   .tag    { background-color: #eee; font-family: monospace;
-            padding: 2px; font-size: 80%; font-weight: normal; }
+	    padding: 2px; font-size: 80%; font-weight: normal; }
   .timestamp { color: #bebebe; }
   .timestamp-kwd { color: #5f9ea0; }
   .right  { margin-left: auto; margin-right: 0px;  text-align: right; }
@@ -686,11 +686,11 @@ e.g. \"tex:mathjax\".  Allowed values are:
 nil            Ignore math snippets.
 `verbatim'     Keep everything in verbatim
 `dvipng'       Process the LaTeX fragments to images.  This will also
-               include processing of non-math environments.
+	       include processing of non-math environments.
 `imagemagick'  Convert the LaTeX fragments to pdf files and use
-               imagemagick to convert pdf files to png files.
+	       imagemagick to convert pdf files to png files.
 `mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
-               be loaded.
+	       be loaded.
 t              Synonym for `mathjax'."
   :group 'org-export-html
   :version "24.4"
@@ -826,15 +826,15 @@ you can reuse them:
   `rowgroup-number': group number of current row
  `start-rowgroup-p': non-nil means the row starts a group
    `end-rowgroup-p': non-nil means the row ends a group
-        `top-row-p': non-nil means this is the top row
+	`top-row-p': non-nil means this is the top row
      `bottom-row-p': non-nil means this is the bottom row
 
 For example:
 
 \(setq org-html-table-row-tags
       (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
-                   (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
-                   (t (if (= (mod row-number 2) 1)
+		   (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
+		   (t (if (= (mod row-number 2) 1)
 			  \"<tr class=\\\"tr-odd\\\">\"
 			\"<tr class=\\\"tr-even\\\">\")))
 	    \"</tr>\"))
@@ -1033,9 +1033,9 @@ scale       Scaling for the HTML-CSS backend, usually between 100 and 133
 align       How to align display math: left, center, or right
 indent      If align is not center, how far from the left/right side?
 mathml      Should a MathML player be used if available?
-            This is faster and reduces bandwidth use, but currently
-            sometimes has lower spacing quality.  Therefore, the default is
-            nil.  When browsers get better, this switch can be flipped.
+	    This is faster and reduces bandwidth use, but currently
+	    sometimes has lower spacing quality.  Therefore, the default is
+	    nil.  When browsers get better, this switch can be flipped.
 
 You can also customize this for each buffer, using something like
 
@@ -1058,41 +1058,41 @@ You can also customize this for each buffer, using something like
 <script type=\"text/javascript\">
 <!--/*--><![CDATA[/*><!--*/
     MathJax.Hub.Config({
-        // Only one of the two following lines, depending on user settings
-        // First allows browser-native MathML display, second forces HTML/CSS
-        :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
-        :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
-        extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
-                     \"TeX/noUndefined.js\"],
-        tex2jax: {
-            inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
-            displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
-            skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
-            ignoreClass: \"tex2jax_ignore\",
-            processEscapes: false,
-            processEnvironments: true,
-            preview: \"TeX\"
-        },
-        showProcessingMessages: true,
-        displayAlign: \"%ALIGN\",
-        displayIndent: \"%INDENT\",
-
-        \"HTML-CSS\": {
-             scale: %SCALE,
-             availableFonts: [\"STIX\",\"TeX\"],
-             preferredFont: \"TeX\",
-             webFont: \"TeX\",
-             imageFont: \"TeX\",
-             showMathMenu: true,
-        },
-        MMLorHTML: {
-             prefer: {
-                 MSIE:    \"MML\",
-                 Firefox: \"MML\",
-                 Opera:   \"HTML\",
-                 other:   \"HTML\"
-             }
-        }
+	// Only one of the two following lines, depending on user settings
+	// First allows browser-native MathML display, second forces HTML/CSS
+	:MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
+	:MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
+	extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
+		     \"TeX/noUndefined.js\"],
+	tex2jax: {
+	    inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
+	    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
+	    skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
+	    ignoreClass: \"tex2jax_ignore\",
+	    processEscapes: false,
+	    processEnvironments: true,
+	    preview: \"TeX\"
+	},
+	showProcessingMessages: true,
+	displayAlign: \"%ALIGN\",
+	displayIndent: \"%INDENT\",
+
+	\"HTML-CSS\": {
+	     scale: %SCALE,
+	     availableFonts: [\"STIX\",\"TeX\"],
+	     preferredFont: \"TeX\",
+	     webFont: \"TeX\",
+	     imageFont: \"TeX\",
+	     showMathMenu: true,
+	},
+	MMLorHTML: {
+	     prefer: {
+		 MSIE:    \"MML\",
+		 Firefox: \"MML\",
+		 Opera:   \"HTML\",
+		 other:   \"HTML\"
+	     }
+	}
     });
 /*]]>*///-->
 </script>"
@@ -1371,11 +1371,11 @@ attributes with a nil value will be omitted from the result."
   (let (output)
     (dolist (item attributes (mapconcat 'identity (nreverse output) " "))
       (cond ((null item) (pop output))
-            ((symbolp item) (push (substring (symbol-name item) 1) output))
-            (t (let ((key (car output))
-                     (value (replace-regexp-in-string
-                             "\"" "&quot;" (org-html-encode-plain-text item))))
-                 (setcar output (format "%s=\"%s\"" key value))))))))
+	    ((symbolp item) (push (substring (symbol-name item) 1) output))
+	    (t (let ((key (car output))
+		     (value (replace-regexp-in-string
+			     "\"" "&quot;" (org-html-encode-plain-text item))))
+		 (setcar output (format "%s=\"%s\"" key value))))))))
 
 (defun org-html--wrap-image (contents info &optional caption label)
   "Wrap CONTENTS string within an appropriate environment for images.
@@ -1585,37 +1585,39 @@ INFO is a plist used as a communication channel."
 					     'mime-charset))
 		     "iso-8859-1")))
     (concat
-     (format "<title>%s</title>\n" title)
      (when (plist-get info :time-stamp-file)
        (format-time-string
 	 (concat "<!-- " org-html-metadata-timestamp-format " -->\n")))
      (format
       (if (org-html-html5-p info)
-	  (org-html-close-tag "meta" " charset=\"%s\"" info)
+	  (org-html-close-tag "meta" "charset=\"%s\"" info)
 	(org-html-close-tag
 	 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
 	 info))
       charset) "\n"
-     (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info)
+      (format "<title>%s</title>\n" title)
+      (org-html-close-tag "meta" "name=\"viewport\" content=\"width=device-width, initial-scale=1\"" info)
+      "\n"
+     (org-html-close-tag "meta" "name=\"generator\" content=\"Org-mode\"" info)
      "\n"
      (and (org-string-nw-p author)
 	  (concat
 	   (org-html-close-tag "meta"
-			       (format " name=\"author\" content=\"%s\""
+			       (format "name=\"author\" content=\"%s\""
 				       (funcall protect-string author))
 			       info)
 	   "\n"))
      (and (org-string-nw-p description)
 	  (concat
 	   (org-html-close-tag "meta"
-			       (format " name=\"description\" content=\"%s\"\n"
+			       (format "name=\"description\" content=\"%s\""
 				       (funcall protect-string description))
 			       info)
 	   "\n"))
      (and (org-string-nw-p keywords)
 	  (concat
 	   (org-html-close-tag "meta"
-			       (format " name=\"keywords\" content=\"%s\""
+			       (format "name=\"keywords\" content=\"%s\""
 				       (funcall protect-string keywords))
 			       info)
 	   "\n")))))
@@ -2653,7 +2655,7 @@ if its description is a single link targeting an image file."
 		     (not (org-export-inline-image-p
 			   obj org-html-inline-image-rules))))
 	     (otherwise t)))
-         info t)))))
+	 info t)))))
 
 (defvar org-html-standalone-image-predicate)
 (defun org-html-standalone-image-p (element info)
@@ -2706,7 +2708,7 @@ INFO is a plist holding contextual information.  See
 	  (function
 	   (lambda (raw-path info)
 	     "Treat links to `file.org' as links to `file.html', if needed.
-           See `org-html-link-org-files-as-html'."
+	   See `org-html-link-org-files-as-html'."
 	     (cond
 	      ((and org-html-link-org-files-as-html
 		    (string= ".org"
@@ -2886,9 +2888,9 @@ INFO is a plist holding contextual information.  See
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
   (format "%s:%s"
-          (org-element-property :key node-property)
-          (let ((value (org-element-property :value node-property)))
-            (if value (concat " " value) ""))))
+	  (org-element-property :key node-property)
+	  (let ((value (org-element-property :value node-property)))
+	    (if value (concat " " value) ""))))
 
 ;;;; Paragraph
 
@@ -2915,7 +2917,7 @@ the plist used as a communication channel."
 		    'org-html--has-caption-p))
 	       (if (not (org-string-nw-p raw)) raw
 		 (concat
-                  "<span class=\"figure-number\">"
+		  "<span class=\"figure-number\">"
 		  (format (org-html--translate "Figure %d:" info)
 			  (org-export-get-ordinal
 			   (org-element-map paragraph 'link
@@ -3067,7 +3069,7 @@ holding contextual information."
 	      (mapconcat
 	       'number-to-string
 	       (org-export-get-headline-number parent info) "-")))
-        ;; Build return value.
+	;; Build return value.
 	(format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
 		class-num
 		(or (org-element-property :CUSTOM_ID parent) section-number)
@@ -3321,7 +3323,7 @@ contextual information."
 			   "<caption class=\"t-bottom\">%s</caption>")
 			 (concat
 			  "<span class=\"table-number\">"
-                          (format (org-html--translate "Table %d:" info) number)
+			  (format (org-html--translate "Table %d:" info) number)
 			  "</span> " (org-export-data caption info))))
 	       (funcall table-column-specs table info)
 	       contents)))))
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-04-16 16:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 19:57 [Patch] Few small fixes to html header Marcin Antczak
2014-03-28  7:59 ` Rainer M Krug
2014-03-28 10:40   ` Marcin Antczak
2014-03-28 14:43 ` Rick Frankel
2014-03-28 15:16   ` Marcin Antczak
2014-03-28 16:00     ` Rick Frankel
2014-03-28 18:02       ` Marcin Antczak
2014-04-16 14:50         ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).