emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] unattractive list spacing in ox-html export


From: Eric Schulte
Subject: Re: [O] unattractive list spacing in ox-html export
Date: Mon, 23 Jun 2014 17:36:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Nicolas Goaziou <address@hidden> writes:

> Hello,
>
> Eric Schulte <address@hidden> writes:
>
>> When the lists with spaces in some (but not all) elements are exported
>> to HTML, they result in unattractive spacing.  This is due to the use of
>> paragraph tags in some list elements, which cause large spaces between
>> some list elements but no spaces between others.
>>
>> I believe something should be done to ensure consistent spacing in the
>> HTML export of list elements.  I'd suggest that every list element
>> should be wrapped in a paragraph tag, but maybe a different solution is
>> more appropriate.
>
> Actually, there's a special case in ox-html.el (see line 2960) that
> prevents the first paragraph in an item to get <p> tag. I guess that
> this rule is meant for short lists, e.g.,
>
>  - item 1
>  - item 2
>
> where you do not want a new paragraph for each item. So, the special
> case could be extended to also check if there's another element in the
> item before ignoring the tags.
>

This sounds like the best approach.  The attached patch implements this
change, if it looks good I'll go ahead and apply it to master.

Thanks,
Eric

>From 9af2b1c96e2062b1501cb930a1e1f95ab8c0882e Mon Sep 17 00:00:00 2001
From: Eric Schulte <address@hidden>
Date: Mon, 23 Jun 2014 17:33:18 -0400
Subject: [PATCH 1/2] inhibit <p> wraps in list for all or none

* lisp/ox-html.el (org-html-paragraph): Extend the special case of
  inhibiting <p> wrappers to only perform such inhibition when *every*
  element of the list is a single element long.  Otherwise unsightly
  spacing results.
---
 lisp/ox-html.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 762e1dc..d95ce79 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2956,7 +2956,17 @@ the plist used as a communication channel."
     (cond
      ((and (eq (org-element-type parent) 'item)
           (= (org-element-property :begin paragraph)
-             (org-element-property :contents-begin parent)))
+             (org-element-property :contents-begin parent))
+          ;; every subsequent list element is a single element long
+          (let ((gp (org-export-get-parent parent))
+                (all-singles t))
+            (org-element-map gp 'item
+              (lambda (object)
+                (let ((num-children (length (org-element-contents object))))
+                  (unless (= 1 num-children)
+                    (setq all-singles nil))))
+              info nil 'item)
+            all-singles))
       ;; Leading paragraph in a list item have no tags.
       contents)
      ((org-html-standalone-image-p paragraph info)
-- 
2.0.0

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]