ðWSyntax10.Scn.FntþÿÿÐûÐûInfoElemsAllocUSyntax10.Scn.FntböÿÿÿÐÝÀÔStampElemsAlloc4 Feb 980“"Title": TextElems "Author": Andreas Krumenacker "Abstract": TextElems is a part of the Oberon-Web-Browser. It enhances the module HTML with the ability of storing text-elements in HTML-comments and recreating these elements, when parsing an HTML-document. "Keywords": elements, text-elements, HTML "Version": no version "From": 15 Jan 98 "Until":  "Changes": no changes so far "Hints": no hints  þÿÿÐûÐûBalloonElemsAlloc#Syntax10.Scn.FntÔÔ"TextElems" TextElems is a part of the Oberon-Web-Browser. It enhances the module HTML with the ability of storing text-elements in HTML-comments and recreating these elements, when parsing an HTML-document. "Install" TextElems.Install This command is used to force the loading of module TextElems. When loaded, the module HTML is enhanced with the ability of storing text-elements in HTML-comments and recreating these elements, when parsing an HTML-document. =‰ÿÿÿ€8ÀÔFoldElemsNew#Syntax10.Scn.FntUU elemStart = ""; return = 0DX; lineFeed = 0AX;ÿÿÿÿ€8ÀÔÀÿÿÿ€8ÀÔ#Syntax10.Scn.Fnt ScanLine = ARRAY 96 OF CHAR;ÿÿÿÿ€8ÀÔšÿÿÿ€8ÀÔ#Syntax10.Scn.FntDD handleComment : HTML.CommentHandle; handleElem : HTML.ElemHandle;ÿÿÿÿ€8ÀÔFÐÿÿÿ€8ÀÔ#Syntax10.Scn.Fnt END NoNotify;ÿÿÿÿ€8ÀÔAÚùÿÿ€8ÀÔ5Syntax10.Scn.Fnt›ÿÿÿ€8ÀÔFoldElemsNew#Syntax10.Scn.FntÌÌ VAR i : INTEGER; buf : ScanLine; BEGIN COPY(str, buf); i := 0; WHILE buf[i] # 0X DO INC(i) END; buf[i] := return; buf[i + 1] := lineFeed; Files.WriteBytes(r, buf, i + 2) END WriteLine;ÿÿÿÿ€8ÀÔ)Zþÿÿ€8ÀÔ#Syntax10.Scn.Fnt„„ VAR read : Texts.Reader; buf : ScanLine; i : INTEGER; BEGIN Texts.OpenReader(read, t, 0); i := 0; Texts.Read(read, buf[i]); WHILE ~ read.eot DO WHILE ~ read.eot & (buf[i] # return) DO INC(i); Texts.Read(read, buf[i]) END; buf[i] := return; buf[i + 1] := lineFeed; Files.WriteBytes(r, buf, i + 2); i := 0; Texts.Read(read, buf[i]) END END WriteText;ÿÿÿÿ€8ÀÔOSyntax10i.Scn.FntÂò VAR t : Texts.Text; tBuf : Texts.Buffer; f1, f2 : Files.File; rdr : Files.Rider; pos : LONGINT; PROCEDURE WriteLine (str : ARRAY OF CHAR);  PROCEDURE WriteText (t : Texts.Text);  BEGIN pos := Files.Pos(r); handleElem(r, e); IF Files.Pos(r) = pos THEN (* elem has not been handled *) f1 := Files.New(""); f2 := Files.New(""); NEW(tBuf); Texts.OpenBuf(tBuf); Texts.Save(Texts.ElemBase(e), Texts.ElemPos(e), Texts.ElemPos(e) + 1, tBuf); t := TextFrames.Text(""); t.notify := NoNotify; Texts.Append(t, tBuf); Files.Set(rdr, f1, 0); Texts.Store(rdr, t); Texts.Delete(t, 0, t.len); AsciiCoder.Compress(f1, f2); AsciiCoder.Code(f2, t); WriteLine(elemStart); WriteText(t); WriteLine(elemEnd) END END StoreTextElem;ÿÿÿÿ€8ÀÔC ûÿÿ€8ÀÔÝSyntax10.Scn.Fnt¾|þÿÿ€8ÀÔFoldElemsNew#Syntax10.Scn.Fntbb VAR ch : CHAR; len : INTEGER; BEGIN len := 0; Texts.Read(r, ch); WHILE ~ r.eot & (ch = lineFeed) DO Texts.Read(r, ch) END; WHILE ~ r.eot & (ch # return) & (len < LEN(line) - 2) DO line[len] := ch; INC(len); Texts.Read(r, ch) END; IF ~ r.eot & (ch # return) THEN line[len] := ch; INC(len) END; line[len] := 0X END ReadLine;ÿÿÿÿ€8ÀÔZ VAR f1, f2 : Files.File; rdr : Files.Rider; r : Texts.Reader; line : ScanLine; beg : LONGINT; ok : BOOLEAN; PROCEDURE ReadLine (VAR r : Texts.Reader; VAR line : ScanLine);  BEGIN Texts.OpenReader(r, txt, 0); ReadLine(r, line); WHILE ~ r.eot & (line # elemStart) DO ReadLine(r, line) END; IF line = elemStart THEN f1 := Files.New(""); f2 := Files.New(""); beg := Texts.Pos(r); AsciiCoder.Decode(txt, beg, f1, ok); IF ok THEN AsciiCoder.Expand(f1, f2); Files.Set(rdr, f2, 0); Texts.Load(rdr, txt); Texts.OpenReader(r, txt, 0); Texts.ReadElem(r); IF r.elem # NIL THEN w.fnt := r.fnt; w.col := r.col; w.voff := r.voff; Texts.Delete(txt, 0, txt.len); Texts.WriteElem(w, r.elem) END END ELSE handleComment(w, txt) END END LoadTextElem;ÿÿÿÿ€8ÀÔ Syntax10b.Scn.Fnt€ÿÿÿ€8ÀÔCSyntax10.Scn.Fnt Syntax10i.Scn.Fnt$> BEGIN (* only used to force loading of module *) END Install;ÿÿÿÿ€8ÀÔSÿÿÿ€8ÀÔ#Syntax10.Scn.Fnt‹‹ handleElem := HTML.handleElem; HTML.handleElem := StoreTextElem; handleComment := HTML.handleComment; HTML.handleComment := LoadTextElemÿÿÿÿ€8ÀÔfMODULE TextElems;   IMPORT Files, Texts, TextFrames, AsciiCoder, HTML; CONST  TYPE  VAR  PROCEDURE NoNotify (t: Texts.Text; op: INTEGER; beg, end: LONGINT);  PROCEDURE StoreTextElem (VAR r : Files.Rider; e : Texts.Elem);  PROCEDURE LoadTextElem (VAR w : Texts.Writer; txt : Texts.Text);  PROCEDURE Install*;  BEGIN  END TextElems.