From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Re: \newpage in HTML export Date: Fri, 22 Nov 2013 11:24:17 +0100 Message-ID: <8738mo68fi.fsf@gmail.com> References: <20131120212002.GC5155@cardamom.adamsinfoserv.com> <20131120233629.GD19844@kuru.dyndns-at-home.com> <87r4aav9rd.fsf@ericabrahamsen.net> <20131121111730.GA4103@kuru.dyndns-at-home.com> <87ob5du8ai.fsf@ericabrahamsen.net> <8738moubd4.fsf_-_@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjnu8-0000Nt-M3 for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 05:24:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vjnu3-0005Ct-0c for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 05:24:04 -0500 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:59123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjnu2-0005CF-P1 for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 05:23:58 -0500 Received: by mail-ee0-f50.google.com with SMTP id e53so502373eek.37 for ; Fri, 22 Nov 2013 02:23:57 -0800 (PST) In-Reply-To: <8738moubd4.fsf_-_@ericabrahamsen.net> (Eric Abrahamsen's message of "Fri, 22 Nov 2013 14:47:03 +0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Abrahamsen Cc: emacs-orgmode@gnu.org Hello, Eric Abrahamsen 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:
 
") ;; 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