/contrib/groff/contrib/pdfmark/spdf.tmac

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 225 lines · 218 code · 7 blank · 0 comment · 0 complexity · ab83451364af147bd54c9426d6f1b5d1 MD5 · raw file

  1. .\" -*- nroff -*-
  2. .ig
  3. spdf.tmac
  4. Copyright (C) 2004
  5. Free Software Foundation, Inc.
  6. Written by Keith Marshall (keith.d.marshall@ntlworld.com)
  7. This file is part of groff.
  8. groff is free software; you can redistribute it and/or modify it under
  9. the terms of the GNU General Public License as published by the Free
  10. Software Foundation; either version 2, or (at your option) any later
  11. version.
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. for more details.
  16. You should have received a copy of the GNU General Public License along
  17. with groff; see the file COPYING. If not, write to the Free Software
  18. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
  19. ..
  20. .\"
  21. .if !rOPMODE .nr OPMODE 1
  22. .\"
  23. .mso s.tmac
  24. .mso pdfmark.tmac
  25. .\"
  26. .\" Omitted Sections
  27. .\" ================
  28. .\"
  29. .\" Define section markers, for special document sections,
  30. .\" which are to be omitted from regular document processing.
  31. .\"
  32. .de OMIT OMIT
  33. .de \\$1
  34. .omit@begin \\$1 \\$2
  35. ..
  36. .de \\$2
  37. .omit@end \\$1 \\$2
  38. ..
  39. .OMIT CS CE \" front cover text, processed independently
  40. .OMIT MS ME \" menu definitions, for info documents only
  41. .\"
  42. .de omit@begin
  43. .ds omit@section \\$1
  44. .ig \\$2
  45. ..
  46. .de omit@end
  47. .if !'\\*[omit@section]'\\$1' .@error \\$2 without \\$1
  48. .rm omit@section
  49. ..
  50. .de XM
  51. .\"
  52. .pdfhref M -X \\$@
  53. ..
  54. .de XR
  55. .if \\n(.$ \{\
  56. . if \\n[OPMODE] \{\
  57. . ds spdf!opts -D "\\$1"
  58. . if \\n(.$>1 .as spdf!opts " -A "\\$2"
  59. . if \\n(.$>2 .as spdf!opts " -P "\\$3"
  60. . pdfhref L \\*[spdf!opts]
  61. . rm spdf!opts
  62. . \}
  63. . \}
  64. ..
  65. .\"
  66. .\" Document Outlines, Section Headings and Table of Contents
  67. .\" =========================================================
  68. .\"
  69. .de XN
  70. .\" Use AFTER .NH n, to define the text of the numbered heading,
  71. .\" automatically generating a matching formatted TOC entry, and
  72. .\" a PDF document outline entry.
  73. .\"
  74. .\" String registers XNVS1, XNVS2 and XNVS3 establish additional leading,
  75. .\" prior to top level headings, preceding each level of indented subheading,
  76. .\" and following each nested level of subheading, respectively
  77. .\" (strings are used, rather than numeric registers, so that these
  78. .\" additional spacing parameters may be set relative to the current
  79. .\" document line spacing, as set by \n[VS]).
  80. .\"
  81. .rm xn*ref
  82. .while dopt*XN\\$1 \{\
  83. . opt*XN\\$1 \\$*
  84. . shift \\n[xn*argc]
  85. . \}
  86. .rr xn*argc
  87. .if '\\$1'--' .shift
  88. .if dxn*ref .XM -N \\*[xn*ref] -- \\$@
  89. .rm xn*ref
  90. .pdfhref O \\n[nh*hl] "\\*(SN \\$*"
  91. .XS
  92. .if rtc*hl \{\
  93. . if !dXNVS1 .ds XNVS1 1.0v \" default leading for top level
  94. . if !dXNVS2 .ds XNVS2 0.3v \" default leading at nesting increment
  95. . if !dXNVS3 .ds XNVS3 0.6v \" default leading following nested group
  96. . if \\n[nh*hl]==1 \{\
  97. . sp \\*[XNVS1]
  98. . nr tc*hl-max 1
  99. . \}
  100. . ie \\n[nh*hl]<\\n[tc*hl] .if \\n[nh*hl]>1 .sp \\*[XNVS3]
  101. . el \{\
  102. . ie \\n[nh*hl]>\\n[tc*hl] .sp \\*[XNVS2]
  103. . el \{\
  104. . if !r tc*hl-max .nr tc*hl-max 1
  105. . ie \\n[tc*hl-max]>\\n[nh*hl] .sp \\*[XNVS3]
  106. . el .nr tc*hl-max \\n[nh*hl]
  107. . \}
  108. . \}
  109. . \}
  110. .nr tc*hl \\n[nh*hl]
  111. \h'\\n[nh*hl]-1m'\c
  112. \&\\*(SN\h'1n'\\$*
  113. .\".pdfhref L -D \\*[PDFBOOKMARK.NAME] -- \&\\*(SN\h'1n'\\$*
  114. .XE
  115. \&\\$*
  116. ..
  117. .de opt*XN-N
  118. .nr xn*argc 2
  119. .ds xn*ref \\$2
  120. ..
  121. .de opt*XN-X
  122. .nr xn*argc 1
  123. .if !dxn*ref .ds xn*ref \\\\$1
  124. ..
  125. .de LU
  126. .LP
  127. The content for this section is not yet available.
  128. ..
  129. .de AN
  130. .ie \\n(.$ .@AN \\$*
  131. .el .@AN Note
  132. ..
  133. .de @AN
  134. .SH
  135. \\$*
  136. .LP
  137. ..
  138. .nr PDF-TOC-ONLY 1
  139. .nr PDF-BODY-TEXT 2
  140. .de OP
  141. .ie rPHASE \{\
  142. . ie \\n(.$ \{\
  143. . nr op:request 0
  144. . while \\n(.$ \{\
  145. . if \\$1=\\n[PHASE] .nr op:request 1
  146. . shift
  147. . \}
  148. . \}
  149. . el .nr op:request 1
  150. . if !\\n[op:request]=\\n[OPMODE] \{\
  151. . nr OPMODE \\n[op:request]
  152. . nop \O[\\n[OPMODE]]\c
  153. . \}
  154. . \}
  155. .el .nr OPMODE 1
  156. ..
  157. .nr SAME-PAGE 0
  158. .de NN
  159. .if !\\n[SAME-PAGE] .bp
  160. .nr SAME-PAGE 0
  161. .NH \\$1
  162. .nn*setname \\$2
  163. .shift 2
  164. .XN -N \\*[nn*name] -- \\$@
  165. .rm nn*name
  166. ..
  167. .de nn*setname
  168. .ds nn*name \\$1
  169. .shift
  170. .while \\n(.$ \{\
  171. . as nn*name -\\$1
  172. . shift
  173. . \}
  174. ..
  175. .de PXREF
  176. .nn*setname \\$2
  177. .XR \\*[nn*name] )\\$1 (
  178. .rm nn*name
  179. ..
  180. .de IS
  181. .RS
  182. .nr LL \\n(LL-\\n(PI
  183. ..
  184. .de IE
  185. .RE
  186. .nr LL \\n(LL+\\n(PI
  187. ..
  188. .\" Override the standard ms macro,
  189. .\" to ensure the document outline cache is flushed
  190. .\" BEFORE emitting the table of contents.
  191. .de TC
  192. .pdfsync O
  193. .P1
  194. .OP \n[PDF-TOC-ONLY]
  195. .pg@begin 1 i
  196. .if \\n[OPMODE] .pdf@toc
  197. .PX \\$1
  198. ..
  199. .de pdf@toc
  200. .pdfhref O -T T 1 "\\*[TOC]"
  201. .pdfsync O
  202. ..
  203. .de pdf@exit
  204. .if \\n[OPMODE] .pdfsync
  205. .pg@end-text
  206. ..
  207. .em pdf@exit
  208. .OP \n[PDF-BODY-TEXT]
  209. .
  210. .\" groff "ms" provides the "pg@bottom" macro, which has already
  211. .\" been installed as a page transition trap. To ensure proper
  212. .\" mapping of "pdfhref" links which overflow the bottom of any
  213. .\" page, we need to install the "pdfhref" page transition hook,
  214. .\" as an addendum to this macro.
  215. .
  216. .pdfhref I -PT pg@bottom
  217. .\"
  218. .\" spdf.tmac: end of file: vim: ft=groff