* Org-special-blogs does not make well-formed xhtml @ 2011-10-03 12:44 Christian Moe 2011-10-03 13:26 ` Sebastien Vauban 0 siblings, 1 reply; 9+ messages in thread From: Christian Moe @ 2011-10-03 12:44 UTC (permalink / raw) To: Org Mode Hi, XHTML produced with Org-special-blocks is not well-formed; <div> tags get wrapped in <p> tags. Example: Some text. #+begin_sidebar Some details left out of the main text. Some more details. #+end_sidebar Some more text. This results in the following html, which causes XML processors to fail. <p> <div class="sidebar"> Some details left out of the main text. </p> <p> Some more details. </div> </p> <p> Some more text. </p></div> The problem seems to be fixed by un-commenting the fifth line in the below function in org-special-blocks.el: (defun org-special-blocks-convert-html-special-cookies () "Converts the special cookies into div blocks." ;; Uses the dynamically-bound variable `line'. (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line) ; (org-close-par-maybe) (message "%s" (match-string 1)) (if (equal (match-string 2 line) "START") (insert "<div class=\"" (match-string 1 line) "\">\n") (insert "</div>\n")) (throw 'nextline nil))) Does anyone know if that was commented out for a reason? Yours, Christian ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-03 12:44 Org-special-blogs does not make well-formed xhtml Christian Moe @ 2011-10-03 13:26 ` Sebastien Vauban 2011-10-04 11:23 ` Carsten Dominik 0 siblings, 1 reply; 9+ messages in thread From: Sebastien Vauban @ 2011-10-03 13:26 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Christian Moe, Christian Moe wrote: > Hi, > > XHTML produced with Org-special-blocks is not well-formed; <div> tags > get wrapped in <p> tags. Example: > > Some text. > > #+begin_sidebar > Some details left out of the main text. > > Some more details. > #+end_sidebar > > Some more text. > > This results in the following html, which causes XML processors to fail. > > <p> > <div class="sidebar"> > Some details left out of the main text. > </p> > <p> > Some more details. > </div> > </p> > <p> > Some more text. > </p></div> > > The problem seems to be fixed by un-commenting the fifth line in the > below function in org-special-blocks.el: > > (defun org-special-blocks-convert-html-special-cookies () > "Converts the special cookies into div blocks." > ;; Uses the dynamically-bound variable `line'. > (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line) > ; (org-close-par-maybe) > (message "%s" (match-string 1)) > (if (equal (match-string 2 line) "START") > (insert "<div class=\"" (match-string 1 line) "\">\n") > (insert "</div>\n")) > (throw 'nextline nil))) > > Does anyone know if that was commented out for a reason? git blame suggests it was there since that file org-special-blocks.el has been added (in contrib/lisp, by Carsten, on 2009-05-07 13:53)... Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-03 13:26 ` Sebastien Vauban @ 2011-10-04 11:23 ` Carsten Dominik 2011-10-04 12:45 ` Christian Moe 2011-10-04 14:36 ` Jambunathan K 0 siblings, 2 replies; 9+ messages in thread From: Carsten Dominik @ 2011-10-04 11:23 UTC (permalink / raw) To: Sebastien Vauban; +Cc: emacs-orgmode On Oct 3, 2011, at 3:26 PM, Sebastien Vauban wrote: > Hi Christian Moe, > > Christian Moe wrote: >> Hi, >> >> XHTML produced with Org-special-blocks is not well-formed; <div> tags >> get wrapped in <p> tags. Example: >> >> Some text. >> >> #+begin_sidebar >> Some details left out of the main text. >> >> Some more details. >> #+end_sidebar >> >> Some more text. >> >> This results in the following html, which causes XML processors to fail. >> >> <p> >> <div class="sidebar"> >> Some details left out of the main text. >> </p> >> <p> >> Some more details. >> </div> >> </p> >> <p> >> Some more text. >> </p></div> >> >> The problem seems to be fixed by un-commenting the fifth line in the >> below function in org-special-blocks.el: >> >> (defun org-special-blocks-convert-html-special-cookies () >> "Converts the special cookies into div blocks." >> ;; Uses the dynamically-bound variable `line'. >> (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line) >> ; (org-close-par-maybe) >> (message "%s" (match-string 1)) >> (if (equal (match-string 2 line) "START") >> (insert "<div class=\"" (match-string 1 line) "\">\n") >> (insert "</div>\n")) >> (throw 'nextline nil))) >> >> Does anyone know if that was commented out for a reason? > > git blame suggests it was there since that file org-special-blocks.el has been > added (in contrib/lisp, by Carsten, on 2009-05-07 13:53)... > > Best regards, > Seb > > -- > Sebastien Vauban > > I see no reason to not uncomment this line. Shall we just do this? - Carsten ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 11:23 ` Carsten Dominik @ 2011-10-04 12:45 ` Christian Moe 2011-10-04 14:22 ` Carsten Dominik 2011-10-04 14:36 ` Jambunathan K 1 sibling, 1 reply; 9+ messages in thread From: Christian Moe @ 2011-10-04 12:45 UTC (permalink / raw) To: Carsten Dominik; +Cc: Sebastien Vauban, emacs-orgmode >> > > I see no reason to not uncomment this line. Shall we just do this? > > > > - Carsten Yes, would you, please? Yours, Christian ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 12:45 ` Christian Moe @ 2011-10-04 14:22 ` Carsten Dominik 0 siblings, 0 replies; 9+ messages in thread From: Carsten Dominik @ 2011-10-04 14:22 UTC (permalink / raw) To: mail; +Cc: Sebastien Vauban, emacs-orgmode Done... - Carsten On Oct 4, 2011, at 2:45 PM, Christian Moe wrote: > >>> >> >> I see no reason to not uncomment this line. Shall we just do this? >> >> >> >> - Carsten > > Yes, would you, please? > > Yours, > Christian > - Carsten ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 11:23 ` Carsten Dominik 2011-10-04 12:45 ` Christian Moe @ 2011-10-04 14:36 ` Jambunathan K 2011-10-04 19:01 ` Christian Moe 1 sibling, 1 reply; 9+ messages in thread From: Jambunathan K @ 2011-10-04 14:36 UTC (permalink / raw) To: Carsten Dominik; +Cc: Sebastien Vauban, emacs-orgmode Carsten Dominik <carsten.dominik@gmail.com> writes: > On Oct 3, 2011, at 3:26 PM, Sebastien Vauban wrote: > >> Hi Christian Moe, >> >> Christian Moe wrote: >>> Hi, >>> >>> XHTML produced with Org-special-blocks is not well-formed; <div> tags >>> get wrapped in <p> tags. Example: >>> >>> Some text. >>> >>> #+begin_sidebar >>> Some details left out of the main text. >>> >>> Some more details. >>> #+end_sidebar >>> >>> Some more text. >>> >>> This results in the following html, which causes XML processors to fail. >>> >>> <p> >>> <div class="sidebar"> >>> Some details left out of the main text. >>> </p> >>> <p> >>> Some more details. >>> </div> >>> </p> >>> <p> >>> Some more text. >>> </p></div> >>> >>> The problem seems to be fixed by un-commenting the fifth line in the >>> below function in org-special-blocks.el: >>> >>> (defun org-special-blocks-convert-html-special-cookies () >>> "Converts the special cookies into div blocks." >>> ;; Uses the dynamically-bound variable `line'. >>> (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line) >>> ; (org-close-par-maybe) >>> (message "%s" (match-string 1)) >>> (if (equal (match-string 2 line) "START") >>> (insert "<div class=\"" (match-string 1 line) "\">\n") >>> (insert "</div>\n")) >>> (throw 'nextline nil))) >>> >>> Does anyone know if that was commented out for a reason? >> >> git blame suggests it was there since that file org-special-blocks.el has been >> added (in contrib/lisp, by Carsten, on 2009-05-07 13:53)... >> >> Best regards, >> Seb >> >> -- >> Sebastien Vauban >> >> > > I see no reason to not uncomment this line. Shall we just do this? Shouldn't a paragraph be opened/closed while entering/leaving the div. ,---- See org-xhtml-format-environment | (center | (case beg-end | (BEGIN | (org-lparse-end-paragraph) | (insert "\n<div style=\"text-align: center\">") | (org-lparse-begin-paragraph)) | (END | (org-lparse-end-paragraph) | (insert "\n</div>") | (org-lparse-begin-paragraph)))) `---- We can always open a paragraph gratis, because empty paragraphs are pruned at the end of export. ps: I haven't gotten myself to understand when paragraphs are opened and closed in the html exporter. So we can take a leaf out of the centering environment and mimic the same behaviour with the special blocks as well. > - Carsten > > > > > -- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 14:36 ` Jambunathan K @ 2011-10-04 19:01 ` Christian Moe 2011-10-04 21:33 ` Carsten Dominik 0 siblings, 1 reply; 9+ messages in thread From: Christian Moe @ 2011-10-04 19:01 UTC (permalink / raw) To: Carsten Dominik, Sebastien Vauban, emacs-orgmode Hi, Carsten, thanks. Jambunathan's probably right, though, that this fix (while necessary) is incomplete. Sorry, I hadn't thought it through. Now, when the first paragraph of a special block comes right after the #+BEGIN_WHATEVER line, it will just come as the first text node of the <div> block, and will not be wrapped in a <p> element. So among other things, any special CSS styling for <p>s will not be applied to it. It's not a big deal -- if you need a <p> (and often you really don't) the workaround is as simple as leaving an empty line between #+BEGIN_WHATEVER and the first paragraph. But I guess it would be more consistent/expected/helpful behavior for special-blocks to start a new paragraph -- this time *after* the opening <div> tag and not around it! Yours, Christian On 10/4/11 4:36 PM, Jambunathan K wrote: > > Carsten Dominik<carsten.dominik@gmail.com> writes: >> I see no reason to not uncomment this line. Shall we just do this? > > Shouldn't a paragraph be opened/closed while entering/leaving the div. > > ,---- See org-xhtml-format-environment > | (center > | (case beg-end > | (BEGIN > | (org-lparse-end-paragraph) > | (insert "\n<div style=\"text-align: center\">") > | (org-lparse-begin-paragraph)) > | (END > | (org-lparse-end-paragraph) > | (insert "\n</div>") > | (org-lparse-begin-paragraph)))) > `---- > > We can always open a paragraph gratis, because empty paragraphs are > pruned at the end of export. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 19:01 ` Christian Moe @ 2011-10-04 21:33 ` Carsten Dominik 2011-10-06 10:17 ` Christian Moe 0 siblings, 1 reply; 9+ messages in thread From: Carsten Dominik @ 2011-10-04 21:33 UTC (permalink / raw) To: mail; +Cc: Sebastien Vauban, emacs-orgmode Hi Christian, for now I have reverted the patch. WOuld you like to work on a better one? - Carsten On 4.10.2011, at 21:01, Christian Moe wrote: > Hi, > > Carsten, thanks. > > Jambunathan's probably right, though, that this fix (while necessary) is incomplete. Sorry, I hadn't thought it through. > > Now, when the first paragraph of a special block comes right after the #+BEGIN_WHATEVER line, it will just come as the first text node of the <div> block, and will not be wrapped in a <p> element. So among other things, any special CSS styling for <p>s will not be applied to it. > > It's not a big deal -- if you need a <p> (and often you really don't) the workaround is as simple as leaving an empty line between #+BEGIN_WHATEVER and the first paragraph. > > But I guess it would be more consistent/expected/helpful behavior for special-blocks to start a new paragraph -- this time *after* the opening <div> tag and not around it! > > Yours, > Christian > > > On 10/4/11 4:36 PM, Jambunathan K wrote: >> >> Carsten Dominik<carsten.dominik@gmail.com> writes: >>> I see no reason to not uncomment this line. Shall we just do this? >> >> Shouldn't a paragraph be opened/closed while entering/leaving the div. >> >> ,---- See org-xhtml-format-environment >> | (center >> | (case beg-end >> | (BEGIN >> | (org-lparse-end-paragraph) >> | (insert "\n<div style=\"text-align: center\">") >> | (org-lparse-begin-paragraph)) >> | (END >> | (org-lparse-end-paragraph) >> | (insert "\n</div>") >> | (org-lparse-begin-paragraph)))) >> `---- >> >> We can always open a paragraph gratis, because empty paragraphs are >> pruned at the end of export. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org-special-blogs does not make well-formed xhtml 2011-10-04 21:33 ` Carsten Dominik @ 2011-10-06 10:17 ` Christian Moe 0 siblings, 0 replies; 9+ messages in thread From: Christian Moe @ 2011-10-06 10:17 UTC (permalink / raw) To: Carsten Dominik; +Cc: Sebastien Vauban, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2203 bytes --] Hi, Carsten, I've submitted a patch separately. It seems to play nice with the enclosed test file. If org-special-blocks is supposed to become part of the core (it's moved out of contrib, but we still have to require it), it might make sense to just move the html and latex formatting code into org-html.el and org-latex.el respectively, together with the handling of blockquotes, verses, centering etc. Yours, Christian On 10/4/11 11:33 PM, Carsten Dominik wrote: > Hi Christian, > > for now I have reverted the patch. WOuld you like to work on a better one? > > - Carsten > > On 4.10.2011, at 21:01, Christian Moe wrote: > >> Hi, >> >> Carsten, thanks. >> >> Jambunathan's probably right, though, that this fix (while necessary) is incomplete. Sorry, I hadn't thought it through. >> >> Now, when the first paragraph of a special block comes right after the #+BEGIN_WHATEVER line, it will just come as the first text node of the<div> block, and will not be wrapped in a<p> element. So among other things, any special CSS styling for<p>s will not be applied to it. >> >> It's not a big deal -- if you need a<p> (and often you really don't) the workaround is as simple as leaving an empty line between #+BEGIN_WHATEVER and the first paragraph. >> >> But I guess it would be more consistent/expected/helpful behavior for special-blocks to start a new paragraph -- this time *after* the opening<div> tag and not around it! >> >> Yours, >> Christian >> >> >> On 10/4/11 4:36 PM, Jambunathan K wrote: >>> >>> Carsten Dominik<carsten.dominik@gmail.com> writes: >>>> I see no reason to not uncomment this line. Shall we just do this? >>> >>> Shouldn't a paragraph be opened/closed while entering/leaving the div. >>> >>> ,---- See org-xhtml-format-environment >>> | (center >>> | (case beg-end >>> | (BEGIN >>> | (org-lparse-end-paragraph) >>> | (insert "\n<div style=\"text-align: center\">") >>> | (org-lparse-begin-paragraph)) >>> | (END >>> | (org-lparse-end-paragraph) >>> | (insert "\n</div>") >>> | (org-lparse-begin-paragraph)))) >>> `---- >>> >>> We can always open a paragraph gratis, because empty paragraphs are >>> pruned at the end of export. > > > [-- Attachment #2: special-blocks-test.org --] [-- Type: text/plain, Size: 1612 bytes --] #+style: <style>.abstract:before { content: "Abstract: "; font-weight: bold; display: inline} #+style: .abstract {font-size: 10pt; margin-left: 3em} #+style: .sidebar {border: 1px solid black; padding: 1em; background: yellow; counter-increment: box} #+style: .sidebar:before {content: "Box " counter(box); font-weight: bold; display: block} #+style: p {font-family: arial}</style Special blocks test #+begin_src emacs-lisp (require 'org-special-blocks) #+end_src #+results: : org-special-blocks #+begin_abstract This is a special =abstract= block. #+end_abstract Some text. #+begin_sidebar This is a sidebar with additional detail. Check that the first paragraph is styled the same as the others. It extends over several paragraphs. #+end_sidebar Some more text. #+begin_sidebar This is another example with lines above/below. #+end_sidebar Text again. #+begin_center This is centered text. Like special blocks, it's wrapped in a =div= element in HTML. #+end_center New code: #+begin_src emacs-lisp (defun org-special-blocks-convert-html-special-cookies () "Converts the special cookies into div blocks." ;; Uses the dynamically-bound variable `line'. (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line) (message "%s" (match-string 1)) (when (equal (match-string 2 line) "START") (org-close-par-maybe) (insert "\n<div class=\"" (match-string 1 line) "\">") (org-open-par)) (when (equal (match-string 2 line) "END") (org-close-par-maybe) (insert "\n</div>") (org-open-par)) (throw 'nextline nil))) #+end_src ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-10-06 10:14 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-03 12:44 Org-special-blogs does not make well-formed xhtml Christian Moe 2011-10-03 13:26 ` Sebastien Vauban 2011-10-04 11:23 ` Carsten Dominik 2011-10-04 12:45 ` Christian Moe 2011-10-04 14:22 ` Carsten Dominik 2011-10-04 14:36 ` Jambunathan K 2011-10-04 19:01 ` Christian Moe 2011-10-04 21:33 ` Carsten Dominik 2011-10-06 10:17 ` Christian Moe
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).