Macros?

A. Pagaltzis pagaltzis at gmx.de
Tue May 2 15:07:40 EDT 2006


* Anton J Aylward <aja at si.on.ca> [2006-05-02 19:35]:

> Is there any way to do macros in Markdown? Or do you have any

> other suggestions?


You can hack this on top of Markdown as it is, as long as you
don’t need to nest macros inside links. Then you can write this:


> You are %%USERNAME%%

> Logged in at %%LOGINTIME%%

>

> Your browser is %%HTTP{"User-Agent"}%%

> You are accessing from %%REMOTE_ADDR%%:%%REMOTE_PORT%%

>

> The time is now %%TIME(timezone=%%USER{%%TZ%%}%%, fmt="HH:MM:SS")%%


like this:

You are [USERNAME](macro:)
Logged in at [LOGINTIME](macro:)

Your browser is [HTTP{"User-Agent"}](macro:)
You are accessing from [REMOTE_ADDR](macro:):[REMOTE_PORT](macro:)

The time is now [TIME(timezone=USER{TZ},fmt="HH:MM:SS")](macro:)

Markdown makes this out of it:

<p>You are <a href="macro:">USERNAME</a>
Logged in at <a href="macro:">LOGINTIME</a></p>

<p>Your browser is <a href="macro:">HTTP{“User-Agent”}</a>
You are accessing from <a href="macro:">REMOTE<em>ADDR</a>:<a href="macro:">REMOTE</em>PORT</a></p>

<p>The time is now <a href="macro:">TIME(timezone=USER{TZ},fmt=”HH:MM:SS”)</a></p>

Then you can you go in there and replace `<a>` tags with a `href`
of `macro:` by the result of evaluating their textual content.

Hmm, you’d have to be careful about your underscores and
asterisks; not to mention there’s a bug there in Markdown…

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>


More information about the Markdown-Discuss mailing list