Oberon/ETH Oberon/2.3.7/HTML.Mod and Oberon/A2/Oberon.HTML.Mod: Difference between pages
Appearance
(Difference between pages)
[checked revision] | [checked revision] |
Content deleted Content added
m Pi zero moved page Oberon/S3/2003-01-05/HTML.Mod to Oberon/ETH Oberon/2003-01-05/HTML.Mod without leaving a redirect: request by User:PeterEasthope (at Wikibooks:Reading room/Technical Assistance) |
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; |
|||
⚫ | |||
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; |
|||
⚫ | |||
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: | ||
	tab = 09X; |
	tab = 09X; |
||
	 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
<span style="color: #009A00">	(* One DTD should be uncommented. If necessary, add one. Recompile after any change. |
|||
		Ref. [https://www.w3.org/QA/2002/04/valid-dtd-list.html https://www.w3.org/QA/2002/04/valid-dtd-list.html] *) |
|||
	(* DTD = "none"; This will suppress the DTD. *) |
|||
	(* DTD = "HTML401Strict"; *) |
|||
	(* DTD = "HTML401Trans"; *) |
|||
	(* DTD = "HTML401Frameset; *) |
|||
	DTD = "html"; (* HTML5" *) |
|||
	(* CharEncoding = "iso-8859-1"; Obsolete. *) |
|||
	CharEncoding = "UTF-8"; (* Ref. [[w:Character_encoding|https://en.wikipedia.org/wiki/Character_encoding]] . *) |
|||
	lang = "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 |
||
	out |
	out<nowiki>:</nowiki> Files.Rider; |
||
	italic |
	italic<nowiki>:</nowiki> BOOLEAN; |
||
	sep |
	sep<nowiki>:</nowiki> CHAR; |
||
PROCEDURE S(s |
PROCEDURE S(s<nowiki>:</nowiki> ARRAY OF CHAR); |
||
VAR i |
VAR i<nowiki>:</nowiki> INTEGER; |
||
BEGIN |
BEGIN |
||
	i |
	i <nowiki>:</nowiki>= 0; |
||
	WHILE s[i] # 0X DO Files.Write(out, s[i]); INC(i) END |
	WHILE s[i] # 0X DO Files.Write(out, s[i]); INC(i) END |
||
END S; |
END S; |
||
PROCEDURE C(ch |
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 = digit { digit } ("." | "b" | "i"). *) |
(* Check if font matches type. type = digit { digit } ("." | "b" | "i"). *) |
||
PROCEDURE MatchFont(font |
PROCEDURE MatchFont(font<nowiki>:</nowiki> ARRAY OF CHAR; type<nowiki>:</nowiki> ARRAY OF CHAR)<nowiki>:</nowiki> BOOLEAN; |
||
VAR i, j |
VAR i, j<nowiki>:</nowiki> LONGINT; |
||
BEGIN |
BEGIN |
||
	i |
	i <nowiki>:</nowiki>= 0; |
||
	WHILE (font[i] # 0X) & ((font[i] < "0") OR (font[i] > "9")) DO (* skip name *) |
	WHILE (font[i] # 0X) & ((font[i] < "0") OR (font[i] > "9")) DO (* skip name *) |
||
		INC(i) |
		INC(i) |
||
	END; |
	END; |
||
	j |
	j <nowiki>:</nowiki>= 0; |
||
	WHILE (font[i] # 0X) & (font[i] >= "0") & (font[i] <= "9") & (font[i] = type[j]) DO |
	WHILE (font[i] # 0X) & (font[i] >= "0") & (font[i] <= "9") & (font[i] = type[j]) DO |
||
		INC(i); INC(j) |
		INC(i); INC(j) |
||
Line 59: | Line 66: | ||
END MatchFont; |
END MatchFont; |
||
(* Delimit a paragraph |
(* Delimit a paragraph<nowiki>:</nowiki> begins at lastnl and ends at end *) |
||
PROCEDURE GetPara(T |
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 |
VAR ch, firstch<nowiki>:</nowiki> CHAR; firstfnt<nowiki>:</nowiki> Objects.Library; firstcol<nowiki>:</nowiki> INTEGER; lastnl<nowiki>:</nowiki> LONGINT; |
||
BEGIN |
BEGIN |
||
	beg |
	beg <nowiki>:</nowiki>= Texts.Pos(R); end <nowiki>:</nowiki>= beg; lastnl <nowiki>:</nowiki>= beg; |
||
	 |
|||
	(* skip empty lines *) |
	(* skip empty lines *) |
||
	Texts.Read(R, ch); |
	Texts.Read(R, ch); |
||
	WHILE ~R.eot & (ch <= " ") DO |
	WHILE ~R.eot & (ch <= " ") DO |
||
		INC(beg); |
		INC(beg); |
||
		IF ch = 0DX THEN lastnl |
		IF ch = 0DX THEN lastnl <nowiki>:</nowiki>= beg END; |
||
		Texts.Read(R, ch) |
		Texts.Read(R, ch) |
||
	END; |
	END; |
||
	 |
|||
	IF ~R.eot THEN |
	IF ~R.eot THEN |
||
		firstch |
		firstch <nowiki>:</nowiki>= ch; firstfnt <nowiki>:</nowiki>= R.lib; firstcol <nowiki>:</nowiki>= R.col; |
||
		LOOP |
		LOOP |
||
			WHILE ~R.eot & (ch # 0DX) DO Texts.Read(R, ch) END; (* read till first nl *) |
			WHILE ~R.eot & (ch # 0DX) DO Texts.Read(R, ch) END; (* read till first nl *) |
||
			IF R.eot THEN EXIT END; |
			IF R.eot THEN EXIT END; |
||
			IF ch = 0DX THEN |
			IF ch = 0DX THEN |
||
				end |
				end <nowiki>:</nowiki>= Texts.Pos(R)-1; |
||
				Texts.Read(R, ch); |
				Texts.Read(R, ch); |
||
				WHILE ~R.eot & (ch = " ") OR (ch = tab) DO Texts.Read(R, ch) END; |
				WHILE ~R.eot & (ch = " ") OR (ch = tab) DO Texts.Read(R, ch) END; |
||
Line 86: | Line 93: | ||
			END |
			END |
||
		END; |
		END; |
||
		IF firstcol = 1 THEN (* red *) typ |
		IF firstcol = 1 THEN (* red *) typ <nowiki>:</nowiki>= title |
||
		ELSIF MatchFont(firstfnt.name, "12b") THEN typ |
		ELSIF MatchFont(firstfnt.name, "12b") THEN typ <nowiki>:</nowiki>= heading |
||
		ELSIF MatchFont(firstfnt.name, "10.") THEN typ |
		ELSIF MatchFont(firstfnt.name, "10.") THEN typ <nowiki>:</nowiki>= pre; beg <nowiki>:</nowiki>= lastnl; |
||
		ELSIF firstch = "*" THEN typ |
		ELSIF firstch = "*" THEN typ <nowiki>:</nowiki>= bullet |
||
		ELSIF firstch = "-" THEN typ |
		ELSIF firstch = "-" THEN typ <nowiki>:</nowiki>= line |
||
		ELSE typ |
		ELSE typ <nowiki>:</nowiki>= para |
||
		END |
		END |
||
	END |
	END |
||
END GetPara; |
END GetPara; |
||
PROCEDURE WriteStretch(T |
PROCEDURE WriteStretch(T<nowiki>:</nowiki> Texts.Text; beg, end<nowiki>:</nowiki> LONGINT); |
||
VAR R |
VAR R<nowiki>:</nowiki> Texts.Reader; ch<nowiki>:</nowiki> CHAR; lastlib<nowiki>:</nowiki> Objects.Library; |
||
BEGIN |
BEGIN |
||
	IF end > beg THEN |
	IF end > beg THEN |
||
		Texts.OpenReader(R, T, beg); |
		Texts.OpenReader(R, T, beg); |
||
		Texts.Read(R, ch); lastlib |
		Texts.Read(R, ch); lastlib <nowiki>:</nowiki>= R.lib; |
||
		WHILE beg < end DO |
		WHILE beg < end DO |
||
			IF R.lib # lastlib THEN |
			IF R.lib # lastlib THEN |
||
				IF MatchFont(R.lib.name, "12i") THEN |
				IF MatchFont(R.lib.name, "12i") THEN |
||
					IF ~italic THEN S("<i>"); italic |
					IF ~italic THEN S("<i>"); italic <nowiki>:</nowiki>= TRUE END |
||
				ELSE |
				ELSE |
||
					IF italic THEN S("</i>"); italic |
					IF italic THEN S("</i>"); italic <nowiki>:</nowiki>= FALSE END |
||
				END; |
				END; |
||
				lastlib |
				lastlib <nowiki>:</nowiki>= R.lib |
||
			END; |
			END; |
||
			IF ch = |
<span style="color: #FF0000">			IF ch = 085X THEN S("&uuml;") |
||
			ELSIF ch = |
			ELSIF ch = 082X THEN S("&Uuml;") |
||
			ELSIF ch = |
			ELSIF ch = 08FX THEN S("&ugrave;") |
||
			ELSIF ch = |
			ELSIF ch = 083X THEN S("&auml;") |
||
			ELSIF ch = |
			ELSIF ch = 080X THEN S("&Auml;") |
||
			ELSIF ch = |
			ELSIF ch = 094X THEN S("&aacute;") |
||
			ELSIF ch = |
			ELSIF ch = 08BX THEN S("&agrave;") |
||
			ELSIF ch = |
			ELSIF ch = 091X THEN S("&euml;") |
||
			ELSIF ch = |
			ELSIF ch = 090X THEN S("&eacute;") |
||
			ELSIF ch = |
			ELSIF ch = 08CX THEN S("&egrave;") |
||
			ELSIF ch = |
			ELSIF ch = 084X THEN S("&ouml;") |
||
			ELSIF ch = |
			ELSIF ch = 081X THEN S("&Ouml;") |
||
			ELSIF ch = |
			ELSIF ch = 08EX THEN S("&ograve;") |
||
			ELSIF ch = |
			ELSIF ch = 092X THEN S("&iuml;") |
||
			ELSIF ch = |
			ELSIF ch = 08DX THEN S("&igrave;") |
||
			 |
			ELS</span>IF ch = 0DX THEN C(" "); C(sep) |
||
			ELSIF ch = tab THEN S("&nbsp; &nbsp; &nbsp;") |
			ELSIF ch = tab THEN S("&nbsp; &nbsp; &nbsp;") |
||
			ELSIF (ch >= " ") OR (ch = "-") THEN |
			ELSIF (ch >= " ") OR (ch = "-") THEN |
||
Line 137: | Line 144: | ||
END WriteStretch; |
END WriteStretch; |
||
PROCEDURE WritePara(T |
PROCEDURE WritePara(T<nowiki>:</nowiki> Texts.Text; beg, end<nowiki>:</nowiki> LONGINT); |
||
VAR R |
VAR R<nowiki>:</nowiki> Texts.Reader; ch<nowiki>:</nowiki> CHAR; col<nowiki>:</nowiki> INTEGER; |
||
	pos, lstart |
	pos, lstart<nowiki>:</nowiki> LONGINT; anchor<nowiki>:</nowiki> ARRAY 512 OF CHAR; apos<nowiki>:</nowiki> INTEGER; |
||
BEGIN col |
BEGIN col <nowiki>:</nowiki>= -1; pos <nowiki>:</nowiki>= beg; anchor <nowiki>:</nowiki>= ""; |
||
	Texts.OpenReader(R, T, beg); |
	Texts.OpenReader(R, T, beg); |
||
	Texts.Read(R, ch); |
	Texts.Read(R, ch); |
||
	WHILE pos < end DO |
	WHILE pos < end DO |
||
		IF (R.col = 3) & (col # 3) THEN (* start link *) |
		IF (R.col = 3) & (col # 3) THEN (* start link *) |
||
			WriteStretch(T, beg, pos); beg |
			WriteStretch(T, beg, pos); beg <nowiki>:</nowiki>= pos |
||
		END; |
		END; |
||
		col |
		col <nowiki>:</nowiki>= R.col; |
||
		  |
|||
		IF (col = 3) & (ch = "{") THEN (* reading an anchor *) |
		IF (col = 3) & (ch = "{") THEN (* reading an anchor *) |
||
			lstart |
			lstart <nowiki>:</nowiki>= pos; |
||
			INC(pos); Texts.Read(R, ch); |
			INC(pos); Texts.Read(R, ch); |
||
			apos |
			apos <nowiki>:</nowiki>= 0; |
||
			WHILE ~R.eot & (apos < LEN(anchor)) & (ch # "}") DO |
			WHILE ~R.eot & (apos < LEN(anchor)) & (ch # "}") DO |
||
				anchor[apos] |
				anchor[apos] <nowiki>:</nowiki>= ch; INC(apos); |
||
				INC(pos); |
				INC(pos); |
||
				Texts.Read(R, ch) |
				Texts.Read(R, ch) |
||
			END; |
			END; |
||
			anchor[apos] |
			anchor[apos] <nowiki>:</nowiki>= 0X; |
||
			S("<a href="); C(22X); S(anchor); C(22X); C(">"); |
			S("<a href="); C(22X); S(anchor); C(22X); C(">"); |
||
			WriteStretch(T, beg, lstart); beg |
			WriteStretch(T, beg, lstart); beg <nowiki>:</nowiki>= pos+1; |
||
			S("</a>") |
			S("</a>") |
||
		ELSE INC(pos); Texts.Read(R, ch) |
		ELSE INC(pos); Texts.Read(R, ch) |
||
Line 168: | Line 175: | ||
END WritePara; |
END WritePara; |
||
PROCEDURE GetPrefix(T |
PROCEDURE GetPrefix(T<nowiki>:</nowiki> Texts.Text; VAR beg, end<nowiki>:</nowiki> LONGINT; VAR s<nowiki>:</nowiki> ARRAY OF CHAR); |
||
VAR R |
VAR R<nowiki>:</nowiki> Texts.Reader; old<nowiki>:</nowiki> LONGINT; ch<nowiki>:</nowiki> CHAR; i<nowiki>:</nowiki> INTEGER; |
||
BEGIN |
BEGIN |
||
	old |
	old <nowiki>:</nowiki>= beg; i <nowiki>:</nowiki>= 0; |
||
	Texts.OpenReader(R, T, beg); |
	Texts.OpenReader(R, T, beg); |
||
	Texts.Read(R, ch); |
	Texts.Read(R, ch); |
||
	WHILE ~R.eot & (ch # " |
	WHILE ~R.eot & (ch # "<nowiki>:</nowiki>") & (beg < end) DO |
||
		IF (ch > " ") & (i < LEN(s) - 1) THEN s[i] |
		IF (ch > " ") & (i < LEN(s) - 1) THEN s[i] <nowiki>:</nowiki>= ch; INC(i) END; |
||
		INC(beg); |
		INC(beg); |
||
		Texts.Read(R, ch) |
		Texts.Read(R, ch) |
||
	END; |
	END; |
||
	IF ch = " |
	IF ch = "<nowiki>:</nowiki>" THEN s[i] <nowiki>:</nowiki>= 0X; INC(beg) |
||
	ELSE s[0] |
	ELSE s[0] <nowiki>:</nowiki>= 0X; beg <nowiki>:</nowiki>= old |
||
	END |
	END |
||
END GetPrefix; |
END GetPrefix; |
||
PROCEDURE ConvertText(T |
PROCEDURE ConvertText(T<nowiki>:</nowiki> Texts.Text; start<nowiki>:</nowiki> LONGINT; VAR filename<nowiki>:</nowiki> ARRAY OF CHAR); |
||
VAR R |
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">	PROCEDURE StartBody; |
<span style="color: #0000FF">	PROCEDURE StartBody; |
||
Line 195: | Line 202: | ||
			S("<body>"); L |
			S("<body>"); L |
||
		END; |
		END; |
||
		body |
		body <nowiki>:</nowiki>= TRUE |
||
	END StartBody; |
	END StartBody; |
||
</span> |
</span> |
||
BEGIN |
BEGIN |
||
	italic |
	italic <nowiki>:</nowiki>= FALSE; <span style="color: #0000FF">body <nowiki>:</nowiki>= FALSE; |
||
</span>	Texts.OpenReader(R, T, start); |
</span>	Texts.OpenReader(R, T, start); |
||
	GetPara(T, R, beg, end, typ); |
	GetPara(T, R, beg, end, typ); |
||
	IF DocHeader THEN |
	<span style="color: #FF0000">(* IF DocHeader THEN |
||
		S("<!DOCTYPE HTML PUBLIC "); C(22X); S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X); S(">"); L |
		S("<!DOCTYPE HTML PUBLIC "); C(22X); S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X); S(">"); L |
||
	END; *)</span> |
|||
	<span style="color: #009A00">IF DTD = "HTML401Strict" THEN |
|||
		S("<!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01//EN"); C(22X); |
|||
		S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/strict.dtd"); S(">"); L |
|||
	ELSIF DTD = "HTML401Trans" THEN |
|||
		S("<!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01 Transitional//EN"); C(22X); |
|||
		S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/loose.dtd"); S(">"); L |
|||
	ELSIF DTD = "HTML401Frameset" THEN |
|||
		S("<!DOCTYPE HTML PUBLIC "); C(22X);S("-//W3C//DTD HTML 4.01 Frameset//EN"); C(22X); |
|||
		S(" "); C(22X); S("http<nowiki>:</nowiki>//www.w3.org/TR/html4/frameset.dtd"); S(">"); L |
|||
	ELSIF DTD = "html" THEN |
|||
		S("<!DOCTYPE html>"); L |
|||
	ELSE (* no DTD *)</span> |
|||
	END; |
	END; |
||
	S("<html>"); L; |
	<span style="color: #009A00">S("<html lang="); C(22X); S(lang); C(22X); S(">"); L;</span> |
||
	S("<head>"); L; |
	S("<head>"); L; |
||
	S("<title>"); |
	S("<title>"); |
||
Line 211: | Line 231: | ||
		GetPrefix(T, beg, end, filename); (* Skip that file name, discarding it *) |
		GetPrefix(T, beg, end, filename); (* Skip that file name, discarding it *) |
||
		WritePara(T, beg, end); |
		WritePara(T, beg, end); |
||
<span style="color: #0000FF">		beg |
<span style="color: #0000FF">		beg <nowiki>:</nowiki>= end (* title paragraph already written *) |
||
</span>	ELSE |
</span>	ELSE |
||
		S("Untitled") |
		S("Untitled") |
||
	END; |
	END; |
||
	S("</title>"); L; |
	S("</title>"); L; |
||
	S('<meta http-equiv="Content-Type" content="text/html; charset= |
	S('<meta http-equiv="Content-Type" content="text/html; charset=');S(CharEncoding);S('">'); L; |
||
	WHILE ~R.eot DO |
	WHILE ~R.eot DO |
||
<span style="color: #0000FF">		IF ~body & (typ # title) THEN StartBody END; (* first non-title paragraph starts body *) |
<span style="color: #0000FF">		IF ~body & (typ # title) THEN StartBody END; (* first non-title paragraph starts body *) |
||
</span>		GetPara(T, R, nbeg, nend, ntyp); |
</span>		GetPara(T, R, nbeg, nend, ntyp); |
||
<span style="color: #0000FF">		IF body & (ntyp = title) THEN ntyp |
<span style="color: #0000FF">		IF body & (ntyp = title) THEN ntyp <nowiki>:</nowiki>= para END; (* treat a title paragraph in body like normal *) |
||
</span>		IF typ = bullet THEN S("<li>"); INC(beg) |
</span>		IF typ = bullet THEN S("<li>"); INC(beg) |
||
		ELSIF typ = heading THEN S("<h2>") |
		ELSIF typ = heading THEN S("<h2>") |
||
Line 233: | Line 253: | ||
		IF typ = heading THEN S("</h2>") END; |
		IF typ = heading THEN S("</h2>") END; |
||
		<span style="color: #0000FF">IF beg # end THEN</span> L <span style="color: #0000FF">END</span>; |
		<span style="color: #0000FF">IF beg # end THEN</span> L <span style="color: #0000FF">END</span>; |
||
		 |
|||
		(* List *) |
		(* List *) |
||
		IF (ntyp = bullet) & (typ # bullet) THEN (* open list *) |
		IF (ntyp = bullet) & (typ # bullet) THEN (* open list *) |
||
Line 240: | Line 260: | ||
<span style="color: #FF0000">			</span>S("</ul>"); L<span style="color: #FF0000"> |
<span style="color: #FF0000">			</span>S("</ul>"); L<span style="color: #FF0000"> |
||
</span>		END; |
</span>		END; |
||
		 |
|||
		(* Pre-formatted text *) |
		(* Pre-formatted text *) |
||
		IF (ntyp = pre) & (typ # pre) THEN (* start pre-formatted text *) |
		IF (ntyp = pre) & (typ # pre) THEN (* start pre-formatted text *) |
||
<span style="color: # |
<span style="color: #FF0000">			IF ~body THEN StartBody END; |
||
</span>			S("<pre>") |
</span>			S("<pre>") |
||
		ELSIF (ntyp # pre) & (typ = pre) THEN |
		ELSIF (ntyp # pre) & (typ = pre) THEN |
||
			S("</pre>"); L |
			S("</pre>"); L |
||
		END; |
		END; |
||
		 |
|||
		(* Separate 2 consecutive "normal" paragraphs with a paragraph break, except two preformatteds *) |
		(* Separate 2 consecutive "normal" paragraphs with a paragraph break, except two preformatteds *) |
||
		IF (ntyp = para) & (typ = para) THEN S("<p>"); L END; |
		IF (ntyp = para) & (typ = para) THEN S("<p>"); L END; |
||
		 |
|||
		end |
		end <nowiki>:</nowiki>= nend; beg <nowiki>:</nowiki>= nbeg; typ <nowiki>:</nowiki>= ntyp |
||
	END; |
	END; |
||
	<span style="color: #0000FF">IF ~body & (typ # title) THEN StartBody END;</span> |
	<span style="color: #0000FF">IF ~body & (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 |
VAR S<nowiki>:</nowiki> Texts.Scanner; T, t<nowiki>:</nowiki> Texts.Text; time, beg, end<nowiki>:</nowiki> LONGINT; |
||
	filename |
	filename<nowiki>:</nowiki> ARRAY 64 OF CHAR; f<nowiki>:</nowiki> Files.File; |
||
BEGIN |
BEGIN |
||
	sep |
	sep <nowiki>:</nowiki>= 0DX; |
||
	beg |
	beg <nowiki>:</nowiki>= 0; (* Process from the beginning of the text. Modified if "@" used *) |
||
	Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); |
	Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); |
||
	Texts.Scan(S); T |
	Texts.Scan(S); T <nowiki>:</nowiki>= NIL; |
||
	IF (S.class = Texts.Char) & (S.c = "*") THEN |
	IF (S.class = Texts.Char) & (S.c = "*") THEN |
||
		T |
		T <nowiki>:</nowiki>= Oberon.MarkedText() |
||
	ELSIF (S.class = Texts.Char) & (S.c = "^") THEN |
	ELSIF (S.class = Texts.Char) & (S.c = "^") THEN |
||
		Oberon.GetSelection(T, beg, end, time); |
		Oberon.GetSelection(T, beg, end, time); |
||
Line 284: | Line 304: | ||
			IF (S.class = Texts.Name) THEN |
			IF (S.class = Texts.Name) THEN |
||
				NEW(T); Texts.Open(T, S.s); |
				NEW(T); Texts.Open(T, S.s); |
||
				IF T.len = 0 THEN T |
				IF T.len = 0 THEN T <nowiki>:</nowiki>= NIL END |
||
			END |
			END |
||
		ELSE T |
		ELSE T <nowiki>:</nowiki>= NIL |
||
		END |
		END |
||
	ELSIF (S.class = Texts.Char) & (S.c = "@") THEN |
	ELSIF (S.class = Texts.Char) & (S.c = "@") THEN |
||
		Oberon.GetSelection(T, beg, end, time); |
		Oberon.GetSelection(T, beg, end, time); |
||
		IF time < 0 THEN T |
		IF time < 0 THEN T <nowiki>:</nowiki>= NIL END |
||
	END; |
	END; |
||
	IF T # NIL THEN |
	IF T # NIL THEN |
||
		f |
		f <nowiki>:</nowiki>= Files.New("Temp.HTML.tmp"); |
||
		Files.Set(out, f, 0); |
		Files.Set(out, f, 0); |
||
		ConvertText(T, beg, filename); |
		ConvertText(T, beg, filename); |
||
Line 303: | Line 323: | ||
PROCEDURE Compile*; |
PROCEDURE Compile*; |
||
	VAR S |
	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; |
||
	PROCEDURE CompileT |
	PROCEDURE CompileT; |
||
		VAR R |
		VAR R<nowiki>:</nowiki> Texts.Reader; beg, end<nowiki>:</nowiki> LONGINT; typ<nowiki>:</nowiki> SHORTINT; |
||
				res, i |
				res, i<nowiki>:</nowiki> INTEGER; bak<nowiki>:</nowiki> ARRAY 64 OF CHAR; |
||
	BEGIN |
	BEGIN |
||
		IF T.len > 0 THEN |
		IF T.len > 0 THEN |
||
Line 320: | Line 340: | ||
				Out.String(filename); |
				Out.String(filename); |
||
			(* Rename the file 'fileName.Bak' *) |
			(* Rename the file 'fileName.Bak' *) |
||
				i |
				i <nowiki>:</nowiki>= 0; |
||
				WHILE filename[i] # 0X DO bak[i] |
				WHILE filename[i] # 0X DO bak[i] <nowiki>:</nowiki>= filename[i]; INC(i) END; |
||
				bak[i] |
				bak[i] <nowiki>:</nowiki>= "."; bak[i+1] <nowiki>:</nowiki>= "B"; bak[i+2] <nowiki>:</nowiki>= "a"; bak[i+3] <nowiki>:</nowiki>= "k"; bak[i+4] <nowiki>:</nowiki>= 0X; |
||
				Files.Rename(filename, bak, res); |
				Files.Rename(filename, bak, res); |
||
			(* *) |
			(* *) |
||
				f |
				f <nowiki>:</nowiki>= Files.New(filename); |
||
				Files.Set(out, f, 0); |
				Files.Set(out, f, 0); |
||
				ConvertText(T, 0, filename); |
				ConvertText(T, 0, filename); |
||
Line 335: | Line 355: | ||
		Out.Ln |
		Out.Ln |
||
	END CompileT; |
	END CompileT; |
||
	 |
|||
BEGIN |
BEGIN |
||
	sep |
	sep <nowiki>:</nowiki>= 0AX; |
||
	Out.String("HTML.Compile"); Out.Ln; |
	Out.String("HTML.Compile"); Out.Ln; |
||
	Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); |
	Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); |
||
	Texts.Scan(S); |
	Texts.Scan(S); |
||
	IF (S.class = Texts.Char) & (S.c = "*") THEN |
	IF (S.class = Texts.Char) & (S.c = "*") THEN |
||
		T |
		T <nowiki>:</nowiki>= Oberon.MarkedText(); |
||
		IF T # NIL THEN |
		IF T # NIL THEN |
||
			CompileT() |
			CompileT() |
||
		END |
		END |
||
	ELSE |
	ELSE |
||
		end |
		end <nowiki>:</nowiki>= MAX(LONGINT) - 100; |
||
		IF (S.class = Texts.Char) & (S.c = "^") THEN |
		IF (S.class = Texts.Char) & (S.c = "^") THEN |
||
			Oberon.GetSelection(T, beg, end, time); |
			Oberon.GetSelection(T, beg, end, time); |