view doc/manual/document.tema @ 31:3e77076621a8

Remove obsolete docs and sample.
author Mikhail Kryshen <mikhail@kryshen.net>
date Sun, 30 Aug 2009 02:51:15 +0400
parents 6c41a0b43e58
children
line wrap: on
line source

[%\
  Macro definitions used in manual.tema to generate HTML document.
%]

[%!\
  Create HTML document.
  Arguments are read in pairs (name value) until "content" name is found.
  Then follows the document content.

  TODO: generate TOC.
%]
<%define#document
  <%silent while#
    <%if:<%not equal:<%set:arg <%next_arg:%>%> content%>
      <%export:<%arg:%> <%next_arg:%>%>
    %>
  %>\\
<%if:<%not embedded:%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title><%html_escape title:%></title>
  <meta http-equiv="Content-Type" content="text/html; charset=<%charset:%>" />
  <meta name="generator" content="<%tema:%>" />
</head>

<body>
<h1><%html_escape title:%><%optional:<br /><%html_escape subtitle:%>%></h1>
%>\
<%html_escape data:%>
<%if:<%not embedded:%>
</body>
</html>
%>\
%>

<%set:charset iso-8859-1%>
<%set:escape <%char:0%>%>

[%!\
  Create HTML tag.
%]
<%define#tag <%false:<%escape:%><<%data:%><%escape:%>>%>%>

[%!\
  Escape special HTML characters (except those preceded with <%escape:%>).
%]
<%define#html_escape
  <%replace:<%escape:%> <%:%>
  <%regex_replace_all:(?<!<%escape:%>)-- &ndash;
  <%regex_replace_all:(?<!<%escape:%>)--- &mdash;
  <%regex_replace_all:(?<!<%escape:%>)< &lt;
  <%regex_replace_all:(?<!<%escape:%>)> &gt;
  <%regex_replace_all:(?<!<%escape:%>)& &amp;
    <%data:%>\\
  %>%>%>%>%>%>\
%>

<%define#section
  <%tag:h2<%if:<%first_section:%> <%: class="first"%>%>%><%data:%><%tag:/h2%>\\
  <%unset:first_section%>\\
%>

<%define#subsection <%tag:h3%><%data:%><%tag:/h3%>%>

<%define#par <%tag:p%><%data:%><%tag:/p%>%>

<%define#itemize
<%tag:ul%>
<%while#\
  <%tag:li%><%next_arg:%><%tag:/li%>
%>\
<%tag:/ul%>
%>

<%define#code <%tag:code%><%replace:-- <%escape:%>-- <%data:%>%><%tag:/code%>%>

<%define#emph <%tag:i%><%data:%><%tag:/i%>%>

<%define#link
  <%silent set:url <%next_arg:%>%>\\
  <%tag:a href="<%url:%>"%>\\
    <%if_else:<%has_more_data:%>
      <%data:%>
      <%url:%>%>\\
  <%tag:/a%>\\
%>

<%define#function
  <%silent set:name <%next_arg:%>%>\\
  <%silent while#
    <%set:<%next_arg:%> <%next_arg:%>%>
  %>\\
  <%tag:div%>
    <%tag:b%><%name:%><%tag:/b%><%tag:br /%>
  <%tag:/div%>
  <%optional:<%tag:div style="padding-left:1em; margin-bottom: 0.5em;"%>
    <%description:%>
  <%tag:/div%>%>
  <%tag:div style="padding-left:1em; margin-bottom: 1em;"%>
    <%optional:<%tag:b%>Arguments:<%tag:/b%> <%arguments:%><%tag:br /%>%>
    <%optional:<%tag:b%>Data:<%tag:/b%> <%input_data:%><%tag:br /%>%>
    <%optional:<%tag:b%>Output:<%tag:/b%> <%output:%><%tag:br /%>%>
  <%tag:/div%>
%>