links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Last updated at 8:34 am UTC on 16 September 2017
 HtmlToken printHierarchy '
 ProtoObject #()
	Object #()
		HtmlToken #(''source'')
			HtmlComment #()
			HtmlTag #(''isNegated'' ''name'' ''attribs'')
			HtmlText #(''text'')'

Method to create a HtmlElement

	"return an empty entity corresponding to this tag"
	| eClass |
	eClass := self class entityClasses at: name ifAbsent: [ ^nil ].
	^eClass forTag: self 

This method #entityFor uses the class method #entityClasses to get the mapping from tag to HtmlEntity subclass.

	"a Dictionary mapping tag names into the correct entity class"
	"EntityClasses := nil"

	EntityClasses isNil ifFalse: [ ^EntityClasses ].

	EntityClasses := Dictionary new.

		frameset	HtmlFrame
		frame	HtmlFrame

		title		HtmlTitle
		style	HtmlStyle
		meta	HtmlMeta

		p		HtmlParagraph
		form	HtmlForm
		blockquote	HtmlBlockQuote

		input	HtmlInput
		textarea	HtmlTextArea
		select	HtmlSelect
		optgroup	HtmlOptionGroup
		option		HtmlOption

		img		HtmlImage
		embed	HtmlEmbedded
		noembed	HtmlNoEmbed
		a		HtmlAnchor
		br		HtmlBreak

		map	HtmlMap
		area	HtmlArea

		li		HtmlListItem
		dd		HtmlDefinitionDefinition
		dt		HtmlDefinitionTerm

		ol		HtmlOrderedList
		ul		HtmlUnorderedList
		dl		HtmlDefinitionList

		h1		HtmlHeader
		h2		HtmlHeader
		h3		HtmlHeader
		h4		HtmlHeader
		h5		HtmlHeader
		h6		HtmlHeader

		hr		HtmlHorizontalRule

		strong	HtmlBoldEntity
		b		HtmlBoldEntity

		em		HtmlItalicsEntity
		i		HtmlItalicsEntity
		dfn 	HtmlItalicsEntity

		u		HtmlUnderlineEntity 

		tt		HtmlFixedWidthEntity
		kbd		HtmlFixedWidthEntity		

		strike	HtmlStrikeEntity

		big		HtmlBiggerFontEntity
		small	HtmlSmallerFontEntity

		sub		HtmlSubscript
		sup		HtmlSuperscript

		font	HtmlFontEntity

		pre		HtmlPreformattedRegion

		table	HtmlTable
		tr		HtmlTableRow
		td		HtmlTableDataItem 
		th		HtmlTableHeader
		) pairsDo: [ 
			:tagName :className |
			EntityClasses at: tagName asString put: (Smalltalk at: className) ].


HtmlDocument, HtmlHead and HtmlBody are treated separately, see parseTokens: method of HtmlParser.