emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Include mechanism for web publishing
@ 2009-07-28 22:38 Israel Herraiz
  2009-07-29  0:38 ` Michael Zeller
  0 siblings, 1 reply; 5+ messages in thread
From: Israel Herraiz @ 2009-07-28 22:38 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I use org-mode for web publishing. My web contains four pages that
share a common (HTML) header, with some links to the different
sections of the web and other stuff.

At some point, I decided to include a common raw HTML in every
page. This raw HTML is Javascript stuff for visits counting using
Google Analytics.

That file is included in every page right after the title, using
#+INCLUDE header/header.org.

Everything was working fine when I had just links, but now that I have
included the #+BEGIN_HTML stuff, it is escaped when exporting
everything to HTML, and instead of my raw HTML in the output files I
get a line starting by ",#+BEGIN..." (properly written and escaped in
HTML; notice the initial comma).

I though of #+INCLUDE as a sort of C's #include, i.e. it just copies
the text of the included file in the line where #+INCLUDE is. However
this seems not to be the case.

I have found in the list a discussion about how to insert source code
in HTML outputs, without inserting the initial commas, which confirms
that included org files are escaped when exporting to HTML:

  http://thread.gmane.org/gmane.emacs.orgmode/15707

I have also found this approach to include files approach, that I have
tried without success: nothing is shown in the HTML output (see second
message in the thread):

  http://thread.gmane.org/gmane.emacs.orgmode/4127

Is there any way to do a plain (no escape) import of org files?

Cheers,
Israel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Include mechanism for web publishing
  2009-07-28 22:38 Include mechanism for web publishing Israel Herraiz
@ 2009-07-29  0:38 ` Michael Zeller
  2009-07-29  0:53   ` Michael Zeller
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zeller @ 2009-07-29  0:38 UTC (permalink / raw)
  To: Israel Herraiz; +Cc: emacs-orgmode

Israel Herraiz <isra@herraiz.org> writes:

> Hi all,
>
> I use org-mode for web publishing. My web contains four pages that
> share a common (HTML) header, with some links to the different
> sections of the web and other stuff.
>
> At some point, I decided to include a common raw HTML in every
> page. This raw HTML is Javascript stuff for visits counting using
> Google Analytics.
>
> That file is included in every page right after the title, using
> #+INCLUDE header/header.org.
>
> Everything was working fine when I had just links, but now that I have
> included the #+BEGIN_HTML stuff, it is escaped when exporting
> everything to HTML, and instead of my raw HTML in the output files I
> get a line starting by ",#+BEGIN..." (properly written and escaped in
> HTML; notice the initial comma).

I had the exact same issue last night, and oddly enough, it used to work
in 6.21b, which is what comes with CVS emacs!

Anyways, here is what I changed so that you can do an #+INCLUDE
header/header.org org to include as raw Org. Personally, I'd like the
default to be Org, but I see why it was changed. 

diff --git a/doc/org.texi b/doc/org.texi
index e28b185..43cd2ab 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -8262,13 +8262,15 @@ include your @file{.emacs} file, you could use:
 @end example
 @noindent
 The optional second and third parameter are the markup (@samp{quote},
-@samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
-language for formatting the contents.  The markup is optional, if it is not
-given, the text will be assumed to be in Org mode format and will be
-processed normally.  The include line will also allow additional keyword
-parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
-first line and for each following line, as well as any options accepted by
-the selected markup.  For example, to include a file as an item, use
+@samp{example}, @samp{org}, or @samp{src}), and, if the markup is @samp{src},
+the language for formatting the contents. If the markup is @samp{org}, the
+text will be assumed to be in Org mode format and will be processed
+normally. The markup is optional, if it is not given, the text will be
+included as is and any Org markup will be escaped.  The include line will
+also allow additional keyword parameters @code{:prefix1} and @code{:prefix}
+to specify prefixes for the first line and for each following line, as well
+as any options accepted by the selected markup.  For example, to include a
+file as an item, use
 
 @example
 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 280b1f4..83f9b74 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2085,13 +2085,14 @@ TYPE must be a string, any of:
              (not (file-readable-p file)))
          (insert (format "CANNOT INCLUDE FILE %s" file))
        (when markup
- (if (equal (downcase markup) "src")
- (setq start (format "#+begin_src %s %s\n"
- (or lang "fundamental")
- (or switches ""))
- end "#+end_src")
- (setq start (format "#+begin_%s %s\n" markup switches)
- end  (format "#+end_%s" markup))))
- (cond ((equal (downcase markup) "src")
- (setq start (format "#+begin_src %s %s\n"
- (or lang "fundamental")
- (or switches ""))
- end "#+end_src"))
- ((equal (downcase markup) "org") nil)
- (t (setq start (format "#+begin_%s %s\n" markup switches)
- end  (format "#+end_%s" markup)))))
        (insert (or start ""))
        (insert (org-get-file-contents (expand-file-name file) prefix prefix1 markup))
        (or (bolp) (newline))

I hope that helps!
~Michael Zeller

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Include mechanism for web publishing
  2009-07-29  0:38 ` Michael Zeller
@ 2009-07-29  0:53   ` Michael Zeller
  2009-07-29 14:08     ` Israel Herraiz
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zeller @ 2009-07-29  0:53 UTC (permalink / raw)
  To: Michael Zeller; +Cc: emacs-orgmode

Opps, for some reason the important portion didn't copy. You'll have to
forgive me, I'm still learning gnus.

Michael Zeller <michael.dylan.zeller@gmail.com> writes:

> diff --git a/doc/org.texi b/doc/org.texi
> index e28b185..43cd2ab 100644
> --- a/doc/org.texi
> +++ b/doc/org.texi
> @@ -8262,13 +8262,15 @@ include your @file{.emacs} file, you could use:
>  @end example
>  @noindent
>  The optional second and third parameter are the markup (@samp{quote},
> -@samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
> -language for formatting the contents.  The markup is optional, if it is not
> -given, the text will be assumed to be in Org mode format and will be
> -processed normally.  The include line will also allow additional keyword
> -parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
> -first line and for each following line, as well as any options accepted by
> -the selected markup.  For example, to include a file as an item, use
> +@samp{example}, @samp{org}, or @samp{src}), and, if the markup is @samp{src},
> +the language for formatting the contents. If the markup is @samp{org}, the
> +text will be assumed to be in Org mode format and will be processed
> +normally. The markup is optional, if it is not given, the text will be
> +included as is and any Org markup will be escaped.  The include line will
> +also allow additional keyword parameters @code{:prefix1} and @code{:prefix}
> +to specify prefixes for the first line and for each following line, as well
> +as any options accepted by the selected markup.  For example, to include a
> +file as an item, use
>  
>  @example
>  #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> index 280b1f4..83f9b74 100644
> --- a/lisp/org-exp.el
> +++ b/lisp/org-exp.el
> @@ -2085,13 +2085,14 @@ TYPE must be a string, any of:
>               (not (file-readable-p file)))
>           (insert (format "CANNOT INCLUDE FILE %s" file))
>         (when markup
> - (if (equal (downcase markup) "src")
> - (setq start (format "#+begin_src %s %s\n"
> - (or lang "fundamental")
> - (or switches ""))
> - end "#+end_src")
> - (setq start (format "#+begin_%s %s\n" markup switches)
> - end  (format "#+end_%s" markup))))
> - (cond ((equal (downcase markup) "src")
> - (setq start (format "#+begin_src %s %s\n"
> - (or lang "fundamental")
> - (or switches ""))
> - end "#+end_src"))
> - ((equal (downcase markup) "org") nil)
> - (t (setq start (format "#+begin_%s %s\n" markup switches)
> - end  (format "#+end_%s" markup)))))
+         (cond ((equal (downcase markup) "src")
+                 (setq start (format "#+begin_src %s %s\n"
+                                     (or lang "fundamental")
+                                     (or switches ""))
+                       end "#+end_src"))
+                ((equal (downcase markup) "org") nil)
+                (t (setq start (format "#+begin_%s %s\n" markup switches)
+                         end  (format "#+end_%s" markup)))))
>         (insert (or start ""))
>         (insert (org-get-file-contents (expand-file-name file) prefix prefix1 markup))
>         (or (bolp) (newline))
>
> I hope that helps!
> ~Michael Zeller

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Include mechanism for web publishing
  2009-07-29  0:53   ` Michael Zeller
@ 2009-07-29 14:08     ` Israel Herraiz
  2009-07-29 15:25       ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Israel Herraiz @ 2009-07-29 14:08 UTC (permalink / raw)
  To: emacs-orgmode

Excerpts from Michael's message on Jul 29, 2009 about  2 AM:
> Opps, for some reason the important portion didn't copy. You'll have to
> forgive me, I'm still learning gnus.

Thanks for the patch. However, stragenly, it is now working out of the
box. I cloned the git repo to try out your patch, and before applying
it, I tried the original sources, just in case something has changed
and my scripts stop working.

I added the "org" markup option to all the #+INCLUDEs; for instance:

 #+INCLUDE: header/my-header.org org

And surprisingly it is now working, without changing any single
line. I say surprisingly because it works with anything but "src" or
none. For instance, I can write #+INCLUDE: file.org blablabla, and the
file is included without any formatting or escaping. If I don't
indicate the markup, it is escaped. And if I indicate "src", the
original file gets included as source code.

Thanks anyway for the patch.

Cheers,
Israel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Include mechanism for web publishing
  2009-07-29 14:08     ` Israel Herraiz
@ 2009-07-29 15:25       ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2009-07-29 15:25 UTC (permalink / raw)
  To: Israel Herraiz; +Cc: emacs-orgmode

Hi Israel,

Israel Herraiz <isra@herraiz.org> writes:

> Excerpts from Michael's message on Jul 29, 2009 about  2 AM:
>> Opps, for some reason the important portion didn't copy. You'll have to
>> forgive me, I'm still learning gnus.
>
> Thanks for the patch. However, stragenly, it is now working out of the
> box. I cloned the git repo to try out your patch, and before applying
> it, I tried the original sources, just in case something has changed
> and my scripts stop working.
>
> I added the "org" markup option to all the #+INCLUDEs; for instance:
>
>  #+INCLUDE: header/my-header.org org
>
> And surprisingly it is now working, without changing any single
> line. 

I think this patch did the trick:

http://repo.or.cz/w/org-mode.git?a=commit;h=68b65e8f480c17cfe1024001c236eb4065893f4d

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-29 15:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 22:38 Include mechanism for web publishing Israel Herraiz
2009-07-29  0:38 ` Michael Zeller
2009-07-29  0:53   ` Michael Zeller
2009-07-29 14:08     ` Israel Herraiz
2009-07-29 15:25       ` Bastien

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).