فهرست منبع

New variable to add to the default HTML style.

Instead of overwriting the default style, you can now simply add to it
using the variable `org-export-html-style-extra'.
Carsten Dominik 17 سال پیش
والد
کامیت
5f39979bbe
4فایلهای تغییر یافته به همراه51 افزوده شده و 12 حذف شده
  1. 9 1
      ORGWEBPAGE/Changes.org
  2. 11 9
      doc/org.texi
  3. 5 0
      lisp/ChangeLog
  4. 26 2
      lisp/org-exp.el

+ 9 - 1
ORGWEBPAGE/Changes.org

@@ -10,7 +10,7 @@
 #+LINK_UP: index.html
 #+LINK_HOME: http://orgmode.org
 
-* Version 6.06
+* Version 6.06 (in preparation)
 :PROPERTIES:
 :VISIBILITY: content
 :END:
@@ -18,6 +18,14 @@
 ** Overview
 ** Details
 
+*** New variable =org-export-html-style-extra=
+
+    This variable can be used to just /add/ to the default style
+    in =org-export-html-style=.  So if you want only small
+    modifications to the default style, you no longer need to to
+    copy the entire default style to your customization.
+    This follows a proposal by Rustom Mody.
+
 *** Simplified way to specify file links
 
     In a link, you can now leave uout the "file:" prefix if you

+ 11 - 9
doc/org.texi

@@ -7345,20 +7345,21 @@ document - your style specifications may change these:
 @end example
 
 The default style specification can be configured through the option
-@code{org-export-html-style}.  If you want to use a file-local style,
-you may use file variables, best wrapped into a COMMENT section at the
-end of the outline tree.  For example@footnote{Under Emacs 21, the
-continuation lines for a variable value should have no @samp{#} at the
-start of the line.}:
+@code{org-export-html-style}.  You can also just @emph{add} to the default
+(instead of overwriting it) by using the option
+@code{org-export-html-style-extra}. If you want to use a file-local style,
+you may use file variables, best wrapped into a COMMENT section at the end of
+the outline tree.  For example@footnote{Under Emacs 21, the continuation
+lines for a variable value should have no @samp{#} at the start of the
+line.}:
 
 @example
 * COMMENT html style specifications
 
 # Local Variables:
-# org-export-html-style: "   <style type=\"text/css\">
-#       p @{font-weight: normal; color: gray; @}
-#       h1 @{color: black; @}
-#   </style>"
+# org-export-html-style-extra: 
+#  "p  @{font-weight: normal; color: gray; @}
+#   h1 @{color: black; @}"
 # End:
 @end example
 
@@ -7768,6 +7769,7 @@ respective variable for details.
 @item @code{:tables}                @tab @code{org-export-with-tables}
 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
 @item @code{:style}                 @tab @code{org-export-html-style}
+@item @code{:style-extra}           @tab @code{org-export-html-style-extra}
 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2008-06-29  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-export-html-style-extra): New variable.
+	(org-export-splice-style): New function.
+
 2008-06-26  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-exp.el (org-export-plist-vars, org-export-as-html):

+ 26 - 2
lisp/org-exp.el

@@ -519,10 +519,22 @@ or, if you want to keep the style in a file,
    <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
 
 As the value of this option simply gets inserted into the HTML <head> header,
-you can \"misuse\" it to add arbitrary text to the header."
+you can \"misuse\" it to add arbitrary text to the header.
+See also the variable `org-export-html-style-extra'."
   :group 'org-export-html
   :type 'string)
 
+(defcustom org-export-html-style-extra ""
+  "Additional style information that is spliced into `org-export-html-style'.
+This can be used to add or overwrite information given in the variable
+`org-export-html-style'.  Use this if you are satisfied with the default
+style but would like to add to it instead of completely overwriting it.
+The value of this variable is spliced into `org-export-html-style', directly
+before the </style> tag.  Note that this will only work if the default
+style does indeed contain this tag.  In particular, if the default is to
+refer to a CSS style file, this option will be completely ignored."
+  :group 'org-export-html
+  :type 'string)
 
 (defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
   "Format for typesetting the document title in HTML export."
@@ -755,6 +767,7 @@ or if they are only using it locally."
     (:tables               . org-export-with-tables)
     (:table-auto-headline  . org-export-highlight-first-table-line)
     (:style                . org-export-html-style)
+    (:style-extra          . org-export-html-style-extra)
     (:agenda-style         . org-agenda-export-html-style)
     (:convert-org-links    . org-export-html-link-org-files-as-html)
     (:inline-images        . org-export-html-inline-images)
@@ -2617,7 +2630,8 @@ PUB-DIR is set, use this as the publishing directory."
 			       ext-plist
 			       (org-infile-export-plist))))
 
-	 (style (plist-get opt-plist :style))
+	 (style (org-export-splice-style (plist-get opt-plist :style)
+					 (plist-get opt-plist :style-extra)))
 	 (html-extension (plist-get opt-plist :html-extension))
 	 (link-validate (plist-get opt-plist :link-validation-function))
 	 valid thetoc have-headings first-heading-pos
@@ -3574,6 +3588,16 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
     (set-buffer " org-tmp2 ")
     (buffer-substring (point-min) (point-max))))
 
+(defun org-export-splice-style (style extra)
+  "Splice EXTRA into STYLE, just before \"</style>\"."
+  (if (and (stringp extra)
+	   (string-match "\\S-" extra)
+	   (string-match "</style>" style))
+      (concat (substring style 0 (match-beginning 0))
+	      "\n" extra "\n"
+	      (substring style (match-beginning 0)))
+    style))
+
 (defun org-html-handle-time-stamps (s)
   "Format time stamps in string S, or remove them."
   (catch 'exit