Difference between pages "Oberon/ETH Oberon/2003-01-05/HTML.Mod" and "Oberon/A2/Oberon.HTML.Mod"

(Difference between pages)
Jump to navigation Jump to search
[checked revision][checked revision]
 
m (PeterEasthope moved page Oberon/Oberon.HTML.Mod to Oberon/A2/Oberon.HTML.Mod: Rationalizing page names.)
 
Line 1: Line 1:
<span style="font-family: Oberon, Helvetica, sans-serif;
+
<span style="font-family: Oberon, Helvetica, sans-serif; font-size: 1rem; font-weight: normal
  +
font-style: normal; color: #000000; position: relative; top: 0%"
font-size: 1rem;
 
 
>(* ETH Oberon, Copyright 2001 ETH Zuerich Institut fuer Computersysteme, ETH Zentrum, CH-8092 Zuerich.
font-weight: normal;
 
  +
Refer to the "General ETH Oberon System Source License" contract available at<nowiki>:</nowiki>
font-style: normal;
 
  +
[ftp://ftp.ethoberon.ethz.ch/ETHOberon/license.txt ftp://ftp.ethoberon.ethz.ch/ETHOberon/license.txt] . *)
color: #000000;
 
position: relative;
 
top: 0%">(* ETH Oberon, Copyright 1990-2003 Computer Systems Institute, ETH Zurich, CH-8092 Zurich.
 
Refer to the license.txt file provided with this distribution. *)
 
 
 
MODULE HTML; (** portable *) (* jm 26.8.94 *)
+
MODULE HTML IN Oberon; (** portable *) (* jm 26.8.94 *)
 
 
 
IMPORT
 
IMPORT
Line 24: Line 21:
 
 
 
&#9;tab &#61; 09X;
 
&#9;tab &#61; 09X;
&#9;
 
&#9;DocHeader &#61; TRUE; (* include document header comment *)
 
&#9;BodyColor &#61; TRUE; (* set body color - HTML 4-specific *)
 
 
 
 
&#9;DocHeader &#61; TRUE; (* include document header comment *)
 
&#9;BodyColor &#61; FALSE; (* set body color - HTML 4-specific *)
  +
<span style="color: #009A00">&#9;(* One DTD should be uncommented. If necessary, add one. Recompile after any change.
  +
&#9;&#9;Ref. [https://www.w3.org/QA/2002/04/valid-dtd-list.html https://www.w3.org/QA/2002/04/valid-dtd-list.html] *)
  +
&#9;(* DTD &#61; "none"; This will suppress the DTD. *)
  +
&#9;(* DTD &#61; "HTML401Strict"; *)
  +
&#9;(* DTD &#61; "HTML401Trans"; *)
  +
&#9;(* DTD &#61; "HTML401Frameset; *)
  +
&#9;DTD &#61; "html"; (* HTML5" *)
  +
&#9;(* CharEncoding &#61; "iso-8859-1"; Obsolete. *)
  +
&#9;CharEncoding &#61; "UTF-8"; (* Ref. [[w:Character_encoding|https://en.wikipedia.org/wiki/Character_encoding]] . *)
  +
&#9;lang &#61; "en"; (* Ref. [https://www.w3.org/International/questions/qa-html-language-declarations#basics https://www.w3.org/International/questions/qa-html-language-declarations#basics] . *)
  +
</span>
 
VAR
 
VAR
&#9;out&#58; Files.Rider;
+
&#9;out<nowiki>:</nowiki> Files.Rider;
&#9;italic&#58; BOOLEAN;
+
&#9;italic<nowiki>:</nowiki> BOOLEAN;
&#9;sep&#58; CHAR;
+
&#9;sep<nowiki>:</nowiki> CHAR;
 
 
PROCEDURE S(s&#58; ARRAY OF CHAR);
+
PROCEDURE S(s<nowiki>:</nowiki> ARRAY OF CHAR);
VAR i&#58; INTEGER;
+
VAR i<nowiki>:</nowiki> INTEGER;
 
BEGIN
 
BEGIN
&#9;i &#58;&#61; 0;
+
&#9;i <nowiki>:</nowiki>&#61; 0;
 
&#9;WHILE s&#91;i&#93; # 0X DO Files.Write(out, s&#91;i&#93;); INC(i) END
 
&#9;WHILE s&#91;i&#93; # 0X DO Files.Write(out, s&#91;i&#93;); INC(i) END
 
END S;
 
END S;
 
 
PROCEDURE C(ch&#58; CHAR); BEGIN Files.Write(out, ch) END C;
+
PROCEDURE C(ch<nowiki>:</nowiki> CHAR); BEGIN Files.Write(out, ch) END C;
 
 
 
PROCEDURE L; BEGIN Files.Write(out, sep); END L;
 
PROCEDURE L; BEGIN Files.Write(out, sep); END L;
 
 
 
(* Check if font matches type. type &#61; digit &#123; digit &#125; ("." &#124; "b" &#124; "i"). *)
 
(* Check if font matches type. type &#61; digit &#123; digit &#125; ("." &#124; "b" &#124; "i"). *)
PROCEDURE MatchFont(font&#58; ARRAY OF CHAR; type&#58; ARRAY OF CHAR)&#58; BOOLEAN;
+
PROCEDURE MatchFont(font<nowiki>:</nowiki> ARRAY OF CHAR; type<nowiki>:</nowiki> ARRAY OF CHAR)<nowiki>:</nowiki> BOOLEAN;
VAR i, j&#58; LONGINT;
+
VAR i, j<nowiki>:</nowiki> LONGINT;
 
BEGIN
 
BEGIN
&#9;i &#58;&#61; 0;
+
&#9;i <nowiki>:</nowiki>&#61; 0;
 
&#9;WHILE (font&#91;i&#93; # 0X) &#38; ((font&#91;i&#93; &#60; "0") OR (font&#91;i&#93; &#62; "9")) DO (* skip name *)
 
&#9;WHILE (font&#91;i&#93; # 0X) &#38; ((font&#91;i&#93; &#60; "0") OR (font&#91;i&#93; &#62; "9")) DO (* skip name *)
 
&#9;&#9;INC(i)
 
&#9;&#9;INC(i)
 
&#9;END;
 
&#9;END;
&#9;j &#58;&#61; 0;
+
&#9;j <nowiki>:</nowiki>&#61; 0;
 
&#9;WHILE (font&#91;i&#93; # 0X) &#38; (font&#91;i&#93; &#62;&#61; "0") &#38; (font&#91;i&#93; &#60;&#61; "9") &#38; (font&#91;i&#93; &#61; type&#91;j&#93;) DO
 
&#9;WHILE (font&#91;i&#93; # 0X) &#38; (font&#91;i&#93; &#62;&#61; "0") &#38; (font&#91;i&#93; &#60;&#61; "9") &#38; (font&#91;i&#93; &#61; type&#91;j&#93;) DO
 
&#9;&#9;INC(i); INC(j)
 
&#9;&#9;INC(i); INC(j)
Line 59: Line 66:
 
END MatchFont;
 
END MatchFont;
 
 
(* Delimit a paragraph&#58; begins at lastnl and ends at end *)
+
(* Delimit a paragraph<nowiki>:</nowiki> begins at lastnl and ends at end *)
PROCEDURE GetPara(T&#58; Texts.Text; VAR R&#58; Texts.Reader; VAR beg, end&#58; LONGINT; VAR typ&#58; SHORTINT);
+
PROCEDURE GetPara(T<nowiki>:</nowiki> Texts.Text; VAR R<nowiki>:</nowiki> Texts.Reader; VAR beg, end<nowiki>:</nowiki> LONGINT; VAR typ<nowiki>:</nowiki> SHORTINT);
VAR ch, firstch&#58; CHAR; firstfnt&#58; Objects.Library; firstcol&#58; INTEGER; lastnl&#58; LONGINT;
+
VAR ch, firstch<nowiki>:</nowiki> CHAR; firstfnt<nowiki>:</nowiki> Objects.Library; firstcol<nowiki>:</nowiki> INTEGER; lastnl<nowiki>:</nowiki> LONGINT;
 
BEGIN
 
BEGIN
&#9;beg &#58;&#61; Texts.Pos(R); end &#58;&#61; beg; lastnl &#58;&#61; beg;
+
&#9;beg <nowiki>:</nowiki>&#61; Texts.Pos(R); end <nowiki>:</nowiki>&#61; beg; lastnl <nowiki>:</nowiki>&#61; beg;
  +
&#9;
 
 
&#9;(* skip empty lines *)
 
&#9;(* skip empty lines *)
 
&#9;Texts.Read(R, ch);
 
&#9;Texts.Read(R, ch);
 
&#9;WHILE &#126;R.eot &#38; (ch &#60;&#61; " ") DO
 
&#9;WHILE &#126;R.eot &#38; (ch &#60;&#61; " ") DO
 
&#9;&#9;INC(beg);
 
&#9;&#9;INC(beg);
&#9;&#9;IF ch &#61; 0DX THEN lastnl &#58;&#61; beg END;
+
&#9;&#9;IF ch &#61; 0DX THEN lastnl <nowiki>:</nowiki>&#61; beg END;
 
&#9;&#9;Texts.Read(R, ch)
 
&#9;&#9;Texts.Read(R, ch)
 
&#9;END;
 
&#9;END;
  +
&#9;
 
 
&#9;IF &#126;R.eot THEN
 
&#9;IF &#126;R.eot THEN
&#9;&#9;firstch &#58;&#61; ch; firstfnt &#58;&#61; R.lib; firstcol &#58;&#61; R.col;
+
&#9;&#9;firstch <nowiki>:</nowiki>&#61; ch; firstfnt <nowiki>:</nowiki>&#61; R.lib; firstcol <nowiki>:</nowiki>&#61; R.col;
 
&#9;&#9;LOOP
 
&#9;&#9;LOOP
 
&#9;&#9;&#9;WHILE &#126;R.eot &#38; (ch # 0DX) DO Texts.Read(R, ch) END; (* read till first nl *)
 
&#9;&#9;&#9;WHILE &#126;R.eot &#38; (ch # 0DX) DO Texts.Read(R, ch) END; (* read till first nl *)
 
&#9;&#9;&#9;IF R.eot THEN EXIT END;
 
&#9;&#9;&#9;IF R.eot THEN EXIT END;
 
&#9;&#9;&#9;IF ch &#61; 0DX THEN
 
&#9;&#9;&#9;IF ch &#61; 0DX THEN
&#9;&#9;&#9;&#9;end &#58;&#61; Texts.Pos(R)-1;
+
&#9;&#9;&#9;&#9;end <nowiki>:</nowiki>&#61; Texts.Pos(R)-1;
 
&#9;&#9;&#9;&#9;Texts.Read(R, ch);
 
&#9;&#9;&#9;&#9;Texts.Read(R, ch);
 
&#9;&#9;&#9;&#9;WHILE &#126;R.eot &#38; (ch &#61; " ") OR (ch &#61; tab) DO Texts.Read(R, ch) END;
 
&#9;&#9;&#9;&#9;WHILE &#126;R.eot &#38; (ch &#61; " ") OR (ch &#61; tab) DO Texts.Read(R, ch) END;
Line 86: Line 93:
 
&#9;&#9;&#9;END
 
&#9;&#9;&#9;END
 
&#9;&#9;END;
 
&#9;&#9;END;
&#9;&#9;IF firstcol &#61; 1 THEN (* red *) typ &#58;&#61; title
+
&#9;&#9;IF firstcol &#61; 1 THEN (* red *) typ <nowiki>:</nowiki>&#61; title
&#9;&#9;ELSIF MatchFont(firstfnt.name, "12b") THEN typ &#58;&#61; heading
+
&#9;&#9;ELSIF MatchFont(firstfnt.name, "12b") THEN typ <nowiki>:</nowiki>&#61; heading
&#9;&#9;ELSIF MatchFont(firstfnt.name, "10.") THEN typ &#58;&#61; pre; beg &#58;&#61; lastnl;
+
&#9;&#9;ELSIF MatchFont(firstfnt.name, "10.") THEN typ <nowiki>:</nowiki>&#61; pre; beg <nowiki>:</nowiki>&#61; lastnl;
&#9;&#9;ELSIF firstch &#61; "*" THEN typ &#58;&#61; bullet
+
&#9;&#9;ELSIF firstch &#61; "*" THEN typ <nowiki>:</nowiki>&#61; bullet
&#9;&#9;ELSIF firstch &#61; "-" THEN typ &#58;&#61; line
+
&#9;&#9;ELSIF firstch &#61; "-" THEN typ <nowiki>:</nowiki>&#61; line
&#9;&#9;ELSE typ &#58;&#61; para
+
&#9;&#9;ELSE typ <nowiki>:</nowiki>&#61; para
 
&#9;&#9;END
 
&#9;&#9;END
 
&#9;END
 
&#9;END
 
END GetPara;
 
END GetPara;
 
 
PROCEDURE WriteStretch(T&#58; Texts.Text; beg, end&#58; LONGINT);
+
PROCEDURE WriteStretch(T<nowiki>:</nowiki> Texts.Text; beg, end<nowiki>:</nowiki> LONGINT);
VAR R&#58; Texts.Reader; ch&#58; CHAR; lastlib&#58; Objects.Library;
+
VAR R<nowiki>:</nowiki> Texts.Reader; ch<nowiki>:</nowiki> CHAR; lastlib<nowiki>:</nowiki> Objects.Library;
 
BEGIN
 
BEGIN
&#9;IF end &#62; beg THEN
+
&#9;IF end &#62; beg THEN
 
&#9;&#9;Texts.OpenReader(R, T, beg);
 
&#9;&#9;Texts.OpenReader(R, T, beg);
&#9;&#9;Texts.Read(R, ch); lastlib &#58;&#61; R.lib;
+
&#9;&#9;Texts.Read(R, ch); lastlib <nowiki>:</nowiki>&#61; R.lib;
 
&#9;&#9;WHILE beg &#60; end DO
 
&#9;&#9;WHILE beg &#60; end DO
 
&#9;&#9;&#9;IF R.lib # lastlib THEN
 
&#9;&#9;&#9;IF R.lib # lastlib THEN
 
&#9;&#9;&#9;&#9;IF MatchFont(R.lib.name, "12i") THEN
 
&#9;&#9;&#9;&#9;IF MatchFont(R.lib.name, "12i") THEN
&#9;&#9;&#9;&#9;&#9;IF &#126;italic THEN S("&#60;i&#62;"); italic &#58;&#61; TRUE END
+
&#9;&#9;&#9;&#9;&#9;IF &#126;italic THEN S("&#60;i&#62;"); italic <nowiki>:</nowiki>&#61; TRUE END
 
&#9;&#9;&#9;&#9;ELSE
 
&#9;&#9;&#9;&#9;ELSE
&#9;&#9;&#9;&#9;&#9;IF italic THEN S("&#60;/i&#62;"); italic &#58;&#61; FALSE END
+
&#9;&#9;&#9;&#9;&#9;IF italic THEN S("&#60;/i&#62;"); italic <nowiki>:</nowiki>&#61; FALSE END
 
&#9;&#9;&#9;&#9;END;
 
&#9;&#9;&#9;&#9;END;
&#9;&#9;&#9;&#9;lastlib &#58;&#61; R.lib
+
&#9;&#9;&#9;&#9;lastlib <nowiki>:</nowiki>&#61; R.lib
 
&#9;&#9;&#9;END;
 
&#9;&#9;&#9;END;
&#9;&#9;&#9;IF ch &#61; "…" THEN S("&#38;uuml;")
+
<span style="color: #FF0000">&#9;&#9;&#9;IF ch &#61; 085X THEN S("&#38;uuml;")
&#9;&#9;&#9;ELSIF ch &#61; "‚" THEN S("&#38;Uuml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 082X THEN S("&#38;Uuml;")
&#9;&#9;&#9;ELSIF ch &#61; "" THEN S("&#38;ugrave;")
+
&#9;&#9;&#9;ELSIF ch &#61; 08FX THEN S("&#38;ugrave;")
&#9;&#9;&#9;ELSIF ch &#61; "ƒ" THEN S("&#38;auml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 083X THEN S("&#38;auml;")
&#9;&#9;&#9;ELSIF ch &#61; "€" THEN S("&#38;Auml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 080X THEN S("&#38;Auml;")
&#9;&#9;&#9;ELSIF ch &#61; "”" THEN S("&#38;aacute;")
+
&#9;&#9;&#9;ELSIF ch &#61; 094X THEN S("&#38;aacute;")
&#9;&#9;&#9;ELSIF ch &#61; "‹" THEN S("&#38;agrave;")
+
&#9;&#9;&#9;ELSIF ch &#61; 08BX THEN S("&#38;agrave;")
&#9;&#9;&#9;ELSIF ch &#61; "‘" THEN S("&#38;euml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 091X THEN S("&#38;euml;")
&#9;&#9;&#9;ELSIF ch &#61; "" THEN S("&#38;eacute;")
+
&#9;&#9;&#9;ELSIF ch &#61; 090X THEN S("&#38;eacute;")
&#9;&#9;&#9;ELSIF ch &#61; "Œ" THEN S("&#38;egrave;")
+
&#9;&#9;&#9;ELSIF ch &#61; 08CX THEN S("&#38;egrave;")
&#9;&#9;&#9;ELSIF ch &#61; "„" THEN S("&#38;ouml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 084X THEN S("&#38;ouml;")
&#9;&#9;&#9;ELSIF ch &#61; "" THEN S("&#38;Ouml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 081X THEN S("&#38;Ouml;")
&#9;&#9;&#9;ELSIF ch &#61; "Ž" THEN S("&#38;ograve;")
+
&#9;&#9;&#9;ELSIF ch &#61; 08EX THEN S("&#38;ograve;")
&#9;&#9;&#9;ELSIF ch &#61; "’" THEN S("&#38;iuml;")
+
&#9;&#9;&#9;ELSIF ch &#61; 092X THEN S("&#38;iuml;")
&#9;&#9;&#9;ELSIF ch &#61; "" THEN S("&#38;igrave;")
+
&#9;&#9;&#9;ELSIF ch &#61; 08DX THEN S("&#38;igrave;")
&#9;&#9;&#9;ELSIF ch &#61; 0DX THEN C(" "); C(sep)
+
&#9;&#9;&#9;ELS</span>IF ch &#61; 0DX THEN C(" "); C(sep)
 
&#9;&#9;&#9;ELSIF ch &#61; tab THEN S("&#38;nbsp; &#38;nbsp; &#38;nbsp;")
 
&#9;&#9;&#9;ELSIF ch &#61; tab THEN S("&#38;nbsp; &#38;nbsp; &#38;nbsp;")
 
&#9;&#9;&#9;ELSIF (ch &#62;&#61; " ") OR (ch &#61; "-") THEN
 
&#9;&#9;&#9;ELSIF (ch &#62;&#61; " ") OR (ch &#61; "-") THEN
Line 137: Line 144:
 
END WriteStretch;
 
END WriteStretch;
 
 
PROCEDURE WritePara(T&#58; Texts.Text; beg, end&#58; LONGINT);
+
PROCEDURE WritePara(T<nowiki>:</nowiki> Texts.Text; beg, end<nowiki>:</nowiki> LONGINT);
VAR R&#58; Texts.Reader; ch&#58; CHAR; col&#58; INTEGER;
+
VAR R<nowiki>:</nowiki> Texts.Reader; ch<nowiki>:</nowiki> CHAR; col<nowiki>:</nowiki> INTEGER;
&#9;pos, lstart&#58; LONGINT; anchor&#58; ARRAY 512 OF CHAR; apos&#58; INTEGER;
+
&#9;pos, lstart<nowiki>:</nowiki> LONGINT; anchor<nowiki>:</nowiki> ARRAY 512 OF CHAR; apos<nowiki>:</nowiki> INTEGER;
BEGIN col &#58;&#61; -1; pos &#58;&#61; beg; anchor &#58;&#61; "";
+
BEGIN col <nowiki>:</nowiki>&#61; -1; pos <nowiki>:</nowiki>&#61; beg; anchor <nowiki>:</nowiki>&#61; "";
 
&#9;Texts.OpenReader(R, T, beg);
 
&#9;Texts.OpenReader(R, T, beg);
&#9;Texts.Read(R, ch);
+
&#9;Texts.Read(R, ch);
 
&#9;WHILE pos &#60; end DO
 
&#9;WHILE pos &#60; end DO
 
&#9;&#9;IF (R.col &#61; 3) &#38; (col # 3) THEN (* start link *)
 
&#9;&#9;IF (R.col &#61; 3) &#38; (col # 3) THEN (* start link *)
&#9;&#9;&#9;WriteStretch(T, beg, pos); beg &#58;&#61; pos
+
&#9;&#9;&#9;WriteStretch(T, beg, pos); beg <nowiki>:</nowiki>&#61; pos
 
&#9;&#9;END;
 
&#9;&#9;END;
&#9;&#9;col &#58;&#61; R.col;
+
&#9;&#9;col <nowiki>:</nowiki>&#61; R.col;
  +
&#9;&#9;&#32;
 
 
&#9;&#9;IF (col &#61; 3) &#38; (ch &#61; "&#123;") THEN (* reading an anchor *)
 
&#9;&#9;IF (col &#61; 3) &#38; (ch &#61; "&#123;") THEN (* reading an anchor *)
&#9;&#9;&#9;lstart &#58;&#61; pos;
+
&#9;&#9;&#9;lstart <nowiki>:</nowiki>&#61; pos;
 
&#9;&#9;&#9;INC(pos); Texts.Read(R, ch);
 
&#9;&#9;&#9;INC(pos); Texts.Read(R, ch);
&#9;&#9;&#9;apos &#58;&#61; 0;
+
&#9;&#9;&#9;apos <nowiki>:</nowiki>&#61; 0;
 
&#9;&#9;&#9;WHILE &#126;R.eot &#38; (apos &#60; LEN(anchor)) &#38; (ch # "&#125;") DO
 
&#9;&#9;&#9;WHILE &#126;R.eot &#38; (apos &#60; LEN(anchor)) &#38; (ch # "&#125;") DO
&#9;&#9;&#9;&#9;anchor&#91;apos&#93; &#58;&#61; ch; INC(apos);
+
&#9;&#9;&#9;&#9;anchor&#91;apos&#93; <nowiki>:</nowiki>&#61; ch; INC(apos);
 
&#9;&#9;&#9;&#9;INC(pos);
 
&#9;&#9;&#9;&#9;INC(pos);
 
&#9;&#9;&#9;&#9;Texts.Read(R, ch)
 
&#9;&#9;&#9;&#9;Texts.Read(R, ch)
 
&#9;&#9;&#9;END;
 
&#9;&#9;&#9;END;
&#9;&#9;&#9;anchor&#91;apos&#93; &#58;&#61; 0X;
+
&#9;&#9;&#9;anchor&#91;apos&#93; <nowiki>:</nowiki>&#61; 0X;
 
&#9;&#9;&#9;S("&#60;a href&#61;"); C(22X); S(anchor); C(22X); C("&#62;");
 
&#9;&#9;&#9;S("&#60;a href&#61;"); C(22X); S(anchor); C(22X); C("&#62;");
&#9;&#9;&#9;WriteStretch(T, beg, lstart); beg &#58;&#61; pos+1;
+
&#9;&#9;&#9;WriteStretch(T, beg, lstart); beg <nowiki>:</nowiki>&#61; pos+1;
 
&#9;&#9;&#9;S("&#60;/a&#62;")
 
&#9;&#9;&#9;S("&#60;/a&#62;")
 
&#9;&#9;ELSE INC(pos); Texts.Read(R, ch)
 
&#9;&#9;ELSE INC(pos); Texts.Read(R, ch)
Line 168: Line 175:
 
END WritePara;
 
END WritePara;
 
 
PROCEDURE GetPrefix(T&#58; Texts.Text; VAR beg, end&#58; LONGINT; VAR s&#58; ARRAY OF CHAR);
+
PROCEDURE GetPrefix(T<nowiki>:</nowiki> Texts.Text; VAR beg, end<nowiki>:</nowiki> LONGINT; VAR s<nowiki>:</nowiki> ARRAY OF CHAR);
VAR R&#58; Texts.Reader; old&#58; LONGINT; ch&#58; CHAR; i&#58; INTEGER;
+
VAR R<nowiki>:</nowiki> Texts.Reader; old<nowiki>:</nowiki> LONGINT; ch<nowiki>:</nowiki> CHAR; i<nowiki>:</nowiki> INTEGER;
 
BEGIN
 
BEGIN
&#9;old &#58;&#61; beg; i &#58;&#61; 0;
+
&#9;old <nowiki>:</nowiki>&#61; beg; i <nowiki>:</nowiki>&#61; 0;
 
&#9;Texts.OpenReader(R, T, beg);
 
&#9;Texts.OpenReader(R, T, beg);
 
&#9;Texts.Read(R, ch);
 
&#9;Texts.Read(R, ch);
&#9;WHILE &#126;R.eot &#38; (ch # "&#58;") &#38; (beg &#60; end) DO
+
&#9;WHILE &#126;R.eot &#38; (ch # "<nowiki>:</nowiki>") &#38; (beg &#60; end) DO
&#9;&#9;IF (ch &#62; " ") &#38; (i &#60; LEN(s) - 1) THEN s&#91;i&#93; &#58;&#61; ch; INC(i) END;
+
&#9;&#9;IF (ch &#62; " ") &#38; (i &#60; LEN(s) - 1) THEN s&#91;i&#93; <nowiki>:</nowiki>&#61; ch; INC(i) END;
 
&#9;&#9;INC(beg);
 
&#9;&#9;INC(beg);
 
&#9;&#9;Texts.Read(R, ch)
 
&#9;&#9;Texts.Read(R, ch)
 
&#9;END;
 
&#9;END;
&#9;IF ch &#61; "&#58;" THEN s&#91;i&#93; &#58;&#61; 0X; INC(beg)
+
&#9;IF ch &#61; "<nowiki>:</nowiki>" THEN s&#91;i&#93; <nowiki>:</nowiki>&#61; 0X; INC(beg)
&#9;ELSE s&#91;0&#93; &#58;&#61; 0X; beg &#58;&#61; old
+
&#9;ELSE s&#91;0&#93; <nowiki>:</nowiki>&#61; 0X; beg <nowiki>:</nowiki>&#61; old
 
&#9;END
 
&#9;END
 
END GetPrefix;
 
END GetPrefix;
 
 
PROCEDURE ConvertText(T&#58; Texts.Text; start&#58; LONGINT; VAR filename&#58; ARRAY OF CHAR);
+
PROCEDURE ConvertText(T<nowiki>:</nowiki> Texts.Text; start<nowiki>:</nowiki> LONGINT; VAR filename<nowiki>:</nowiki> ARRAY OF CHAR);
VAR R&#58; Texts.Reader; beg, end, nbeg, nend&#58; LONGINT; typ, ntyp&#58; SHORTINT; <span style="color: #0000FF">body&#58; BOOLEAN;
+
VAR R<nowiki>:</nowiki> Texts.Reader; beg, end, nbeg, nend<nowiki>:</nowiki> LONGINT; typ, ntyp<nowiki>:</nowiki> SHORTINT; <span style="color: #0000FF">body<nowiki>:</nowiki> BOOLEAN;
 
</span>
 
</span>
 
<span style="color: #0000FF">&#9;PROCEDURE StartBody;
 
<span style="color: #0000FF">&#9;PROCEDURE StartBody;
Line 195: Line 202:
 
&#9;&#9;&#9;S("&#60;body&#62;"); L
 
&#9;&#9;&#9;S("&#60;body&#62;"); L
 
&#9;&#9;END;
 
&#9;&#9;END;
&#9;&#9;body &#58;&#61; TRUE
+
&#9;&#9;body <nowiki>:</nowiki>&#61; TRUE
 
&#9;END StartBody;
 
&#9;END StartBody;
</span>&#9;
+
</span>
 
BEGIN
 
BEGIN
&#9;italic &#58;&#61; FALSE; <span style="color: #0000FF">body &#58;&#61; FALSE;
+
&#9;italic <nowiki>:</nowiki>&#61; FALSE; <span style="color: #0000FF">body <nowiki>:</nowiki>&#61; FALSE;
 
</span>&#9;Texts.OpenReader(R, T, start);
 
</span>&#9;Texts.OpenReader(R, T, start);
 
&#9;GetPara(T, R, beg, end, typ);
 
&#9;GetPara(T, R, beg, end, typ);
&#9;IF DocHeader THEN
+
&#9;<span style="color: #FF0000">(* IF DocHeader THEN
&#9;&#9;S("&#60;!DOCTYPE HTML PUBLIC "); C(22X); S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X); S("&#62;"); L
+
&#9;&#9;S("&#60;!DOCTYPE HTML PUBLIC "); C(22X); S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X); S("&#62;"); L
  +
&#9;END; *)</span>
  +
&#9;<span style="color: #009A00">IF DTD &#61; "HTML401Strict" THEN
  +
&#9;&#9;S("&#60;!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01//EN"); C(22X);
  +
&#9;&#9;S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/strict.dtd"); S("&#62;"); L
  +
&#9;ELSIF DTD &#61; "HTML401Trans" THEN
  +
&#9;&#9;S("&#60;!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X);
  +
&#9;&#9;S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/loose.dtd"); S("&#62;"); L
  +
&#9;ELSIF DTD &#61; "HTML401Frameset" THEN
  +
&#9;&#9;S("&#60;!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01 Frameset//EN"); C(22X);
  +
&#9;&#9;S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/frameset.dtd"); S("&#62;"); L
  +
&#9;ELSIF DTD &#61; "html" THEN
  +
&#9;&#9;S("&#60;!DOCTYPE html&#62;"); L
  +
&#9;ELSE (* no DTD *)</span>
 
&#9;END;
 
&#9;END;
&#9;S("&#60;html&#62;"); L;
+
&#9;<span style="color: #009A00">S("&#60;html lang&#61;"); C(22X); S(lang); C(22X); S("&#62;"); L;</span>
 
&#9;S("&#60;head&#62;"); L;
 
&#9;S("&#60;head&#62;"); L;
 
&#9;S("&#60;title&#62;");
 
&#9;S("&#60;title&#62;");
Line 211: Line 231:
 
&#9;&#9;GetPrefix(T, beg, end, filename); (* Skip that file name, discarding it *)
 
&#9;&#9;GetPrefix(T, beg, end, filename); (* Skip that file name, discarding it *)
 
&#9;&#9;WritePara(T, beg, end);
 
&#9;&#9;WritePara(T, beg, end);
<span style="color: #0000FF">&#9;&#9;beg &#58;&#61; end (* title paragraph already written *)
+
<span style="color: #0000FF">&#9;&#9;beg <nowiki>:</nowiki>&#61; end (* title paragraph already written *)
 
</span>&#9;ELSE
 
</span>&#9;ELSE
 
&#9;&#9;S("Untitled")
 
&#9;&#9;S("Untitled")
 
&#9;END;
 
&#9;END;
 
&#9;S("&#60;/title&#62;"); L;
 
&#9;S("&#60;/title&#62;"); L;
&#9;S(&#39;&#60;meta http-equiv&#61;"Content-Type" content&#61;"text/html; charset&#61;iso-8859-1"&#62;&#39;); L;
+
&#9;S(&#39;&#60;meta http-equiv&#61;"Content-Type" content&#61;"text/html; charset&#61;&#39;);S(CharEncoding);S(&#39;"&#62;&#39;); L;
 
&#9;WHILE &#126;R.eot DO
 
&#9;WHILE &#126;R.eot DO
 
<span style="color: #0000FF">&#9;&#9;IF &#126;body &#38; (typ # title) THEN StartBody END; (* first non-title paragraph starts body *)
 
<span style="color: #0000FF">&#9;&#9;IF &#126;body &#38; (typ # title) THEN StartBody END; (* first non-title paragraph starts body *)
 
</span>&#9;&#9;GetPara(T, R, nbeg, nend, ntyp);
 
</span>&#9;&#9;GetPara(T, R, nbeg, nend, ntyp);
<span style="color: #0000FF">&#9;&#9;IF body &#38; (ntyp &#61; title) THEN ntyp &#58;&#61; para END; (* treat a title paragraph in body like normal *)
+
<span style="color: #0000FF">&#9;&#9;IF body &#38; (ntyp &#61; title) THEN ntyp <nowiki>:</nowiki>&#61; para END; (* treat a title paragraph in body like normal *)
 
</span>&#9;&#9;IF typ &#61; bullet THEN S("&#60;li&#62;"); INC(beg)
 
</span>&#9;&#9;IF typ &#61; bullet THEN S("&#60;li&#62;"); INC(beg)
 
&#9;&#9;ELSIF typ &#61; heading THEN S("&#60;h2&#62;")
 
&#9;&#9;ELSIF typ &#61; heading THEN S("&#60;h2&#62;")
Line 233: Line 253:
 
&#9;&#9;IF typ &#61; heading THEN S("&#60;/h2&#62;") END;
 
&#9;&#9;IF typ &#61; heading THEN S("&#60;/h2&#62;") END;
 
&#9;&#9;<span style="color: #0000FF">IF beg # end THEN</span> L <span style="color: #0000FF">END</span>;
 
&#9;&#9;<span style="color: #0000FF">IF beg # end THEN</span> L <span style="color: #0000FF">END</span>;
  +
&#9;&#9;
 
 
&#9;&#9;(* List *)
 
&#9;&#9;(* List *)
 
&#9;&#9;IF (ntyp &#61; bullet) &#38; (typ # bullet) THEN (* open list *)
 
&#9;&#9;IF (ntyp &#61; bullet) &#38; (typ # bullet) THEN (* open list *)
Line 240: Line 260:
 
<span style="color: #FF0000">&#9;&#9;&#9;</span>S("&#60;/ul&#62;"); L<span style="color: #FF0000">
 
<span style="color: #FF0000">&#9;&#9;&#9;</span>S("&#60;/ul&#62;"); L<span style="color: #FF0000">
 
</span>&#9;&#9;END;
 
</span>&#9;&#9;END;
  +
&#9;&#9;
 
 
&#9;&#9;(* Pre-formatted text *)
 
&#9;&#9;(* Pre-formatted text *)
 
&#9;&#9;IF (ntyp &#61; pre) &#38; (typ # pre) THEN (* start pre-formatted text *)
 
&#9;&#9;IF (ntyp &#61; pre) &#38; (typ # pre) THEN (* start pre-formatted text *)
<span style="color: #0000FF">&#9;&#9;&#9;IF &#126;body THEN StartBody END;
+
<span style="color: #FF0000">&#9;&#9;&#9;IF &#126;body THEN StartBody END;
 
</span>&#9;&#9;&#9;S("&#60;pre&#62;")
 
</span>&#9;&#9;&#9;S("&#60;pre&#62;")
 
&#9;&#9;ELSIF (ntyp # pre) &#38; (typ &#61; pre) THEN
 
&#9;&#9;ELSIF (ntyp # pre) &#38; (typ &#61; pre) THEN
 
&#9;&#9;&#9;S("&#60;/pre&#62;"); L
 
&#9;&#9;&#9;S("&#60;/pre&#62;"); L
 
&#9;&#9;END;
 
&#9;&#9;END;
  +
&#9;&#9;
 
 
&#9;&#9;(* Separate 2 consecutive "normal" paragraphs with a paragraph break, except two preformatteds *)
 
&#9;&#9;(* Separate 2 consecutive "normal" paragraphs with a paragraph break, except two preformatteds *)
 
&#9;&#9;IF (ntyp &#61; para) &#38; (typ &#61; para) THEN S("&#60;p&#62;"); L END;
 
&#9;&#9;IF (ntyp &#61; para) &#38; (typ &#61; para) THEN S("&#60;p&#62;"); L END;
  +
&#9;&#9;
 
&#9;&#9;end &#58;&#61; nend; beg &#58;&#61; nbeg; typ &#58;&#61; ntyp
+
&#9;&#9;end <nowiki>:</nowiki>&#61; nend; beg <nowiki>:</nowiki>&#61; nbeg; typ <nowiki>:</nowiki>&#61; ntyp
 
&#9;END;
 
&#9;END;
 
&#9;<span style="color: #0000FF">IF &#126;body &#38; (typ # title) THEN StartBody END;</span>
 
&#9;<span style="color: #0000FF">IF &#126;body &#38; (typ # title) THEN StartBody END;</span>
Line 266: Line 286:
 
END ConvertText;
 
END ConvertText;
 
 
(** Show a preview of the HTML text in a text viewer - Processes ONLY one text! *)
+
(** Show a preview of the HTML text in a text viewer - Processes ONLY one text! *)
 
PROCEDURE Show*;
 
PROCEDURE Show*;
VAR S&#58; Texts.Scanner; T, t&#58; Texts.Text; time, beg, end&#58; LONGINT;
+
VAR S<nowiki>:</nowiki> Texts.Scanner; T, t<nowiki>:</nowiki> Texts.Text; time, beg, end<nowiki>:</nowiki> LONGINT;
&#9;filename&#58; ARRAY 64 OF CHAR; f&#58; Files.File;
+
&#9;filename<nowiki>:</nowiki> ARRAY 64 OF CHAR; f<nowiki>:</nowiki> Files.File;
 
BEGIN
 
BEGIN
&#9;sep &#58;&#61; 0DX;
+
&#9;sep <nowiki>:</nowiki>&#61; 0DX;
&#9;beg &#58;&#61; 0; (* Process from the beginning of the text. Modified if "@" used *)
+
&#9;beg <nowiki>:</nowiki>&#61; 0; (* Process from the beginning of the text. Modified if "@" used *)
 
&#9;Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
 
&#9;Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
&#9;Texts.Scan(S); T &#58;&#61; NIL;
+
&#9;Texts.Scan(S); T <nowiki>:</nowiki>&#61; NIL;
 
&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "*") THEN
 
&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "*") THEN
&#9;&#9;T &#58;&#61; Oberon.MarkedText()
+
&#9;&#9;T <nowiki>:</nowiki>&#61; Oberon.MarkedText()
 
&#9;ELSIF (S.class &#61; Texts.Char) &#38; (S.c &#61; "^") THEN
 
&#9;ELSIF (S.class &#61; Texts.Char) &#38; (S.c &#61; "^") THEN
 
&#9;&#9;Oberon.GetSelection(T, beg, end, time);
 
&#9;&#9;Oberon.GetSelection(T, beg, end, time);
Line 284: Line 304:
 
&#9;&#9;&#9;IF (S.class &#61; Texts.Name) THEN
 
&#9;&#9;&#9;IF (S.class &#61; Texts.Name) THEN
 
&#9;&#9;&#9;&#9;NEW(T); Texts.Open(T, S.s);
 
&#9;&#9;&#9;&#9;NEW(T); Texts.Open(T, S.s);
&#9;&#9;&#9;&#9;IF T.len &#61; 0 THEN T &#58;&#61; NIL END
+
&#9;&#9;&#9;&#9;IF T.len &#61; 0 THEN T <nowiki>:</nowiki>&#61; NIL END
 
&#9;&#9;&#9;END
 
&#9;&#9;&#9;END
&#9;&#9;ELSE T &#58;&#61; NIL
+
&#9;&#9;ELSE T <nowiki>:</nowiki>&#61; NIL
 
&#9;&#9;END
 
&#9;&#9;END
 
&#9;ELSIF (S.class &#61; Texts.Char) &#38; (S.c &#61; "@") THEN
 
&#9;ELSIF (S.class &#61; Texts.Char) &#38; (S.c &#61; "@") THEN
 
&#9;&#9;Oberon.GetSelection(T, beg, end, time);
 
&#9;&#9;Oberon.GetSelection(T, beg, end, time);
&#9;&#9;IF time &#60; 0 THEN T &#58;&#61; NIL END
+
&#9;&#9;IF time &#60; 0 THEN T <nowiki>:</nowiki>&#61; NIL END
 
&#9;END;
 
&#9;END;
 
&#9;IF T # NIL THEN
 
&#9;IF T # NIL THEN
&#9;&#9;f &#58;&#61; Files.New("Temp.HTML.tmp");
+
&#9;&#9;f <nowiki>:</nowiki>&#61; Files.New("Temp.HTML.tmp");
 
&#9;&#9;Files.Set(out, f, 0);
 
&#9;&#9;Files.Set(out, f, 0);
 
&#9;&#9;ConvertText(T, beg, filename);
 
&#9;&#9;ConvertText(T, beg, filename);
Line 303: Line 323:
 
 
 
PROCEDURE Compile*;
 
PROCEDURE Compile*;
&#9;VAR S&#58; Texts.Scanner; T&#58; Texts.Text; filename&#58; ARRAY 64 OF CHAR; f&#58; Files.File; beg, end, time&#58; LONGINT;
+
&#9;VAR S<nowiki>:</nowiki> Texts.Scanner; T<nowiki>:</nowiki> Texts.Text; filename<nowiki>:</nowiki> ARRAY 64 OF CHAR; f<nowiki>:</nowiki> Files.File; beg, end, time<nowiki>:</nowiki> LONGINT;
 
 
&#9;PROCEDURE CompileT();
+
&#9;PROCEDURE CompileT;
&#9;&#9;VAR R&#58; Texts.Reader; beg, end&#58; LONGINT; typ&#58; SHORTINT;
+
&#9;&#9;VAR R<nowiki>:</nowiki> Texts.Reader; beg, end<nowiki>:</nowiki> LONGINT; typ<nowiki>:</nowiki> SHORTINT;
&#9;&#9;&#9;&#9;res, i&#58; INTEGER; bak&#58; ARRAY 64 OF CHAR;
+
&#9;&#9;&#9;&#9;res, i<nowiki>:</nowiki> INTEGER; bak<nowiki>:</nowiki> ARRAY 64 OF CHAR;
 
&#9;BEGIN
 
&#9;BEGIN
 
&#9;&#9;IF T.len &#62; 0 THEN
 
&#9;&#9;IF T.len &#62; 0 THEN
Line 320: Line 340:
 
&#9;&#9;&#9;&#9;Out.String(filename);
 
&#9;&#9;&#9;&#9;Out.String(filename);
 
&#9;&#9;&#9;(* Rename the file &#39;fileName.Bak&#39; *)
 
&#9;&#9;&#9;(* Rename the file &#39;fileName.Bak&#39; *)
&#9;&#9;&#9;&#9;i &#58;&#61; 0;
+
&#9;&#9;&#9;&#9;i <nowiki>:</nowiki>&#61; 0;
&#9;&#9;&#9;&#9;WHILE filename&#91;i&#93; # 0X DO bak&#91;i&#93; &#58;&#61; filename&#91;i&#93;; INC(i) END;
+
&#9;&#9;&#9;&#9;WHILE filename&#91;i&#93; # 0X DO bak&#91;i&#93; <nowiki>:</nowiki>&#61; filename&#91;i&#93;; INC(i) END;
&#9;&#9;&#9;&#9;bak&#91;i&#93; &#58;&#61; "."; bak&#91;i+1&#93; &#58;&#61; "B"; bak&#91;i+2&#93; &#58;&#61; "a"; bak&#91;i+3&#93; &#58;&#61; "k"; bak&#91;i+4&#93; &#58;&#61; 0X;
+
&#9;&#9;&#9;&#9;bak&#91;i&#93; <nowiki>:</nowiki>&#61; "."; bak&#91;i+1&#93; <nowiki>:</nowiki>&#61; "B"; bak&#91;i+2&#93; <nowiki>:</nowiki>&#61; "a"; bak&#91;i+3&#93; <nowiki>:</nowiki>&#61; "k"; bak&#91;i+4&#93; <nowiki>:</nowiki>&#61; 0X;
 
&#9;&#9;&#9;&#9;Files.Rename(filename, bak, res);
 
&#9;&#9;&#9;&#9;Files.Rename(filename, bak, res);
 
&#9;&#9;&#9;(* *)
 
&#9;&#9;&#9;(* *)
&#9;&#9;&#9;&#9;f &#58;&#61; Files.New(filename);
+
&#9;&#9;&#9;&#9;f <nowiki>:</nowiki>&#61; Files.New(filename);
 
&#9;&#9;&#9;&#9;Files.Set(out, f, 0);
 
&#9;&#9;&#9;&#9;Files.Set(out, f, 0);
 
&#9;&#9;&#9;&#9;ConvertText(T, 0, filename);
 
&#9;&#9;&#9;&#9;ConvertText(T, 0, filename);
Line 335: Line 355:
 
&#9;&#9;Out.Ln
 
&#9;&#9;Out.Ln
 
&#9;END CompileT;
 
&#9;END CompileT;
  +
&#9;
 
 
BEGIN
 
BEGIN
&#9;sep &#58;&#61; 0AX;
+
&#9;sep <nowiki>:</nowiki>&#61; 0AX;
 
&#9;Out.String("HTML.Compile"); Out.Ln;
 
&#9;Out.String("HTML.Compile"); Out.Ln;
 
&#9;Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
 
&#9;Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
 
&#9;Texts.Scan(S);
 
&#9;Texts.Scan(S);
 
&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "*") THEN
 
&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "*") THEN
&#9;&#9;T &#58;&#61; Oberon.MarkedText();
+
&#9;&#9;T <nowiki>:</nowiki>&#61; Oberon.MarkedText();
 
&#9;&#9;IF T # NIL THEN
 
&#9;&#9;IF T # NIL THEN
 
&#9;&#9;&#9;CompileT()
 
&#9;&#9;&#9;CompileT()
 
&#9;&#9;END
 
&#9;&#9;END
 
&#9;ELSE
 
&#9;ELSE
&#9;&#9;end &#58;&#61; MAX(LONGINT) - 100;
+
&#9;&#9;end <nowiki>:</nowiki>&#61; MAX(LONGINT) - 100;
 
&#9;&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "^") THEN
 
&#9;&#9;IF (S.class &#61; Texts.Char) &#38; (S.c &#61; "^") THEN
 
&#9;&#9;&#9;Oberon.GetSelection(T, beg, end, time);
 
&#9;&#9;&#9;Oberon.GetSelection(T, beg, end, time);