emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: \newpage in HTML export
Date: Fri, 22 Nov 2013 11:24:17 +0100	[thread overview]
Message-ID: <8738mo68fi.fsf@gmail.com> (raw)
In-Reply-To: <8738moubd4.fsf_-_@ericabrahamsen.net> (Eric Abrahamsen's message of "Fri, 22 Nov 2013 14:47:03 +0700")

Hello,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Here's a fairly simple first stab, with page breaks made into an
> element, and a sample handling in the LaTeX backend. I've hardcoded ^L
> and the page-delimiter regexp that finds it, not sure it's worth
> providing an org-page-delimiter shadow. For now, use C-q C-l to insert
> the control character.

Thanks for the patch.

Anyway, I don't think this is a good idea to introduce a new syntax just
to avoid a one-liner (or a hook, see below). Also, this would only make
sense in few export back-ends.

Really, introducing new syntax has a cost, so you have to ponder if it's
really useful, because, once installed, every Org user will have to pay
the price for it.

In the same vein, we have a couple of dubious syntactical elements which
probably sound great for a few users but don't make much sense in most
cases (e.g. quote sections, which can be replaced with an example(!)
block and comments blocks, which can be replaced with a regular
comment).

Admittedly, in this particular case, that cost isn't very high, but
I think it would nonetheless add up to the list of hardly-used syntax
category.

> If this passes muster I can go through the other backends and add
> page-break handling where it makes sense. If not, I'll just keep it on
> my local branch!

You don't need such a patch. For example, you can install the following:

  (defun my-page-delimiter-hook (backend)
    (while (re-search-forward page-delimiter nil t)
      (replace-match
       (cond
        ((org-export-derived-backend-p backend 'latex)
         "#+LATEX: \\\\newpage")
        ((org-export-derived-backend-p backend 'html)
         "#+HTML: <div style=\"page-break-before: always\">&nbsp;</div>")
        ;; Ignore page delimiters in other back-ends.
        (t "")))))

  (add-hook 'org-export-before-parsing-hook 'my-page-delimiter-hook)

Obviously, you can handle as many back-ends as you see fit in
`my-page-delimiter-hook'.

Here are a few comments about the code:

>  (defconst org-element-all-objects
>    '(bold code entity export-snippet footnote-reference inline-babel-call
> -	 inline-src-block italic line-break latex-fragment link macro
> +	 inline-src-block italic line-break latex-fragment link macro page-break
>  	 radio-target statistics-cookie strike-through subscript superscript
>  	 table-cell target timestamp underline verbatim)
>    "Complete list of object types.")

Since `page-break' is an element type, you cannot make it also an object
type.

Also, you would need to update `org-element-paragraph-separate' regexp.

>  (defun org-element-paragraph-parser (limit affiliated)
> @@ -3845,6 +3879,8 @@ element it has to parse."
>  	     ;; Horizontal Rule.
>  	     ((looking-at "[ \t]*-\\{5,\\}[ \t]*$")
>  	      (org-element-horizontal-rule-parser limit affiliated))
> +	     ((looking-at page-delimiter)
> +	      (org-element-page-break-parser limit affiliated))

Using `page-delimiter' is not desirable because it implies that its
syntax is customizable, which would go against the last syntax patches
(changing defcustoms into defconsts whenever possible). Customizable
syntax cripples portability: please use it with care.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2013-11-22 10:24 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20 18:52 \newpage in HTML export Luke Crook
2013-11-20 20:10 ` Dan Griswold
2013-11-20 21:15   ` Luke Crook
2013-11-20 21:20     ` Russell Adams
2013-11-20 23:36       ` Suvayu Ali
2013-11-21  1:11         ` Eric Abrahamsen
2013-11-21  2:38           ` Jambunathan K
2013-11-21 11:17           ` Suvayu Ali
2013-11-21 14:41             ` Eric Abrahamsen
2013-11-22  7:47               ` [PATCH] " Eric Abrahamsen
2013-11-22 10:24                 ` Nicolas Goaziou [this message]
2013-11-22 12:50                   ` Rüdiger Sonderfeld
2013-11-24  9:31                     ` Nicolas Goaziou
2013-11-24 11:05                       ` Eric Abrahamsen
2013-11-24 13:58                         ` Andreas Leha
2013-12-22 13:49                           ` Nicolas Goaziou
2013-12-22 14:08                             ` Andreas Leha
2013-12-22 14:20                               ` Nicolas Goaziou
2013-12-22 14:28                                 ` Andreas Leha
2014-01-03 15:39                             ` Bastien
2014-01-03 19:29                               ` Andreas Leha
2014-01-03 19:50                                 ` Thomas S. Dye
2014-01-03 20:10                                   ` Andreas Leha
2014-01-04 10:40                                     ` Bastien
2014-01-04 12:41                                       ` Andreas Leha
2014-01-04 14:07                                         ` Bastien
2014-01-05 20:53                                       ` Suvayu Ali
2014-01-06  9:42                                         ` Bastien
2014-01-04 19:47                                     ` Sebastien Vauban
2014-01-05  6:35                                       ` Bastien
2014-01-05  9:42                                         ` Sebastien Vauban
2014-01-05 10:46                                           ` Bastien
2013-11-24 16:39                       ` Christian Moe
2013-11-23  9:28                   ` Eric Abrahamsen
2013-11-23  9:28                   ` Eric Abrahamsen
2013-11-25  9:55                 ` Jambunathan K

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=8738mo68fi.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric@ericabrahamsen.net \
    /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).