Guides and Sample Code


Playground Book Format Reference

Comment Markers

You can add prose to be displayed on a page by using comment markers in .swift files.

Single-line comment markers consist of one line of text containing markup delimiters. Use two forward slash characters followed by a colon (//:) for a single line of markup for a playground.

  • //: line of markup content

Block comment markers enclose one or more lines of text containing markup delimiters. Use a forward slash followed by an asterisk and then a colon (/*:) for the opening comment delimiter. Use an asterisk followed by a forward slash (*/) for the closing comment delimiter.

  • /*:
  •      line of text with optional markup
  •      …
  •      line of text with optional markup
  •  */

The lines between the opening and closing comment delimiters can contain text, text and markup, or nothing. There is no limit to the number of lines in a comment. Text on the same line as the opening comment delimiter is ignored.

For more information, see Markup Formatting Reference.

Localized Comment Markers

You can localize the content displayed in comment markers by using the localized delimiter. To enable this, a playground page must have a Prose.strings file in each localization folder in the PrivateResources folder.

The localized delimiter takes a single labeled key argument, for the identifier corresponding to a localization key in the Prose.strings file. The delimiter is preceded by two forward slash characters followed by a colon and a pound sign (//:#).

  • //:#localized(key: "FirstProseBlock")

The Prose.strings file contains a list of key-value pairs along with optional comments describing the purpose of each key-value pair. Key and value strings are separated by an equal sign (=), and the entire entry must be terminated with a semicolon character (;). By convention, comments are enclosed inside C-style comment delimiters (/* and */) and are placed immediately before the entry they describe.

For example, a playground page with the //:#localized(key: "FirstProseBlock") comment marker may contain an en.lproj folder in the PrivateResources folder containing the following Prose.strings file:

  • /* First block of prose for the page */
  • "FirstProseBlock"="Caring for a llama can be a challenging, but rewarding, experience.";

When run on a device set to an English-speaking locale, the playground page automatically replaces the localization delimiter with the text.

For more information, see String Resources in Resource Programming Guide, and Internationalization and Localization Guide.