Squeak Class Documentation category index | class index  
 
HtmlFileStream
  category: System-Files
  superclass: CrLfFileStream
  subclasses:

The Class apes StandardFileStream, but converts the text to HTML before putting it out (primarily intended for printOut). It can be invoked with

((FileStream fileNamed: 'changes.html') asHtml) fileOutChanges

Use usual FileStream methods to put out text converted to
HTML fairly approximating that text (for best looks, use
method:, methodHeader:, methodBody:, for code);

verbatim: puts text out without conversion;

command: put out HTML items, such as <br>, supplying the brackets.

header: and trailer: put out an HTML wrapper (preamble and closing text)

nextPut does the actual conversion, nextPutAll: defers characters to nextPut.

The code is fairly dumb at present, doing a wooden straightforward conversion of the text without attempting to capture the style or fonts in which the original text was rendered. Tabs are handled awkwardly, using  , so that probably only leading strings are working right. Style sheets now permit us to do a much neater looking job if there is interest in improving the looks of things.

instance methods
  HTML
  command:

  fileIn/Out
  copyMethodChunkFrom:
copyPreamble:from:
nextChunk
skipSeparators

  read, write, position
  header
nextPut:
nextPutAll:
trailer
verbatim:

class methods
  class initialization
  initialize

  instance creation
  newFrom:

instance methods
  HTML top  
 

command:

Append HTML commands directly without translation. Caller should not include < or >. Note that font change info comes through here! 4/5/96 tk


  fileIn/Out top  
 

copyMethodChunkFrom:

Overridden to bolden the first line (presumably a method header)


 

copyPreamble:from:

Make method category preambles bold at category changes.


 

nextChunk

Answer the contents of the receiver, up to the next terminator character (!). Imbedded terminators are doubled. Undo and strip out all Html stuff in the stream and convert the characters back. 4/12/96 tk


 

skipSeparators

Bsides the normal spacers, also skip any <...>, html commands.
4/12/96 tk


  read, write, position top  
 

header

append the HTML header. Be sure to call trailer after you put out the data.
4/4/96 tk


 

nextPut:

Put a character on the file, but translate it first. 4/6/96 tk 1/1/98 acg


 

nextPutAll:

Write the whole string, translating as we go. 4/6/96 tk


 

trailer

append the HTML trailer. Call this just before file close.
4/4/96 tk


 

verbatim:

Put out the string without HTML conversion. 1/1/99 acg


class methods
  class initialization top  
 

initialize

HtmlFileStream initialize


  instance creation top  
 

newFrom:

Answer an HtmlFileStream that is 'like' aFileStream. As a side-effect, the surviving fileStream answered by this method replaces aFileStream on the finalization registry. 1/6/99 acg