summaryrefslogtreecommitdiff
path: root/tex/context/base/spec-tst.tex
blob: bdd8a29b221bbf0ac88aacfcc99765e1e43ad53f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%D \module
%D   [       file=spec-tst,
%D        version=2002.12.08,
%D          title=\CONTEXT\ \PDF\ Macros,
%D       subtitle=Special Test Macro,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\ifcase \pdfoutput \endinput \fi

\unprotect

%D The conversions comes down to (for the sake of speed the
%D implementation combines steps):
%D
%D \startitemize
%D \item we expand the \UTF\ sequences into \type {\unicodechar}'s
%D \item spaces become character 255's (so that they are not
%D      gobbled in argument fetching
%D \item normal \ASCII\ chars are unchanged
%D \item \par's and alike are converted to \type {\unicodechar}'s
%D \stopitemize
%D
%D This happens by expansion; next we convert the resulting
%D sequence by interpreting the stream.

\long\def\sanitizePDFuniencoding#1\to#2%
  {\enablePDFunicrlf
   \simplifycommands % added due to Dohyun Kim
   \let\unicodechar\relax % prevent further expansion
   \retainlccodes\lccode32=255 % slooow
   \lowercasestring\PDFunicodetrigger#1\to#2%
   \edef#2{\expandafter\doPDFuni#2\empty\empty}} % slooow

%D Handling of empty lines:

\bgroup
\catcode`\^^M=\@@active
\gdef\enablePDFunicrlf%
  {\def\\{\unicodechar{13}}%
   \def\par{\\\\}%
   \catcode`\^^M=\@@active%
   \let^^M=\\}
\egroup

%D Conversion to 16 bit \UNICODE:

\def\PDFunicodechar#1%
  {\@EA\lchexnumbers\@EA{\number\utfdiv{#1}}%
   \@EA\lchexnumbers\@EA{\number\utfmod{#1}}}

\def\PDFunicodetrigger
  {\unicodechar{65279}}

%D The postprocessor:

\def\doPDFuni#1%
  {\ifx#1\relax
     \@EA\dodoPDFuni
   \else\ifx#1\empty
     % quit
   \else
     \@EAEAEA\nodoPDFuni
   \fi\fi#1}

\def\nodoPDFuni#1%
  {\PDFunicodechar{\ifnum`#1=255 32\else`#1\fi}\doPDFuni}

\def\dodoPDFuni#1#2%
  {\PDFunicodechar{#2}\doPDFuni}

\def\sanitizePDFencoding
  {\doifelse\currentregime{utf}%
     {\PDFunicodetrue\sanitizePDFuniencoding}\sanitizePDFdocencoding}

% pdftex specific

\def\doPDFinsertbookmark#1#2#3#4#5% level sublevels text page open=1
  {\bgroup
   \sanitizePDFencoding#3\to\bookmarktext % uses scratchcounter
   \stripstring\bookmarktext
   \doPDFbookmark{#1}{#2}{\bookmarktext}{#4}{#5}%
   \egroup}

\def\doPDFbookmark#1#2#3#4#5%
  {\doPDFgetpagereference{#4}\PDFobjectreference
   \pdfoutline
     user {<</S /GoTo /D [\PDFobjectreference\space\PDFpageviewwrd]>>}%
     \ifcase#2 \else count \ifcase#5-\fi#2 \fi
     {\ifPDFunicode<#3>\else#3\fi}}

\def\doPDFsetupidentity#1#2#3#4#5#6%
  {\bgroup
   \enablePDFdocencoding
   \sanitizePDFencoding#1\to\idtitle  \stripstring\idtitle
   \sanitizePDFencoding#2\to\idsubject\stripstring\idsubject
   \sanitizePDFencoding#3\to\idauthor \stripstring\idauthor
   \sanitizePDFencoding#4\to\idcreator\stripstring\idcreator
   \sanitizePDFencoding#6\to\idkeyword\stripstring\idkeyword
   \expanded{\doPDFaddtoinfo
     {/Title   \ifPDFunicode<\idtitle  >\else(\idtitle  )\fi
      /Subject \ifPDFunicode<\idsubject>\else(\idsubject)\fi
      /Author  \ifPDFunicode<\idauthor >\else(\idauthor )\fi
      /Creator \ifPDFunicode<\idcreator>\else(\idcreator)\fi
      /ModDate (#4)
      /ID (\jobname.#5) % needed for pdf/x
      /Keywords \ifPDFunicode<\idkeyword>\else(\idkeyword)\fi}}%
   \egroup}

\protect

\doifnotmode{demo}{\endinput}

% \input spec-tst.tex

\mainlanguage[vn]
\enableregime[utf]
\usetypescript[all][computer-modern][t5]

\setupinteraction
  [state=start,
   title={Thử tiếng Việt},
   author={Tác Văn Giả},
   keyword={Thử tiếng Việt}]

\placebookmarks[chapter,section,subsection]

\starttext

\placelist[chapter,section,subsection][alternative=c]

\chapter{Thử tiếng Việt}

\section   {Mục thứ nhất}
\subsection{Mục nhỏ thứ nhất} Thử tiếng Việt
\subsection{Mục nhỏ thứ hai}    Thử tiếng Việt

\section   {Mục thứ hai}
\subsection{Mục nhỏ thứ nhất} Thử tiếng Việt
\subsection{Mục nhỏ thứ hai}    Thử tiếng Việt

\section   {Mục thứ ba}
\subsection{Mục nhỏ thứ nhất} Thử tiếng Việt
\subsection{Mục nhỏ thứ hai}    Thử tiếng Việt

\stoptext