emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Sebastian Rose <sebastian_rose@gmx.de>
Cc: Emacs-orgmode mailing list <emacs-orgmode@gnu.org>
Subject: Re: [patch] Terminating lists by indentation of #+SPECIALS too
Date: Wed, 21 Apr 2010 23:21:38 +0200	[thread overview]
Message-ID: <BEB3CDEA-D203-4FEB-B9FF-322B577B1AEA@gmail.com> (raw)
In-Reply-To: <87ljcgiy96.fsf@gmx.de>

Hi Sebastion, sorry for being hard to satisfy on this one.

What I mean is this:

The location where your patck kicks in looks like this:

....
	  (org-export-html-close-lists-maybe line)

	  ;; Protected HTML
	  (when (get-text-property 0 'org-protected line)
	    (let (par (ind (get-text-property 0 'original-indentation line)))
	      (when (re-search-backward
		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
		(setq par (match-string 1))
		(replace-match "\\2\n"))
	      (insert line "\n")

So before we are looking at protected stuff, there is already a call to
org-export-html-close-lists-maybe.  It seems to me that what you are  
trying to do
could just happen inside that function.  The function checks for a  
text property
'original-indentation to check for special stuff that was indented -  
but apparently that does not cover your case.  So in that function you  
could also look at the protected property and act accordingly.

Does that make sense?

- Carsten


On Apr 21, 2010, at 6:08 PM, Sebastian Rose wrote:

> Hi Carsten,
>
>
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>> Hi Sebastian,
>>
>> I am not sure I understand this patch fully.  And it looks to me  
>> that this
>> should be taken care of in `org-export-html-close-list-maybe'.  
>> Could you take
>> another look and check if this could be easily moved  into there?   
>> I am confused
>> why this is inside the when clause about  protectedness of the line.
>
>
> I was aware of the function `org-export-html-close-list-maybe' but I
> couldn't get that to work. Now got it to work by adding a new  
> parameter
> to that function, saying, that it's first argument is raw HTML (see  
> new
> patch below).
>
>
> There was another problem about paragraphs.
> In this file, "*List ONE*" was wrapped in "<p></p>", while "*List  
> TWO*"
> was not:
>
> * Some Lists
>
>  #+HTML: <div style="width:48%;float:left;">
>
>  *List ONE*
>    - Item one
>    - Item two
>
>  #+html: </div>
>  #+html: <div style="width:48%;float:right;">
>
>  *List TWO*
>    - Item one
>    - Item two
>
>  #+HTML: </div>
>
> The new patch fixes this, too. That is, what the new
> `org-open-par-maybe' is for. It's a corner case and I should keep it
> for testing.
>
>
>
>
> I published all my org-notes (more than 100 files) to HTML and they
> validate better then before. So the patch might be save to apply.
>
>
>
>
>
>
> --- lisp/org-html.el	2010-04-21 17:02:18.000000000 +0200
> +++ lisp/org-html-versuch-mit-rawhtml.el	2010-04-21  
> 17:50:10.000000000 +0200
> @@ -929,6 +929,12 @@
>
> 	  ;; Protected HTML
> 	  (when (get-text-property 0 'org-protected line)
> +        (when in-local-list
> +          (org-export-html-close-lists-maybe line t)
> +          (insert line "\n")
> +          (throw 'nextline nil))
> +
> +
> 	    (let (par (ind (get-text-property 0 'original-indentation line)))
> 	      (when (re-search-backward
> 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
> @@ -959,10 +965,12 @@
> 	  (when (equal "ORG-VERSE-START" line)
> 	    (org-close-par-maybe)
> 	    (insert "\n<p class=\"verse\">\n")
> +        (setq org-par-open t)
> 	    (setq inverse t)
> 	    (throw 'nextline nil))
> 	  (when (equal "ORG-VERSE-END" line)
> 	    (insert "</p>\n")
> +        (setq org-par-open nil)
> 	    (org-open-par)
> 	    (setq inverse nil)
> 	    (throw 'nextline nil))
> @@ -986,6 +994,8 @@
> 	      (unless (string-match "\\\\\\\\[ \t]*$" line)
> 		(setq line (concat line "\\\\")))))
>
> +      (org-open-par-maybe)
> +
> 	  ;; make targets to anchors
> 	  (setq start 0)
> 	  (while (string-match
> @@ -1982,6 +1992,11 @@
>   (org-close-par-maybe)
>   (insert "\n<p>")
>   (setq org-par-open t))
> +(defun org-open-par-maybe ()
> +  "Insert <p>, but only if no paragraph is open."
> +  (when (not org-par-open)
> +    (insert "\n<p>")
> +    (setq org-par-open t)))
> (defun org-close-par-maybe ()
>   "Close paragraph if there is one open."
>   (when org-par-open
> @@ -1995,15 +2010,20 @@
> (defvar in-local-list)
> (defvar local-list-indent)
> (defvar local-list-type)
> -(defun org-export-html-close-lists-maybe (line)
> -  (let ((ind (or (get-text-property 0 'original-indentation line)))
> +(defun org-export-html-close-lists-maybe (line &optional rawhtml)
> +  "RAWHTML suppresses paragraphs and checks the indentation for
> +`#+SPECIAL:' lines."
> +  (let ((ind
> +         (if rawhtml
> +             (org-get-indentation line)
> +           (or (get-text-property 0 'original-indentation line))))
> ;		 (and (string-match "\\S-" line)
> ;		      (org-get-indentation line))))
> 	didclose)
>     (when ind
>       (while (and in-local-list
> 		  (<= ind (car local-list-indent)))
> -	(setq didclose t)
> +	(setq didclose (not rawhtml))
> 	(org-close-li (car local-list-type))
> 	(insert (format "</%sl>\n" (car local-list-type)))
> 	(pop local-list-type) (pop local-list-indent)
>
>
>
>
>
>
>
>
>    Sebastian
>
>
>
>
>
>
>> But I may have just lost my memory of how this works....
>>
>> - Carsten
>>
>> On Apr 19, 2010, at 1:54 AM, Sebastian Rose wrote:
>>
>>> Haaarrrgh ---
>>>
>>>
>>> the first patch in my previous mail does not work for all cases.  
>>> Hairy
>>> stuff....
>>>
>>>
>>> Here's what did _not_ work with my previous patch:
>>>
>>> #+html: <div style="width:48%;float:right;">
>>> *Unsorted Patterns*
>>>   - a
>>>   - b
>>>   - c
>>>         #+HTML: <br /><b>Somthing inside the last item!!!</b>
>>> #+HTML: </div>
>>>
>>>
>>>
>>>
>>>
>>> But this one finally works:
>>>
>>>
>>> diff --git a/lisp/org-html.el b/lisp/org-html.el
>>> index fcddd50..0174e43 100644
>>> --- a/lisp/org-html.el
>>> +++ b/lisp/org-html.el
>>> @@ -929,6 +929,17 @@ lang=\"%s\" xml:lang=\"%s\">
>>>
>>> 	  ;; Protected HTML
>>> 	  (when (get-text-property 0 'org-protected line)
>>> +        (when in-local-list
>>> +          (let ((ind (org-get-indentation line)))
>>> +            (while (and (car local-list-indent) (< ind (car local-
>>> list-indent)))
>>> +              (org-close-li (car local-list-type))
>>> +              (insert (format "</%sl>\n" (car local-list-type)))
>>> +              (setq local-list-indent (cdr local-list-indent))
>>> +              (setq local-list-type (cdr local-list-type))
>>> +              (setq in-local-list local-list-indent))
>>> +            (insert line "\n")
>>> +            (throw 'nextline nil)))
>>> +
>>> 	    (let (par (ind (get-text-property 0 'original-indentation  
>>> line)))
>>> 	      (when (re-search-backward
>>> 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
>>>
>>>
>>> Again: If it makes things easier, I could apply the change to the  
>>> master
>>> branch and send an appropriate patch.
>>>
>>>
>>>
>>>
>>>
>>>   Sebastian
>>>
>>>
>>>
>>>
>>>
>>>
>>> Sebastian Rose <sebastian_rose@gmx.de> writes:
>>>> Hello Carsten,
>>>>
>>>>
>>>> there was much discussion about a terminator and I ran into a  
>>>> problem,
>>>> that made me think we need one. But then I found we had one ---  
>>>> it's
>>>> just not used on HTML export.
>>>>
>>>>
>>>> Below is a little file I wrote. Thanks to the `- __' items, it  
>>>> results
>>>> in the XHTML closely to what I wanted it to.
>>>> But only as long as I use those _undocumented_ `- __' items. Once  
>>>> you
>>>> remove them, you'll see, that the `#+html: </div...' stuff ends up
>>>> inside the last list item and the XHTML will not validate.
>>>>
>>>>
>>>> As I looked at it, I found the most natural solution would be, to
>>>> terminate the list by regarding the indentation of `#+WHATEVER' and
>>>> `#+BEGIN_WHATEVER' if inside lists [fn:1].
>>>>
>>>>
>>>>
>>>> The patch below (diffed against `remove-compatibility-code') makes
>>>> XHTML-export honor the indentation of `#+SPECIALS'.
>>>>
>>>>
>>>>
>>>> Here's the Org-file I wrote (remove and add the `- __' list items  
>>>> to see
>>>> the effect):
>>>>
>>>>
>>>> #+OPTIONS: toc:nil
>>>> #+STYLE: <style type="text/css">
>>>> #+STYLE: body,p,div,td{font-size:13px;font-family:sans-serif;}
>>>> #+STYLE: div { text-align:left; }
>>>> #+STYLE: #content {width:550px;
>>>> #+STYLE:     margin-left:auto;margin-right:auto;text- 
>>>> align:center; }
>>>> #+STYLE: #postamble { width:550px;clear:both;border-top:1px solid  
>>>> black;
>>>> #+STYLE:      margin-left:auto;margin-right:auto;text- 
>>>> align:center; }
>>>> #+STYLE: </style>
>>>>
>>>> * List of design patterns
>>>>
>>>> #+HTML: <div style="width:48%;float:left;">
>>>> *Behavioural Patterns*
>>>>   - [[file:BatchCommand][BatchCommand]]
>>>>   - [[file:ChainOfResponsibility.org][Chain Of Responsibility]]
>>>>   - [[file:Command.org][Command]], UndoableCommand and BatchCommand
>>>>   - [[file:Interpreter.org][Interpreter]]
>>>>   - [[file:Iterator.org][Iterator]]
>>>>   - [[file:Mediator.org][Mediator]]
>>>>   - [[file:Memento.org][Memento]]
>>>>   - [[file:NullObject][NullObject]]
>>>>   - [[file:Observer.org][Observer]]
>>>>   - [[file:State.org][State]]
>>>>   - [[file:Strategy.org][Strategy]]
>>>>   - [[file:TemplateMethod.org][Template Method]]
>>>>   - [[file:Visitor.org][Visitor]]
>>>> *Creational Patterns*
>>>>   - [[file:AbstractFactory.org][Abstract Factory]]
>>>>   - [[file:Builder.org][Builder]]
>>>>   - [[file:Factory.org][Factory]]
>>>>   - [[file:FactoryMethod.org][Factory Method]]
>>>>   - [[file:Prototype.org][Prototype]]
>>>>   - [[file:Singleton.org][Singleton]]
>>>>   - __
>>>> #+html: </div>
>>>> #+html: <div style="width:48%;float:right;">
>>>> *Structural Patterns*
>>>>   - [[file:Adapter.org][Adapter]]
>>>>   - [[file:Composite.org][Composite]]
>>>>   - [[file::Bridge.org][Bridge]]
>>>>   - [[file:Decorator.org][Decorator]]
>>>>   - [[file:Facade.org][Facade]]
>>>>   - [[file:Flyweight.org][Flyweight]]
>>>>   - [[file:Proxy.org][Proxy]]
>>>> *Unsorted*
>>>>   - [[file:BusinessDelegate.org][Business Delegate]]
>>>>   - [[file:DataAccessObject.org][Data Access Object]]
>>>>   - [[file:DataTransferObject.org][Data Transfer Object]]
>>>>   - [[file:DependencyInjection.org][Dependency Injection]]
>>>>   - [[file:FluentInterface.org][Fluent Interface]]
>>>>   - [[file:InversionOfControl.org][Inversion Of Control]]
>>>>   - [[file:ModelViewControler.org][Model View Controler]]
>>>>   - [[file:ModelViewPresenter.org][Model View Presenter]]
>>>>   - [[file:Plugin.org][Plugin]]
>>>>   - __
>>>> #+HTML: </div>
>>>>
>>>>
>>>>
>>>> And, finally, the patch. I would have used the function
>>>> `org-export-html-close-lists-maybe' but that didn't work, so I  
>>>> wrote
>>>> similar code just in place.
>>>>
>>>> Carsten: If it makes things easier for you, I could apply the  
>>>> change to
>>>> the master branch and send an appropriate patch.
>>>>
>>>>
>>>> diff --git a/lisp/org-html.el b/lisp/org-html.el
>>>> index fcddd50..812e63c 100644
>>>> --- a/lisp/org-html.el
>>>> +++ b/lisp/org-html.el
>>>> @@ -929,6 +929,15 @@ lang=\"%s\" xml:lang=\"%s\">
>>>>
>>>> 	  ;; Protected HTML
>>>> 	  (when (get-text-property 0 'org-protected line)
>>>> +        (when in-local-list
>>>> +          (let ((ind (or (get-text-property 0 'original-
>>>> indentation line) 0)))
>>>> +            (while (and (car local-list-indent) (< ind (car local-
>>>> list-indent)))
>>>> +              (org-close-li (car local-list-type))
>>>> +              (insert (format "</%sl>\n" (car local-list-type)))
>>>> +              (setq local-list-indent (cdr local-list-indent))
>>>> +              (setq local-list-type (cdr local-list-type))
>>>> +              (setq in-local-list local-list-indent))))
>>>> +
>>>> 	    (let (par (ind (get-text-property 0 'original-indentation  
>>>> line)))
>>>> 	      (when (re-search-backward
>>>> 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Best wishes
>>>>
>>>>    Sebastian
>>>>
>>>>
>>>>
>>>>
>>>> Footnotes:
>>>>
>>>> [fn:1] `org-end-of-item' and `org-end-of-item-list' already  
>>>> consider the
>>>>      decreased indentation of the `#+html:' line the end of the  
>>>> list.
>>>>
>>>>      You can proof that by deleting the last dot and all empty  
>>>> lines,
>>>>      so that the `#+html:' line is directly below the last list
>>>>      item. Then move point somewhere on the item and do `M-x
>>>>      org-end-of-item RET'.
>>>>
>>>> _______________________________________________
>>>> Emacs-orgmode mailing list
>>>> Please use `Reply All' to send replies to the list.
>>>> Emacs-orgmode@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>> - Carsten
>>
>>
>>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Sebastian  Rose      Fachinformatiker / Anwendungsentwicklung
> Viktoriastr. 22      Entwicklung von Anwendungen mit freien Werkzeugen
> 30451  Hannover      und Bibliotheken.
>
> 0173  83 93 417      sebastian_rose@gmx.de         s.rose@emma-stil.de
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Carsten

  reply	other threads:[~2010-04-21 21:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-18 23:01 [patch] Terminating lists by indentation of #+SPECIALS too Sebastian Rose
2010-04-18 23:54 ` Sebastian Rose
2010-04-21  7:59   ` Carsten Dominik
2010-04-21 16:08     ` Sebastian Rose
2010-04-21 21:21       ` Carsten Dominik [this message]
2010-04-22  1:26         ` Sebastian Rose
2010-04-22  8:22           ` Carsten Dominik
2010-04-22  9:09             ` Sebastian Rose
2010-04-22  9:44               ` Carsten Dominik

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=BEB3CDEA-D203-4FEB-B9FF-322B577B1AEA@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sebastian_rose@gmx.de \
    /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).