You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
7.6 KiB

  1. // Copyright 2011 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. /*
  5. The present file format
  6. Present files have the following format. The first non-blank non-comment
  7. line is the title, so the header looks like
  8. Title of document
  9. Subtitle of document
  10. 15:04 2 Jan 2006
  11. Tags: foo, bar, baz
  12. <blank line>
  13. Author Name
  14. Job title, Company
  15. joe@example.com
  16. http://url/
  17. @twitter_name
  18. The subtitle, date, and tags lines are optional.
  19. The date line may be written without a time:
  20. 2 Jan 2006
  21. In this case, the time will be interpreted as 10am UTC on that date.
  22. The tags line is a comma-separated list of tags that may be used to categorize
  23. the document.
  24. The author section may contain a mixture of text, twitter names, and links.
  25. For slide presentations, only the plain text lines will be displayed on the
  26. first slide.
  27. Multiple presenters may be specified, separated by a blank line.
  28. After that come slides/sections, each after a blank line:
  29. * Title of slide or section (must have asterisk)
  30. Some Text
  31. ** Subsection
  32. - bullets
  33. - more bullets
  34. - a bullet with
  35. *** Sub-subsection
  36. Some More text
  37. Preformatted text
  38. is indented (however you like)
  39. Further Text, including invocations like:
  40. .code x.go /^func main/,/^}/
  41. .play y.go
  42. .image image.jpg
  43. .background image.jpg
  44. .iframe http://foo
  45. .link http://foo label
  46. .html file.html
  47. .caption _Gopher_ by [[https://www.instagram.com/reneefrench/][Renée French]]
  48. Again, more text
  49. Blank lines are OK (not mandatory) after the title and after the
  50. text. Text, bullets, and .code etc. are all optional; title is
  51. not.
  52. Lines starting with # in column 1 are commentary.
  53. Fonts:
  54. Within the input for plain text or lists, text bracketed by font
  55. markers will be presented in italic, bold, or program font.
  56. Marker characters are _ (italic), * (bold) and ` (program font).
  57. An opening marker must be preceded by a space or punctuation
  58. character or else be at start of a line; similarly, a closing
  59. marker must be followed by a space or punctuation character or
  60. else be at the end of a line. Unmatched markers appear as plain text.
  61. There must be no spaces between markers. Within marked text,
  62. a single marker character becomes a space and a doubled single
  63. marker quotes the marker character.
  64. _italic_
  65. *bold*
  66. `program`
  67. Markup_especially_italic_text_can easily be overused.
  68. _Why_use_scoped__ptr_? Use plain ***ptr* instead.
  69. Inline links:
  70. Links can be included in any text with the form [[url][label]], or
  71. [[url]] to use the URL itself as the label.
  72. Functions:
  73. A number of template functions are available through invocations
  74. in the input text. Each such invocation contains a period as the
  75. first character on the line, followed immediately by the name of
  76. the function, followed by any arguments. A typical invocation might
  77. be
  78. .play demo.go /^func show/,/^}/
  79. (except that the ".play" must be at the beginning of the line and
  80. not be indented like this.)
  81. Here follows a description of the functions:
  82. code:
  83. Injects program source into the output by extracting code from files
  84. and injecting them as HTML-escaped <pre> blocks. The argument is
  85. a file name followed by an optional address that specifies what
  86. section of the file to display. The address syntax is similar in
  87. its simplest form to that of ed, but comes from sam and is more
  88. general. See
  89. https://plan9.io/sys/doc/sam/sam.html Table II
  90. for full details. The displayed block is always rounded out to a
  91. full line at both ends.
  92. If no pattern is present, the entire file is displayed.
  93. Any line in the program that ends with the four characters
  94. OMIT
  95. is deleted from the source before inclusion, making it easy
  96. to write things like
  97. .code test.go /START OMIT/,/END OMIT/
  98. to find snippets like this
  99. tedious_code = boring_function()
  100. // START OMIT
  101. interesting_code = fascinating_function()
  102. // END OMIT
  103. and see only this:
  104. interesting_code = fascinating_function()
  105. Also, inside the displayed text a line that ends
  106. // HL
  107. will be highlighted in the display; the 'h' key in the browser will
  108. toggle extra emphasis of any highlighted lines. A highlighting mark
  109. may have a suffix word, such as
  110. // HLxxx
  111. Such highlights are enabled only if the code invocation ends with
  112. "HL" followed by the word:
  113. .code test.go /^type Foo/,/^}/ HLxxx
  114. The .code function may take one or more flags immediately preceding
  115. the filename. This command shows test.go in an editable text area:
  116. .code -edit test.go
  117. This command shows test.go with line numbers:
  118. .code -numbers test.go
  119. play:
  120. The function "play" is the same as "code" but puts a button
  121. on the displayed source so the program can be run from the browser.
  122. Although only the selected text is shown, all the source is included
  123. in the HTML output so it can be presented to the compiler.
  124. link:
  125. Create a hyperlink. The syntax is 1 or 2 space-separated arguments.
  126. The first argument is always the HTTP URL. If there is a second
  127. argument, it is the text label to display for this link.
  128. .link http://golang.org golang.org
  129. image:
  130. The template uses the function "image" to inject picture files.
  131. The syntax is simple: 1 or 3 space-separated arguments.
  132. The first argument is always the file name.
  133. If there are more arguments, they are the height and width;
  134. both must be present, or substituted with an underscore.
  135. Replacing a dimension argument with the underscore parameter
  136. preserves the aspect ratio of the image when scaling.
  137. .image images/betsy.jpg 100 200
  138. .image images/janet.jpg _ 300
  139. video:
  140. The template uses the function "video" to inject video files.
  141. The syntax is simple: 2 or 4 space-separated arguments.
  142. The first argument is always the file name.
  143. The second argument is always the file content-type.
  144. If there are more arguments, they are the height and width;
  145. both must be present, or substituted with an underscore.
  146. Replacing a dimension argument with the underscore parameter
  147. preserves the aspect ratio of the video when scaling.
  148. .video videos/evangeline.mp4 video/mp4 400 600
  149. .video videos/mabel.ogg video/ogg 500 _
  150. background:
  151. The template uses the function "background" to set the background image for
  152. a slide. The only argument is the file name of the image.
  153. .background images/susan.jpg
  154. caption:
  155. The template uses the function "caption" to inject figure captions.
  156. The text after ".caption" is embedded in a figcaption element after
  157. processing styling and links as in standard text lines.
  158. .caption _Gopher_ by [[http://www.reneefrench.com][Renée French]]
  159. iframe:
  160. The function "iframe" injects iframes (pages inside pages).
  161. Its syntax is the same as that of image.
  162. html:
  163. The function html includes the contents of the specified file as
  164. unescaped HTML. This is useful for including custom HTML elements
  165. that cannot be created using only the slide format.
  166. It is your responsibilty to make sure the included HTML is valid and safe.
  167. .html file.html
  168. Presenter notes:
  169. Presenter notes may be enabled by appending the "-notes" flag when you run
  170. your "present" binary.
  171. This will allow you to open a second window by pressing 'N' from your browser
  172. displaying your slides. The second window is completely synced with your main
  173. window, except that presenter notes are only visible on the second window.
  174. Lines that begin with ": " are treated as presenter notes.
  175. * Title of slide
  176. Some Text
  177. : Presenter notes (first paragraph)
  178. : Presenter notes (subsequent paragraph(s))
  179. Notes may appear anywhere within the slide text. For example:
  180. * Title of slide
  181. : Presenter notes (first paragraph)
  182. Some Text
  183. : Presenter notes (subsequent paragraph(s))
  184. This has the same result as the example above.
  185. */
  186. package present // import "golang.org/x/tools/present"