! vim: set syntax=inform: ! ! Copyright (C) 2003,2004 Simon Baldwin (simon_baldwin@yahoo.com) ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU Lesser General Public License as published ! by the Free Software Foundation; either version 2.1 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU Lesser General Public License for more details. ! ! You should have received a copy of the GNU Lesser General Public ! License along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! !----------------------------------------------------------------------------- ! ! This file is a test suite for Inform Markup. For more information on ! Inform Markup, see the header commentary in the file Markup.h. ! ! Here's a suitable PIC1 file for image tests: ! ! begin 664 PIC1 ! MB5!.1PT*&@H````-24A$4@```"`````@`@,````.%))G````#%!,5$4```#. ! MSJ/DYOS__]UOK-:X````H$E$051XG'7/L0K",!0%T`NA%+(X.6?O/TBEHXLN ! MG?V4ULG?2+:0KW!S5>N'9.C8
clears - tests window clearing
infos - tests game information
delays - tests input markup and delays
entities - tests character entities
styles - tests styles
colors - tests colors
nesting - tests style and color nesting
layouts - tests layouts
images - tests image markup
links - tests hyperlink markup
sections - tests markup sections
invalid - tests assorted invalid markup
all - all of the above

input - filters markup text from input lines
file - filters markup text from an input file

help - redisplays this list

"; rtrue; ], has light; [ Initialise; location = TestSuite; ]; [ EntitiesSub; markup ("

Special Character Entity References:

"); print (markup) "These are supported by both Glulx and the Z-machine.



&lt; - < &gt; - >
&amp; - & &quot; - "


"; markup ("

HTML 2.0 Standard Entity References:

"); print (markup) "These are all supported by both Glulx and the Z-machine.



&AElig; - Æ &Aacute; - Á &Acirc; - Â
&Agrave; - À &Aring; - Å &Atilde; - Ã
&Auml; - Ä &Ccedil; - Ç &ETH; - Ð
&Eacute; - É &Ecirc; - Ê &Egrave; - È
&Euml; - Ë &Iacute; - Í &Icirc; - Î
&Igrave; - Ì &Iuml; - Ï &Ntilde; - Ñ
&Oacute; - Ó &Ocirc; - Ô &Ograve; - Ò
&Oslash; - Ø &Otilde; - Õ &Ouml; - Ö
"; print (markup) " &THORN; - Þ &Uacute; - Ú &Ucirc; - Û
&Ugrave; - Ù &Uuml; - Ü &Yacute; - Ý
&aacute; - á &acirc; - â &aelig; - æ
&agrave; - à &aring; - å &atilde; - ã
&auml; - ä &ccedil; - ç &eacute; - é
&ecirc; - ê &egrave; - è &eth; - ð
&euml; - ë &iacute; - í &icirc; - î
"; print (markup) " &igrave; - ì &iuml; - ï &ntilde; - ñ
&oacute; - ó &ocirc; - ô &ograve; - ò
&oslash; - ø &otilde; - õ &ouml; - ö
&szlig; - ß &thorn; - þ &uacute; - ú
&ucirc; - û &ugrave; - ù &uuml; - ü
&yacute; - ý &yuml; - ÿ


"; markup ("

Entities Added with HTML 3.2:

"); print (markup) "These are all supported by Glulx. However, only a few of them are supported by the Z-machine. Some of the ones it doesn't support are emulated by Markup; the others display as their raw tag names.



&nbsp; -   &iexcl; - ¡ &pound; - £
&curren; - ¤ &yen; - ¥ &brvbar; - ¦
&sect; - § &uml; - ¨ &copy; - ©
&ordf; - ª &laquo; - « &not; - ¬
&shy; - ­ &reg; - ® &macr; - ¯
&deg; - ° &plusmn; - ± &sup2; - ²
&sup3; - ³ &acute; - ´ &micro; - µ
"; print (markup) " &para; - ¶ &middot; - · &cedil; - ¸
&sup1; - ¹ &ordm; - º &raquo; - »
&frac14; - ¼ &frac12; - ½ &frac34; - ¾
&iquest; - ¿


"; markup ("

Additional Widely Implemented Entities:

"); print (markup) "These are all supported only by Glulx. Markup emulates them for the Z-machine.



&times; - ×
&divide; - ÷
&cent; - ¢


"; markup ("

Additional Non-ISO 8859-1 Entities:

"); print (markup) "These are supported only by the Z-machine. Markup emulates them for Glulx. The characters are not part of ISO 8859-1.



&OElig; - Œ
&oelig; - œ


"; markup ("

Four Extra Entities Specifically for Inform:

"); print (markup) "These are supported by both Glulx and the Z-machine.



&tilde; - ˜ [ &#126; - ~ ]
&caret; - ⁁ [ &#94; - ^ ]
&at; - &at; [ &#64; - @ ]
&backsl; - &backsl; [ &#92; - \ ]

"; ]; [ StylesSub; markup ("

HTML-like Logical and Physical Styles:

"); print (markup) "These are rendered in a variety of ways by Markup, which tries to select a reasonable style on both Glulx and the Z-machine.

This is <B> text.
This is <STRONG> text.
This is <EM> text.
This is <DFN> text.

This is <ADDRESS> text.

This is <U> text.
This is <TT> text.
This is <PRE> text.

This is <CODE> text.
This is <KBD> text.
This is <VAR> text.
This is <SAMP> text.
This is <QUOTE> text.
This is <CITE> text.

This is <H1> text.


This is <H2> text.


"; markup ("

Directly Addressable Glk Styles:

"); print (markup) "For the Z-machine, Markup converts the style to something approximating the effect produced by Glulx.

This is <ALERT> text.

This is <BLOCKQUOTE> text.

This is <EMPHASIZED> text.
This is <HEADER> text.

This is <INPUT> text.
This is <NOTE> text.
This is <PREFORMATTED> text.
This is <SUBHEADER> text.
This is <USER1> text.
This is <USER2> text.
"; markup ("

Directly Addressable Z-machine Styles:

"); print (markup) "For Glulx, Markup converts the style to something approximating the effect produced by the Z-machine.

This is <BOLD> text.
This is <REVERSE> text.
This is <UNDERLINE> text.
This is <XBOLD> text.
This is <XREVERSE> text.
This is <XROMAN> text.
This is <XUNDERLINE> text.

"; ]; [ ColorsSub; markup ("

Text Coloring:

"); print (markup) "Text color is supported only by the Z-machine, though not all interpreters provide color. Glulx will display colored text using plain, normal styling.

This is black text.
This is red text.
This is green text.
This is yellow text.
This is blue text.
This is magenta text.
This is cyan text.
"; print (markup) " This is white text, black background.
This is white text, red background.
This is white text, green background.
This is white text, yellow background.
This is black text, blue background.
This is black text, magenta background.
This is black text, cyan background.

"; markup ("

Text Coloring Shorthand:

"); print (markup) " This is <BLACK> text.
This is <RED> text.
This is <GREEN> text.
This is <YELLOW> text.
This is <BLUE> text.
This is <MAGENTA> text.
This is <CYAN> text.
This is <WHITE> text.

"; ]; [ NestingSub; markup ("

Style and Color Nesting:

"); print (markup) "Note that text color is supported only by the Z-machine. Glulx will display colored text using the style in force at the time the color is introduced.

This is bold with emphasized nested text.
This is emphasized with bold nested text.
This is bold emphasized

preformatted
emphasized again bold again and back to normal.

"; print (markup) " This is cyan with nested blue text.
This is magenta with nested black text.
This is background cyan with nested background green text.
This is blue with nested window default text.
This is red, nested inside bold.
This is blue, nested inside
		preformatted.

This is shorthand magenta, nested inside emphasized.

"; ]; [ LayoutsSub; markup ("

Line breaks:

"); print (markup) "This is a short line, ending in <br>.
This is a second short line, also break terminated.
"; markup ("

Simple paragraphing:

"); print (markup) "This is the first paragraph of test text. It should flow across several lines, and extends across more"; print (markup) " than one call to print markup.

This is the second paragraph. It should be separated from the first by a blank line, because it starts with <P>."; print (markup) "

This is the third and final paragraph; it too starts with <P>.
"; markup ("

TADS-like Quotes Tag:

"); print (markup) "The <Q> tag encloses text in quotes. Nested <Q> tags alternate double quotes with single ones following normal typographic convention.
"; markup ("

HTML Comments in Markup:

"); print (markup) "There is a comment in this line. Comments begin with "<!-- " - the space after the double dash is important - and end with "-->", for example "<!-- commentary -->".
"; markup ("

VM-specific Tags:

"); print (markup) "This game is running on a GlulxZ-machine interpreter. The <GLULXZCODE> tag encloses text printed only by GlulxZ-machine. There is a <ZCODEGLULX> tag for the converse operation.

"; ]; [ ClearsSub; markup ("

Clear Screen:

"); print (markup) "This page begins with <cls>, and so should always clear the screen before it displays. The <clear> tag is a synonym.

"; ]; [ DelaysSub; markup ("

Delays, and Key and Line Input Waits:

"); print (markup) "Not all Glulx and Z-machine interpreters support timers. Here's a set of 200ms dots, created using repeated <wait delay=200> tags ", (markup) "...", (markup) "...", (markup) "...", (markup) "..."; print (markup) " If these printed without delay, your interpreter doesn't support timers, and Markup will sidestep the delays and timeouts below.

The default delay is one second, using <wait>... and we're back.

"; print (markup) "Here's a wait for a key, with a 5 second timeout, using <waitkey timeout=5000>... and we're back. "; if (markup_waitkey == 0) print (markup) "The wait timed out.

"; else print (markup) "The character you typed has the code ", markup_waitkey, (markup) ".

"; print (markup) "Here's a wait for a line, with a 5 second timeout, using <waitline initial='hello' timeout=5000>... "; if (markup_waitline->0 == 0) print (markup) " and we're back. The wait timed out, or you entered an empty string.

"; else { print (markup) "And we're back. You entered ""; markup_printfilter (markup_waitline + 1, markup_waitline->0); print (markup) "".

"; } ]; [ InfosSub; markup ("

Game Information:

"); print (markup) "This is

", (string) Story, (markup) "

, release , serial number , Inform version . The <release> and <serial> tags print information about the running game. <version> prints information about the Inform version used to compile the game.

"; ]; [ ImagesSub; markup ("

Image Tag and Picture Placements:

"); print (markup) "For now, images are supported only by Glulx. The Z-machine will display the alternate image text. Some Glulx interpreters do not support graphics, in which case they too will display the alternate image text."; print (markup) "

Image default aligned, no alternate text, displayed with <IMG SRC=PIC1>.
"; print (markup) "

[PIC1D] Image default aligned, alternate text is [PIC1D].
"; print (markup) "

[PIC1L] Image left aligned, alternate text is [PIC1L].
"; print (markup) "

[PIC1R] Image right aligned, alternate text is [PIC1R].
"; print (markup) "

[PIC1B] Image bottom aligned, [PIC1M] middle aligned, [PIC1T] top aligned.

The middle image was displayed with an <IMG SRC=PIC1 ALIGN=middle ALT=[PIC1M]> tag.

"; print (markup) "

[PIC1W] Image width=64 default aligned.

"; print (markup) "

[PIC1H] Image height=64 default aligned.

"; print (markup) "

[PIC1X] Image width=64 height=64 default aligned.

"; print (markup) "

The last image was displayed with an <IMG SRC=PIC1 WIDTH=64 HEIGHT=64 ALT=[PIC1X]> tag.

Alternate text can contain markup -- all this is <em>alternate</em> text.  Alternate text can even be
		<em><IMG SRC=9999 ALT=nested></em>, though it's odd, and
		tricky to get right.

"; ]; [ LinksSub; markup ("

Simple Hyperlinking:

"); print (markup) "Hyperlinks are supported only by Glulx. The Z-machine will display these as ordinary text.

This is a hyperlink, created with <A HREF=1>hyperlink</A>. He"; print (markup) "re is another, split across markup calls. These links aren't active; to make them useful, the program needs to listen for hyperlink events.

"; ]; [ print_stuff arg; print " This text is being printed out with plain, ordinary print "..." statements too, only this is coming from inside a function passed as an argument to markup. Markup passed the argument value ", arg, ".

"; ]; [ SectionsSub; markup_start (); print "

Filtering Standard Printed Output:

"; print "This text is being printed out with plain, ordinary print "..." statements, without any explicit need to specify markup. This is because it lies between calls to markup_start() and markup_end()."; print "

One advantage of this mode is that tags can span print statements, for example this link's leading tag is split."; print "

Even character entities such as &"; print "e"; print "ac"; print "u"; print "te; (&eacute;) can span print statements.<"; print "b"; print "r"; print ">"; print "<"; print "b"; print "r"; print ">"; print "Markup sections are slightly hazardous, though, and it's usually cleaner and clearer to call markup explicitly.

"; markup_end (); markup_start (); markup ("Calls to markup() within markup sections are treated like calls to print."); print (markup) " Adding (markup) to print calls causes no ill effects in sections, either.

"; markup ("Function call arguments to markup work inside sections."); markup (print_stuff, 4321); markup_end (); markup ("Function call arguments to markup also work outside sections."); markup (print_stuff, 1234); ]; [ InvalidSub; markup ("

Invalid Markup Entities:

"); markup ("Unknown entities &zzzzzz; and &aaaaaa; - &zzzzzz;, &aaaaaa;.
"); markup ("Unterminated entity &noend - &noend.
"); markup ("Extended entity &eacutex; - éx;.
"); markup ("Lead spaced entity & yuml; - & yuml;.
"); markup ("Trail spaced entity &yuml ; - ÿ ;.
"); markup ("Truncated entity &abc - &abc"); markup ("
"); markup ("Empty numeric entity &#; - &#;.
"); markup ("Space numeric entity &# ; - &# ;.
"); markup ("Invalid numeric entity &#ABC; - &#ABC;.
"); markup ("Over range numeric entity &#256; - Ā.
"); markup ("Under range numeric entity &#0; - �.
"); markup ("

Invalid Layout Tags:

"); markup ("Unknown tags <zzz> and <aaa>- '', ''.
"); markup ("Unknown end tags </zzz> and </aaa> - '
', ''.
"); markup ("Unterminated tag <tag - '"); markup ("Unterminated end tag </tag - '"); markup ("Partly truncated tag <tag - '"); markup ("Fully truncated tag < - '<"); markup ("
"); markup ("Unterminated end tag </tag - '"); markup ("Fully truncated end tag </ - '"); markup ("

Invalid Image Tags:

"); markup ("Missing SRC= argument <IMG > - ''.
"); markup ("Unterminated argument <IMG SRC='PIC1> - ' - '"); markup ("End image tag (ignored) </IMG> - ''.
"); markup ("Missing picture (alt) <IMG SRC=999 ALT=alt> - alt.
"); markup ("

Invalid Anchor Tags:

"); markup ("Missing HREF= argument <A >xxx</A> - 'xxx'.
"); markup ("Bogus argument <A SRC=1>xxx</A> - 'xxx'.
"); markup ("Unterminated argument <A HREF='1>xxx</A> - ' - '"); ]; #Ifdef TARGET_GLULX; Array buf -> 1024; [ FileSub fileref stream len; markup ("

Filtering an Input File:

"); print (markup) "Please select a file to filter...
"; fileref = glk_fileref_create_by_prompt (fileusage_TextMode, filemode_Read, 0); if (~~fileref) { print (markup) "Not a valid file reference, sorry.

"; return; } stream = glk_stream_open_file (fileref, filemode_Read, 0); glk_fileref_destroy (fileref); if (~~stream) { print (markup) "Couldn't open this file, sorry.

"; return; } markup ("
"); len = glk_get_line_stream (stream, buf, 1024); while (len > 0) { markup_printfilter (buf, len); len = glk_get_line_stream (stream, buf, 1024); } glk_stream_close (stream, 0); markup (""); ! reset markup ]; #Endif; [ InputSub; markup ("

Filtering Typed Input:

"); print (markup) "Enter strings to filter, or a blank line to exit...
"; markup (""); do { markup_waitline->0 = 0; ! in case suppressed print (markup) "MARKUP>"; markup_printfilter (markup_waitline + 1, markup_waitline->0); print (markup) "
"; } until (markup_waitline->0 == 0); markup ("
"); ! reset markup ]; [ AllSub; ; ; ; markup (""); ! trick to flush output ; ; ; ; ; ; ; ; ; ]; Include "Grammar"; Verb 'help' * -> Look; Verb 'entities' * -> Entities; Verb 'styles' * -> Styles; Verb 'colors' 'colours' * -> Colors; Verb 'nesting' * -> Nesting; Verb 'layouts' * -> Layouts; Verb 'clears' * -> Clears; Verb 'infos' * -> Infos; Verb 'delays' * -> Delays; Verb 'images' * -> Images; Verb 'links' * -> Links; Verb 'sections' * -> Sections; Verb 'input' * -> Input; #Ifdef TARGET_GLULX; Verb 'file' * -> File; #Endif; Verb 'invalid' * -> Invalid; Verb 'all' * -> All;