emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Stefan Vollmar <vollmar@nf.mpg.de>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [ox-publish] handling of white space in arguments of macros, named arguments?
Date: Wed, 27 Mar 2013 17:26:34 +0100	[thread overview]
Message-ID: <87d2ukg66d.fsf@gmail.com> (raw)
In-Reply-To: <31F8FCDD-923C-402B-AD87-FEB6C8F84B12@nf.mpg.de> (Stefan Vollmar's message of "Tue, 26 Mar 2013 21:08:56 +0100")

Hello,

Stefan Vollmar <vollmar@nf.mpg.de> writes:

> However, the second change is caused by our use of MACROs: we find
> them very helpful for generating HTML content using raw HTML templates
> with placeholders.
>
> This used to work (for generating http://microformats.org/wiki/hcard information) a month ago:
>
> {{{mhead-hcard(
> Dr. Stefan Vollmar,
> Stefan,
> ,
> Vollmar,
> Dr.,
> stefan-vollmar.jpg,
> stefan-vollmar.html,
> ...)}}}
>
> with this type of macro definition:
>
> #+macro: mhead-hcard #+html: <div id="contact" class="vcard"><p><table style="margin-left:0;margin-right:auto"><tr style="text-align: left;margin-left: 2em"><td style="padding: 5px"><img width="200px" class="photo" src="images/$6" alt="$1" /></td><td><a style="color:blue;" class="url" href="http://www.nf.mpg.de/cv/$7"><div class="fn n"><span class="honorific-prefix">$5</span> <span class="given-name">$2</span>[...]
>
> but now the white space around the arguments is no longer stripped and/or other effects cause "<" and ">" in the macro to be exported as "&lt;" etc.
>
> This version seems to work fine:
>
> {{{mhead-hcard(Dr. Stefan
> Vollmar,Stefan,,Vollmar,Dr.,stefan-vollmar.jpg,stefan-vollmar.html,Head
> of IT Group\,<br/>Physicist\, Software
> Developer,vollmar@nf.mpg.de,it,+49 221 4726-213,+49 221 4726-298)}}}

I removed trimming around arguments a few days ago, since it wasn't an
explicit specification for macros. Therefore, newline characters are
inserted in your template, which means that the HTML keyword doesn't
affect all lines of the generated code and, as a consequence, some "<"
are exported as "&lt;".

I think all newline characters should be replaced with a whitespace
character in macro arguments. Indeed, macro templates are only one line
long but unwanted "\n" could be inserted by paragraph filling in
arguments.

I also don't mind trimming arguments again, provided this is added as an
explicit behaviour and there is no opposition to it.

> Yes, I could use it as a workaround, but I would prefer something
> similar to the above version for improved readability - maybe by
> adding "line continuation markers" like "\"? Obviously, more complex
> macros (the one above has 12 individual arguments) are less than ideal
> anyway and the best solution (by far) would be "named arguments".
> Maybe there already is a better way of using (HTML) templates?

I think you really shouldn't use macros for that. For example, consider
adding the following in your buffer (or, better, in the Library of
Babel):

  #+name: mhead-hcard
  #+header: :var cname="Complete Name" gname="Given Name" photo="photo.jpg" prefix=""
  #+header: :var web="web-page.html"
  #+BEGIN_SRC org :exports none
  <div id="contact" class="vcard">
    <p>
      <table style="margin-left:0;margin-right:auto">
        <tr style="text-align: left;margin-left: 2em">
          <td style="padding: 5px">
            <img width="200px" class="photo" src="images/$photo" alt="$cname" />
          </td>
          <td><a style="color:blue;" class="url" href="http://www.nf.mpg.de/cv/$web">
            <div class="fn n">
              <span class="honorific-prefix">$prefix</span>
              <span class="given-name">$gname</span>
  ...
  #+END_SRC

Then, you insert a hcard with:

  #+call: mhead-hcard(cname="Dr. Stefan Vollmar",gname="Stefan",prefix="Dr.",web="stefan-vollmar.html",photo="stefan-vollmar.jpg") :results html


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2013-03-27 16:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 20:08 [ox-publish] handling of white space in arguments of macros, named arguments? Stefan Vollmar
2013-03-27 16:26 ` Nicolas Goaziou [this message]
2013-03-28  6:59   ` Achim Gratz
2013-03-28 16:22     ` Nicolas Goaziou
2013-03-28 17:44       ` Achim Gratz
2013-03-28  9:18   ` Stefan Vollmar

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=87d2ukg66d.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=vollmar@nf.mpg.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).