emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien Guerry <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: [Accepted] Allow mixed export of numbered and unnumbered sections in HTML
Date: Wed, 23 Mar 2011 15:05:04 +0100 (CET)	[thread overview]
Message-ID: <20110323140504.98CE6715E@myhost.localdomain> (raw)
In-Reply-To: m34o6u2mwf.fsf_-_@e4300lm.epcc.ed.ac.uk

Patch 711 (http://patchwork.newartisans.com/patch/711/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3Cm34o6u2mwf.fsf_-_%40e4300lm.epcc.ed.ac.uk%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] Allow mixed export of numbered and unnumbered sections in HTML
> Date: Wed, 23 Mar 2011 14:38:18 -0000
> From: Lawrence Mitchell <wence@gmx.li>
> X-Patchwork-Id: 711
> Message-Id: <m34o6u2mwf.fsf_-_@e4300lm.epcc.ed.ac.uk>
> To: emacs-orgmode@gnu.org
> 
> * lisp/org-html.el (org-export-as-html): Get local value of
> org-export-with-section-numbers from the buffer's plist.  Deal
> specially with the case the resulting value is an integer.
> (org-html-level-start): New optional argument of the option plist used
> instead of `org-export-with-section-numbers'.  Also deal specially
> with the case that the value is an integer.
> 
> When `org-export-with-section-numbers' (or the buffer-local
> :section-numbers option) is an integer, we now export the first NUM
> levels of headings with numbers and lower-level headings without.
> 
> ---
> lisp/org-html.el |   24 ++++++++++++++++++------
>  1 files changed, 18 insertions(+), 6 deletions(-)
> 
> Nick Dokos wrote:
> > Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> 
> >> This works too, but Lawrence's patch makes it much easier and
> >> probably works for other export formats too. Thanks a lot. :)
> 
> As Nick points out, each exporter backend needs a similar change.
> 
> > No doubt Lawrence's patch can be extended to work for other exports, but
> > it's not there yet: each exporter would need a change similar to the one
> > that he made to the LaTeX exporter.
> 
> Here's the matching change to the HTML exporter, which is the
> only other one I'm familiar with.  Maintainers, if you don't want
> the special-casing on integerp, the change to move from
> `org-export-with-section-numbers' to (plist-get opt-plist
> :section-numbers) is the correct one anyway.  I can split the
> patches if required.
> 
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index b13fb93..06305f6 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1150,6 +1150,7 @@ PUB-DIR is set, use this as the publishing directory."
>  	 (language    (plist-get opt-plist :language))
>  	 (keywords    (plist-get opt-plist :keywords))
>  	 (description (plist-get opt-plist :description))
> +	 (num         (plist-get opt-plist :section-numbers))
>  	 (lang-words  nil)
>  	 (head-count  0) cnt
>  	 (start       0)
> @@ -1355,7 +1356,7 @@ lang=\"%s\" xml:lang=\"%s\">
>  				   (if (string-match quote-re0 txt)
>  				       (setq txt (replace-match "" t t txt)))
>  				   (setq snumber (org-section-number level))
> -				   (if org-export-with-section-numbers
> +				   (if (and num (integerp num) (>= num level))
>  				       (setq txt (concat snumber " " txt)))
>  				   (if (<= level (max umax umax-toc))
>  				       (setq head-count (+ head-count 1)))
> @@ -1591,7 +1592,7 @@ lang=\"%s\" xml:lang=\"%s\">
>  	    (setq first-heading-pos (or first-heading-pos (point)))
>  	    (org-html-level-start level txt umax
>  				  (and org-export-with-toc (<= level umax))
> -				  head-count)
> +				  head-count opt-plist)
>  
>  	    ;; QUOTES
>  	    (when (string-match quote-re line)
> @@ -1684,7 +1685,7 @@ lang=\"%s\" xml:lang=\"%s\">
>  
>        (org-html-level-start 1 nil umax
>  			    (and org-export-with-toc (<= level umax))
> -			    head-count)
> +			    head-count opt-plist)
>        ;; the </div> to close the last text-... div.
>        (when (and (> umax 0) first-heading-pos) (insert "</div>\n"))
>  
> @@ -2330,7 +2331,7 @@ If there are links in the string, don't modify these."
>    (insert (if (equal type "d") "</dd>\n" "</li>\n")))
>  
>  (defvar body-only) ; dynamically scoped into this.
> -(defun org-html-level-start (level title umax with-toc head-count)
> +(defun org-html-level-start (level title umax with-toc head-count &optional opt-plist)
>    "Insert a new level in HTML export.
>  When TITLE is nil, just close all open levels."
>    (org-close-par-maybe)
> @@ -2341,6 +2342,7 @@ When TITLE is nil, just close all open levels."
>  	 (preferred (and target
>  			 (cdr (assoc target org-export-preferred-target-alist))))
>  	 (l org-level-max)
> +	 (num (plist-get opt-plist :section-numbers))
>  	 snumber snu href suffix)
>      (setq extra-targets (remove (or preferred target) extra-targets))
>      (setq extra-targets
> @@ -2395,10 +2397,20 @@ When TITLE is nil, just close all open levels."
>  	(setq snumber (org-section-number level)
>  	      snu (replace-regexp-in-string "\\." "_" snumber))
>  	(setq level (+ level org-export-html-toplevel-hlevel -1))
> -	(if (and org-export-with-section-numbers (not body-only))
> +	(if (and num (not body-only))
>  	    (setq title (concat
>  			 (format "<span class=\"section-number-%d\">%s</span>"
> -				 level snumber)
> +				 level
> +				 (if (and (integerp num)
> +					  ;; fix up num to take into
> +					  ;; account the top-level
> +					  ;; heading value
> +					  (>= (+ num
> +						 org-export-html-toplevel-hlevel
> +						 -1)
> +					      level))
> +					   snumber
> +					 ""))
>  			 " " title)))
>  	(unless (= head-count 1) (insert "\n</div>\n"))
>  	(setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
> 

  reply	other threads:[~2011-03-23 14:05 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-22 12:10 unnumbered subsections in latex export Suvayu Ali
2011-03-22 12:20 ` Sébastien Vauban
2011-03-22 12:31   ` Suvayu Ali
2011-03-22 12:56     ` Sébastien Vauban
2011-03-22 14:26       ` [PATCH] Allow mixed export of numbered and unnumbered sections in LaTeX Lawrence Mitchell
2011-03-22 22:52         ` Suvayu Ali
2011-03-23 14:04         ` [Accepted] " Bastien Guerry
2011-03-23 14:17         ` [PATCH] " Bastien
2011-03-22 14:35     ` Re: unnumbered subsections in latex export Nick Dokos
2011-03-22 23:08       ` Suvayu Ali
2011-03-22 23:21         ` Nick Dokos
2011-03-23  9:38           ` [PATCH] Allow mixed export of numbered and unnumbered sections in HTML Lawrence Mitchell
2011-03-23 14:05             ` Bastien Guerry [this message]
2011-03-23 14:57               ` [Accepted] " Nick Dokos
2011-03-23 15:50                 ` Suvayu Ali
2011-03-23 14:18           ` Re: unnumbered subsections in latex export Bastien
2011-03-23 15:02             ` Nick Dokos
2011-03-23 16:25               ` Lawrence Mitchell
2011-03-23 16:42                 ` Nick Dokos
2011-03-23 18:17                   ` Jambunathan K
2011-03-23 19:00                     ` Nick Dokos
2011-03-23 19:18                       ` Jambunathan K
2011-03-23 16:29               ` Thomas S. Dye
2011-03-23 17:42           ` Jambunathan K
2011-03-24  7:59             ` Bastien
2011-03-24 18:27               ` Achim Gratz
2011-03-24 19:25               ` Nick Dokos
2011-03-25  1:06                 ` Suvayu Ali
2011-04-04 14:39                 ` Sébastien Vauban
2011-04-04 17:04                   ` Nick Dokos
2011-04-04 20:32                   ` Aankhen
2011-04-05 10:16                     ` Sébastien Vauban
2011-04-05 19:07                       ` Aankhen
2011-04-05 19:27                         ` Eric S Fraga
2011-04-05 21:25                           ` New features for the exporters? Sébastien Vauban
2011-04-05 21:45                           ` Re: unnumbered subsections in latex export Aankhen
2011-04-06 18:49                   ` Matt Lundin
2011-04-06 20:19                     ` Sébastien Vauban
2011-03-27 11:16               ` Jambunathan K
2011-03-27 11:40                 ` Bastien
2011-03-31 21:58               ` Nicolas
2011-04-01  4:34                 ` Jambunathan K
2011-04-01  4:41                   ` Jambunathan K
2011-04-01  6:29                   ` Nick Dokos
2011-04-01 15:41                   ` Eric S Fraga
2011-04-04 14:00                     ` Matt Lundin
2011-04-04 14:12                       ` Jambunathan K
2011-04-04 16:36                         ` Matt Lundin
2011-04-04 17:09                           ` Nick Dokos
2011-04-01  7:39                 ` Jambunathan K
2011-04-01 18:25                 ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110323140504.98CE6715E@myhost.localdomain \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).