Mercurial > hgbook
changeset 361:96437101a088
more template.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 22 Sep 2008 22:48:57 +0900 |
parents | 45ad9986748a |
children | df4ac9043db0 |
files | ja/Makefile ja/template.tex ja/todo.txt |
diffstat | 3 files changed, 192 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/Makefile Mon Sep 22 01:42:57 2008 +0900 +++ b/ja/Makefile Mon Sep 22 22:48:57 2008 +0900 @@ -116,6 +116,7 @@ dvi: $(sources) $(image-eps) platex 00book.tex + cp 00book.aux hgbook.aux bibtex hgbook platex 00book.tex
--- a/ja/template.tex Mon Sep 22 01:42:57 2008 +0900 +++ b/ja/template.tex Mon Sep 22 22:48:57 2008 +0900 @@ -64,8 +64,8 @@ %command by editing your \hgrc file, naming the style you would %prefer to use. -Mercurial$B$NA4$F$N%3%^%s%I$GMQ$$$i$l$k=PNO%9%?%$%k$O(B\hgrc$B%U%!%$%k$rJT=8$9(B -$B$k$3$H$G@_Dj$G$-!$9%$-$JL>A0$rIU$1$k$3$H$,$G$-$k!%(B +Mercurial$B$NA4$F$N%3%^%s%I$GMQ$$$i$l$k=PNO%9%?%$%k$O(B \hgrc $B%U%!%$%k$rJT=8(B +$B$9$k$3$H$G@_Dj$G$-!$9%$-$JL>A0$rIU$1$k$3$H$,$G$-$k!%(B \begin{codesample2} [ui] @@ -274,125 +274,239 @@ \section{$B%(%9%1!<%W%7!<%1%s%9(B} \label{sec:template:escape} -Mercurial's templating engine recognises the most commonly used escape -sequences in strings. When it sees a backslash (``\Verb+\+'') -character, it looks at the following character and substitutes the two -characters with a single replacement, as described below. +%Mercurial's templating engine recognises the most commonly used escape +%sequences in strings. When it sees a backslash (``\Verb+\+'') +%character, it looks at the following character and substitutes the two +%characters with a single replacement, as described below. + +Mercurial$B$N%F%s%W%l!<%H%(%s%8%s$OJ8;zNs$G:G$b$h$/;HMQ$5$l$k%(%9%1!<%W%7!<(B +$B%1%s%9$rG'<1$9$k!%%(%s%8%s$O%P%C%/%9%i%C%7%e(B(``\Verb+\+'')$B$r8+$D$1$k$H8e(B +$BB3$NJ8;z$r4^$`(B2$BJ8;z$r0J2<$N$h$&$J(B1$BJ8;z$GCV49$9$k!%(B \begin{itemize} -\item[\Verb+\textbackslash\textbackslash+] Backslash, ``\Verb+\+'', +%\item[\Verb+\textbackslash\textbackslash+] Backslash, ``\Verb+\+'', +% ASCII~134. +%\item[\Verb+\textbackslash n+] Newline, ASCII~12. +%\item[\Verb+\textbackslash r+] Carriage return, ASCII~15. +%\item[\Verb+\textbackslash t+] Tab, ASCII~11. +%\item[\Verb+\textbackslash v+] Vertical tab, ASCII~13. +%\item[\Verb+\textbackslash \{+] Open curly brace, ``\Verb+{+'', ASCII~173. +%\item[\Verb+\textbackslash \}+] Close curly brace, ``\Verb+}+'', ASCII~175. +\item[\Verb+\textbackslash\textbackslash+] $B%P%C%/%9%i%C%7%e(B, ``\Verb+\+'', ASCII~134. -\item[\Verb+\textbackslash n+] Newline, ASCII~12. -\item[\Verb+\textbackslash r+] Carriage return, ASCII~15. -\item[\Verb+\textbackslash t+] Tab, ASCII~11. -\item[\Verb+\textbackslash v+] Vertical tab, ASCII~13. -\item[\Verb+\textbackslash \{+] Open curly brace, ``\Verb+{+'', ASCII~173. -\item[\Verb+\textbackslash \}+] Close curly brace, ``\Verb+}+'', ASCII~175. +\item[\Verb+\textbackslash n+] $B2~9T(B, ASCII~12. +\item[\Verb+\textbackslash r+] $BI|5"(B, ASCII~15. +\item[\Verb+\textbackslash t+] $B%?%V(B, ASCII~11. +\item[\Verb+\textbackslash v+] $B?bD>%?%V(B, ASCII~13. +\item[\Verb+\textbackslash \{+] $B3+$-Cf3g8L(B, ``\Verb+{+'', ASCII~173. +\item[\Verb+\textbackslash \}+] $BJD$8Cf3g8L(B, ``\Verb+}+'', ASCII~175. \end{itemize} -As indicated above, if you want the expansion of a template to contain -a literal ``\Verb+\+'', ``\Verb+{+'', or ``\Verb+{+'' character, you -must escape it. +%As indicated above, if you want the expansion of a template to contain +%a literal ``\Verb+\+'', ``\Verb+{+'', or ``\Verb+{+'' character, you +%must escape it. + +$B>e$K<($7$?$h$&$K!$%F%s%W%l!<%H$NE83+$N:]$KJ8;z(B +``\Verb+\+'', ``\Verb+{+'', $B$^$?$O(B``\Verb+{+''$B$rF~$l$?$$>l9g$O%(%9%1!<%W(B +$B$9$k$3$H$,I,MW$G$"$k!%(B %\section{Filtering keywords to change their results} \section{$B7k2L$r2~JQ$9$k%U%#%k%?%-!<%o!<%I(B} \label{sec:template:filter} -Some of the results of template expansion are not immediately easy to -use. Mercurial lets you specify an optional chain of \emph{filters} -to modify the result of expanding a keyword. You have already seen a -common filter, \tplkwfilt{date}{isodate}, in action above, to make a -date readable. +%Some of the results of template expansion are not immediately easy to +%use. Mercurial lets you specify an optional chain of \emph{filters} +%to modify the result of expanding a keyword. You have already seen a +%common filter, \tplkwfilt{date}{isodate}, in action above, to make a +%date readable. + +$B%F%s%W%l!<%HE83+$N7k2L$N$&$A!$$$$/$D$+$O$?$d$9$/MxMQ$G$-$k$b$N$G$O$J$$!%(B +Mercurial$B$OE83+$5$l$k%-!<%o!<%I$rJQ99$9$k$?$a$N0lO"$N(B\emph{filters}$B%*%W%7%g(B +$B%s$rDs6!$7$F$$$k!%F|;~$r2DFI$K$9$k$?$a$K$h$/MQ$$$i$l$k(B +\tplkwfilt{date}{isodate}$B%U%#%k%?$NF0:nNc$K$D$$$F$O4{$K8+$F$-$?!%(B -Below is a list of the most commonly used filters that Mercurial -supports. While some filters can be applied to any text, others can -only be used in specific circumstances. The name of each filter is -followed first by an indication of where it can be used, then a -description of its effect. +%Below is a list of the most commonly used filters that Mercurial +%supports. While some filters can be applied to any text, others can +%only be used in specific circumstances. The name of each filter is +%followed first by an indication of where it can be used, then a +%description of its effect. + +$B0J2<$K<($9$N$O(BMercurial$B$,%5%]!<%H$9$k%U%#%k%?$NCf$G:G$b$h$/;H$o$l$k$b$N$G(B +$B$"$k!%$$$/$D$+$N%U%#%k%?$OG$0U$NJ8;zNs$KBP$7$FE,MQ2DG=$J0lJ}!$B>$N$b$N$O(B +$BFCDj$N>u67$K$*$$$F$N$_MxMQ2DG=$G$"$k!%3F!9$N%U%#%k%?$NL>A0$O!$MxMQ2DG=$J(B +$B>u67$r<($9I=<($G;O$^$j!$F@$i$l$k8z2L$N@bL@$,B3$/!%(B \begin{itemize} -\item[\tplfilter{addbreaks}] Any text. Add an XHTML ``\Verb+<br/>+'' - tag before the end of every line except the last. For example, - ``\Verb+foo\nbar+'' becomes ``\Verb+foo<br/>\nbar+''. -\item[\tplkwfilt{date}{age}] \tplkword{date} keyword. Render the - age of the date, relative to the current time. Yields a string like - ``\Verb+10 minutes+''. -\item[\tplfilter{basename}] Any text, but most useful for the - \tplkword{files} keyword and its relatives. Treat the text as a - path, and return the basename. For example, ``\Verb+foo/bar/baz+'' - becomes ``\Verb+baz+''. -\item[\tplkwfilt{date}{date}] \tplkword{date} keyword. Render a date - in a similar format to the Unix \tplkword{date} command, but with - timezone included. Yields a string like - ``\Verb+Mon Sep 04 15:13:13 2006 -0700+''. -\item[\tplkwfilt{author}{domain}] Any text, but most useful for the - \tplkword{author} keyword. Finds the first string that looks like - an email address, and extract just the domain component. For - example, ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes - ``\Verb+serpentine.com+''. -\item[\tplkwfilt{author}{email}] Any text, but most useful for the - \tplkword{author} keyword. Extract the first string that looks like - an email address. For example, - ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes - ``\Verb+bos@serpentine.com+''. -\item[\tplfilter{escape}] Any text. Replace the special XML/XHTML - characters ``\Verb+&+'', ``\Verb+<+'' and ``\Verb+>+'' with - XML entities. -\item[\tplfilter{fill68}] Any text. Wrap the text to fit in 68 - columns. This is useful before you pass text through the - \tplfilter{tabindent} filter, and still want it to fit in an - 80-column fixed-font window. -\item[\tplfilter{fill76}] Any text. Wrap the text to fit in 76 - columns. -\item[\tplfilter{firstline}] Any text. Yield the first line of text, - without any trailing newlines. -\item[\tplkwfilt{date}{hgdate}] \tplkword{date} keyword. Render the - date as a pair of readable numbers. Yields a string like - ``\Verb+1157407993 25200+''. -\item[\tplkwfilt{date}{isodate}] \tplkword{date} keyword. Render the - date as a text string in ISO~8601 format. Yields a string like - ``\Verb+2006-09-04 15:13:13 -0700+''. -\item[\tplfilter{obfuscate}] Any text, but most useful for the - \tplkword{author} keyword. Yield the input text rendered as a - sequence of XML entities. This helps to defeat some particularly - stupid screen-scraping email harvesting spambots. +%\item[\tplfilter{addbreaks}] Any text. Add an XHTML ``\Verb+<br/>+'' +% tag before the end of every line except the last. For example, +% ``\Verb+foo\nbar+'' becomes ``\Verb+foo<br/>\nbar+''. + +\item[\tplfilter{addbreaks}] $BG$0U$N%F%-%9%H!%(BXHTML$B%?%0(B``\Verb+<br/>+'' +$B$r:G=*9T0J30$N3F9T$NKvHx$KDI2C$9$k!%Nc$($P(B``\Verb+foo\nbar+''$B$O(B + ``\Verb+foo<br/>\nbar+''$B$H$J$k!%(B + +%\item[\tplkwfilt{date}{age}] \tplkword{date} keyword. Render the +% age of the date, relative to the current time. Yields a string like +% ``\Verb+10 minutes+''. + +\item[\tplkwfilt{date}{age}] \tplkword{date}$B%-!<%o!<%I!%F|;~$N7P2a;~4V$r(B + $B8=:_$r5/E@$K@07A$9$k!%7k2L$O(B + ``\Verb+10 minutes+''$B$N$h$&$K$J$k(B + +%\item[\tplfilter{basename}] Any text, but most useful for the +% \tplkword{files} keyword and its relatives. Treat the text as a +% path, and return the basename. For example, ``\Verb+foo/bar/baz+'' +% becomes ``\Verb+baz+''. + +\item[\tplfilter{basename}] $BG$0U$N%F%-%9%H$@$,!$(B\tplkword{files}$B%-!<%o!<(B + $B%I$d$=$N4XO"%-!<%o!<%I$KBP$7$F:G$bM-MQ$G$"(B + $B$k!%%F%-%9%H$r%Q%9$H$7$F07$$!$%Y!<%9%M!<%`$r(B + $BJV$9!%Nc$($P(B``\Verb+foo/bar/baz+''$B$O(B + ``\Verb+baz+''$B$H$J$k!%(B + +%\item[\tplkwfilt{date}{date}] \tplkword{date} keyword. Render a date +% in a similar format to the Unix \tplkword{date} command, but with +% timezone included. Yields a string like +% ``\Verb+Mon Sep 04 15:13:13 2006 -0700+''. + +\item[\tplkwfilt{date}{date}] \tplkword{date}$B%-!<%o!<%I!%F|;~$r(BUnix$B$N(B + \tplkword{date}$B%3%^%s%I$N=PNO$K%?%$%`%>!<%s(B + $B>pJs$rDI2C$7$?7A<0$K@07A$9$k!%7k2L$O(B + ``\Verb+Mon Sep 04 15:13:13 2006 -0700+''$B$N(B + $B$h$&$K$J$k!%(B + +%\item[\tplkwfilt{author}{domain}] Any text, but most useful for the +% \tplkword{author} keyword. Finds the first string that looks like +% an email address, and extract just the domain component. For +% example, ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes +% ``\Verb+serpentine.com+''. + +\item[\tplkwfilt{author}{domain}] $BG$0U$N%F%-%9%H!%(B\tplkword{author}$B%-!<%o!<(B + $B%I$G$N;HMQ$K:G$bM-MQ!%:G=i$K8=$l$k(Bemail$B%"%I(B + $B%l%97A<0$NJ8;zNs$r8+$D$1!$%I%a%$%sItJ,$@$1$r(B + $BH4$-=P$9!%Nc$($P(B + ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' + $B$O(B``\Verb+serpentine.com+''$B$H$J$k!%(B + +%\item[\tplkwfilt{author}{email}] Any text, but most useful for the +% \tplkword{author} keyword. Extract the first string that looks like +% an email address. For example, +% ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes +% ``\Verb+bos@serpentine.com+''. + +\item[\tplkwfilt{author}{email}] $BG$0U$N%F%-%9%H!%(B\tplkword{author}$B%-!<%o!<(B + $B%I$G:G$bM-MQ!%:G=i$K8=$l$k(Bemail$B%"%I%l%97A<0(B + $B$NJ8;zNs$rH4$-=P$9!%Nc$($P(B + ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' + $B$O(B``\Verb+bos@serpentine.com+''$B$H$J$k!%(B + +%\item[\tplfilter{escape}] Any text. Replace the special XML/XHTML +% characters ``\Verb+&+'', ``\Verb+<+'' and ``\Verb+>+'' with +% XML entities. + +\item[\tplfilter{escape}] $BG$0U$N%F%-%9%H!%(BXML/XHTML$BJ8;z(B + ``\Verb+&+'', ``\Verb+<+''$B$*$h$S(B + ``\Verb+>+''$B$r(BXML$B%(%s%F%#%F%#$GCV49$9$k!%(B + +%\item[\tplfilter{fill68}] Any text. Wrap the text to fit in 68 +% columns. This is useful before you pass text through the +% \tplfilter{tabindent} filter, and still want it to fit in an +% 80-column fixed-font window. + +\item[\tplfilter{fill68}] $BG$0U$N%F%-%9%H!%%F%-%9%H$r(B68$B7e$K<}$^$k$h$&$K@0(B + $B7A$9$k!%$3$l$O(B80$B7e$K8GDj$5$l$?C<Kv$G$NI=<(MQ(B + $B$K(B\tplfilter{tabindent}$B%U%#%k%?$r;H$&:]$KJX(B + $BMx$G$"$k!%(B + +%\item[\tplfilter{fill76}] Any text. Wrap the text to fit in 76 +% columns. + +\item[\tplfilter{fill76}] $BG$0U$N%F%-%9%H!%(B76$B7e$K<}$^$k$h$&$K@07A$9$k!%(B + +%\item[\tplfilter{firstline}] Any text. Yield the first line of text, +% without any trailing newlines. + +\item[\tplfilter{firstline}] $BG$0U$N%F%-%9%H:G=i$N9T$@$1$r=PNO$7!$8eB3$N(B + $B9T$O0l@Z=PNO$7$J$$!%(B + +%\item[\tplkwfilt{date}{hgdate}] \tplkword{date} keyword. Render the +% date as a pair of readable numbers. Yields a string like +% ``\Verb+1157407993 25200+''. + +\item[\tplkwfilt{date}{hgdate}] \tplkword{date}$B%-!<%o!<%I!%F|;~$r2DFI$J(B + $B?t;z$N%Z%"$K@07A$9$k!%(B``\Verb+115740799325200+''$B$N$h$&$JJ8;zNs$r=PNO$9$k!%(B + +%\item[\tplkwfilt{date}{isodate}] \tplkword{date} keyword. Render the +% date as a text string in ISO~8601 format. Yields a string like +% ``\Verb+2006-09-04 15:13:13 -0700+''. + +\item[\tplkwfilt{date}{isodate}] \tplkword{date}$B%-!<%o!<%I!%F|;~$r(B + ISO~8601$B%U%)!<%^%C%H$K@07A$9$k!%=PNO$O(B + ``\Verb+2006-09-04 15:13:13 -0700+''$B$N$h$&$K(B + $B$J$k!%(B + +%\item[\tplfilter{obfuscate}] Any text, but most useful for the +% \tplkword{author} keyword. Yield the input text rendered as a +% sequence of XML entities. This helps to defeat some particularly +% stupid screen-scraping email harvesting spambots. + +\item[\tplfilter{obfuscate}]$BG$0U$N%F%-%9%H!%(B\tplkword{author}$B%-!<%o!<%I$H(B + $BJ;$;$FMxMQ$9$k>l9g:G$bM-MQ!%F~NO$5$l$?%F%-%9(B + $B%H$r(BXML$B%(%s%F%#%F%#$N%7!<%1%s%9$H$7$F=PNO$9(B + $B$k!%$3$l$O2hLL$r%9%/%l%$%T%s%0$9$k4VH4$1$J%9(B + $B%Q%`%\%C%H$rHr$1$kF/$-$,$"$k!%(B + \item[\tplkwfilt{author}{person}] Any text, but most useful for the \tplkword{author} keyword. Yield the text before an email address. For example, ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes ``\Verb+Bryan O'Sullivan+''. + \item[\tplkwfilt{date}{rfc822date}] \tplkword{date} keyword. Render a date using the same format used in email headers. Yields a string like ``\Verb+Mon, 04 Sep 2006 15:13:13 -0700+''. + \item[\tplkwfilt{node}{short}] Changeset hash. Yield the short form of a changeset hash, i.e.~a 12-byte hexadecimal string. + \item[\tplkwfilt{date}{shortdate}] \tplkword{date} keyword. Render the year, month, and day of the date. Yields a string like ``\Verb+2006-09-04+''. + \item[\tplfilter{strip}] Any text. Strip all leading and trailing whitespace from the string. + \item[\tplfilter{tabindent}] Any text. Yield the text, with every line except the first starting with a tab character. + \item[\tplfilter{urlescape}] Any text. Escape all characters that are considered ``special'' by URL parsers. For example, \Verb+foo bar+ becomes \Verb+foo%20bar+. + \item[\tplkwfilt{author}{user}] Any text, but most useful for the \tplkword{author} keyword. Return the ``user'' portion of an email address. For example, ``\Verb+Bryan O'Sullivan <bos@serpentine.com>+'' becomes ``\Verb+bos+''. + + \end{itemize} \begin{figure} \interaction{template.simple.manyfilters} - \caption{Template filters in action} +% \caption{Template filters in action} + \caption{$B%F%s%W%l!<%H%U%#%k%?$NF0:n(B} \label{fig:template:filters} \end{figure} \begin{note} - If you try to apply a filter to a piece of data that it cannot - process, Mercurial will fail and print a Python exception. For - example, trying to run the output of the \tplkword{desc} keyword - into the \tplkwfilt{date}{isodate} filter is not a good idea. +% If you try to apply a filter to a piece of data that it cannot +% process, Mercurial will fail and print a Python exception. For +% example, trying to run the output of the \tplkword{desc} keyword +% into the \tplkwfilt{date}{isodate} filter is not a good idea. +$B%U%#%k%?$rE,MQITG=$J%G!<%?$KBP$7$F;H$*$&$H$9$k$H(BMercurial$B$O%(%i!<$r5/$3(B + $B$7!$(BPython$B$+$i$NNc30$r=PNO$9$k!%Nc$($P(B\tplkword{desc}$B%-!<%o!<%I$N=PNO$K(B + \tplkwfilt{date}{isodate}$B%U%#%k%?$rE,MQ$9$k$N$O$$$$9M$($H$O8@$($J$$!%(B + \end{note} %\subsection{Combining filters}