Class: Nokogiri::HTML4::ElementDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/nokogiri/html4/element_description.rb,
lib/nokogiri/html4/element_description_defaults.rb,
ext/nokogiri/html4_element_description.c

Overview

Since:

  • v1.12.0

Defined Under Namespace

Classes: Desc

Constant Summary collapse

DefaultDescriptions =

This is filled in down below.

Since:

  • v1.12.0

Hash.new()
FONTSTYLE =

Attributes defined and categorized

Since:

  • v1.12.0

["tt", "i", "b", "u", "s", "strike", "big", "small"]
PHRASE =

Since:

  • v1.12.0

['em', 'strong', 'dfn', 'code', 'samp',
'kbd', 'var', 'cite', 'abbr', 'acronym']
SPECIAL =

Since:

  • v1.12.0

['a', 'img', 'applet', 'embed', 'object', 'font','basefont',
'br', 'script', 'map', 'q', 'sub', 'sup', 'span', 'bdo',
'iframe']
PCDATA =

Since:

  • v1.12.0

[]
HEADING =

Since:

  • v1.12.0

['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
LIST =

Since:

  • v1.12.0

['ul', 'ol', 'dir', 'menu']
FORMCTRL =

Since:

  • v1.12.0

['input', 'select', 'textarea', 'label', 'button']
BLOCK =

Since:

  • v1.12.0

[HEADING, LIST, 'pre', 'p', 'dl', 'div', 'center', 'noscript',
'noframes', 'blockquote', 'form', 'isindex', 'hr', 'table',
'fieldset', 'address']
INLINE =

Since:

  • v1.12.0

[PCDATA, FONTSTYLE, PHRASE, SPECIAL, FORMCTRL]
FLOW =

Since:

  • v1.12.0

[BLOCK, INLINE]
MODIFIER =

Since:

  • v1.12.0

[]
EMPTY =

Since:

  • v1.12.0

[]
HTML_FLOW =

Since:

  • v1.12.0

FLOW
HTML_INLINE =

Since:

  • v1.12.0

INLINE
HTML_PCDATA =

Since:

  • v1.12.0

PCDATA
HTML_CDATA =

Since:

  • v1.12.0

HTML_PCDATA
COREATTRS =

Since:

  • v1.12.0

['id', 'class', 'style', 'title']
I18N =

Since:

  • v1.12.0

['lang', 'dir']
EVENTS =

Since:

  • v1.12.0

['onclick', 'ondblclick', 'onmousedown', 'onmouseup',
'onmouseover', 'onmouseout', 'onkeypress', 'onkeydown',
'onkeyup']
ATTRS =

Since:

  • v1.12.0

[COREATTRS, I18N,EVENTS]
CELLHALIGN =

Since:

  • v1.12.0

['align', 'char', 'charoff']
CELLVALIGN =

Since:

  • v1.12.0

['valign']
HTML_ATTRS =

Since:

  • v1.12.0

ATTRS
CORE_I18N_ATTRS =

Since:

  • v1.12.0

[COREATTRS, I18N]
CORE_ATTRS =

Since:

  • v1.12.0

COREATTRS
I18N_ATTRS =

Since:

  • v1.12.0

I18N
A_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'charset', 'type', 'name',
'href', 'hreflang', 'rel', 'rev', 'accesskey', 'shape',
'coords', 'tabindex', 'onfocus', 'onblur']
TARGET_ATTR =

Since:

  • v1.12.0

['target']
ROWS_COLS_ATTR =

Since:

  • v1.12.0

['rows', 'cols']
ALT_ATTR =

Since:

  • v1.12.0

['alt']
SRC_ALT_ATTRS =

Since:

  • v1.12.0

['src', 'alt']
HREF_ATTRS =

Since:

  • v1.12.0

['href']
CLEAR_ATTRS =

Since:

  • v1.12.0

['clear']
INLINE_P =

Since:

  • v1.12.0

[INLINE, 'p']
FLOW_PARAM =

Since:

  • v1.12.0

[FLOW, 'param']
APPLET_ATTRS =

Since:

  • v1.12.0

[COREATTRS , 'codebase',
'archive', 'alt', 'name', 'height', 'width', 'align',
'hspace', 'vspace']
AREA_ATTRS =

Since:

  • v1.12.0

['shape', 'coords', 'href', 'nohref',
'tabindex', 'accesskey', 'onfocus', 'onblur']
BASEFONT_ATTRS =

Since:

  • v1.12.0

['id', 'size', 'color', 'face']
QUOTE_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'cite']
BODY_CONTENTS =

Since:

  • v1.12.0

[FLOW, 'ins', 'del']
BODY_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'onload', 'onunload']
BODY_DEPR =

Since:

  • v1.12.0

['background', 'bgcolor', 'text',
'link', 'vlink', 'alink']
BUTTON_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'name', 'value', 'type',
'disabled', 'tabindex', 'accesskey', 'onfocus', 'onblur']
COL_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'span', 'width', CELLHALIGN, CELLVALIGN]
COL_ELT =

Since:

  • v1.12.0

['col']
EDIT_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'datetime', 'cite']
COMPACT_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'compact']
DL_CONTENTS =

Since:

  • v1.12.0

['dt', 'dd']
COMPACT_ATTR =

Since:

  • v1.12.0

['compact']
LABEL_ATTR =

Since:

  • v1.12.0

['label']
FIELDSET_CONTENTS =

Since:

  • v1.12.0

[FLOW, 'legend' ]
FONT_ATTRS =

Since:

  • v1.12.0

[COREATTRS, I18N, 'size', 'color', 'face' ]
FORM_CONTENTS =

Since:

  • v1.12.0

[HEADING, LIST, INLINE, 'pre', 'p', 'div', 'center',
'noscript', 'noframes', 'blockquote', 'isindex', 'hr',
'table', 'fieldset', 'address']
FORM_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'method', 'enctype', 'accept', 'name', 'onsubmit',
'onreset', 'accept-charset']
FRAME_ATTRS =

Since:

  • v1.12.0

[COREATTRS, 'longdesc', 'name', 'src', 'frameborder',
'marginwidth', 'marginheight', 'noresize', 'scrolling' ]
FRAMESET_ATTRS =

Since:

  • v1.12.0

[COREATTRS, 'rows', 'cols', 'onload', 'onunload']
FRAMESET_CONTENTS =

Since:

  • v1.12.0

['frameset', 'frame', 'noframes']
HEAD_ATTRS =

Since:

  • v1.12.0

[I18N, 'profile']
HEAD_CONTENTS =

Since:

  • v1.12.0

['title', 'isindex', 'base', 'script', 'style', 'meta',
'link', 'object']
HR_DEPR =

Since:

  • v1.12.0

['align', 'noshade', 'size', 'width']
VERSION_ATTR =

Since:

  • v1.12.0

['version']
HTML_CONTENT =

Since:

  • v1.12.0

['head', 'body', 'frameset']
IFRAME_ATTRS =

Since:

  • v1.12.0

[COREATTRS, 'longdesc', 'name', 'src', 'frameborder',
'marginwidth', 'marginheight', 'scrolling', 'align',
'height', 'width']
IMG_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'longdesc', 'name', 'height', 'width', 'usemap',
'ismap']
EMBED_ATTRS =

Since:

  • v1.12.0

[COREATTRS, 'align', 'alt', 'border', 'code', 'codebase',
'frameborder', 'height', 'hidden', 'hspace', 'name',
'palette', 'pluginspace', 'pluginurl', 'src', 'type',
'units', 'vspace', 'width']
INPUT_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'type', 'name', 'value', 'checked', 'disabled',
'readonly', 'size', 'maxlength', 'src', 'alt', 'usemap',
'ismap', 'tabindex', 'accesskey', 'onfocus', 'onblur',
'onselect', 'onchange', 'accept']
PROMPT_ATTRS =

Since:

  • v1.12.0

[COREATTRS, I18N, 'prompt']
LABEL_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'for', 'accesskey', 'onfocus', 'onblur']
LEGEND_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'accesskey']
ALIGN_ATTR =

Since:

  • v1.12.0

['align']
[ATTRS, 'charset', 'href', 'hreflang', 'type', 'rel', 'rev',
'media']
MAP_CONTENTS =

Since:

  • v1.12.0

[BLOCK, 'area']
NAME_ATTR =

Since:

  • v1.12.0

['name']
ACTION_ATTR =

Since:

  • v1.12.0

['action']
BLOCKLI_ELT =

Since:

  • v1.12.0

[BLOCK, 'li']
META_ATTRS =

Since:

  • v1.12.0

[I18N, 'http-equiv', 'name', 'scheme']
CONTENT_ATTR =

Since:

  • v1.12.0

['content']
TYPE_ATTR =

Since:

  • v1.12.0

['type']
NOFRAMES_CONTENT =

Since:

  • v1.12.0

['body', FLOW, MODIFIER]
OBJECT_CONTENTS =

Since:

  • v1.12.0

[FLOW, 'param']
OBJECT_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'declare', 'classid', 'codebase', 'data', 'type',
'codetype', 'archive', 'standby', 'height', 'width',
'usemap', 'name', 'tabindex']
OBJECT_DEPR =

Since:

  • v1.12.0

['align', 'border', 'hspace', 'vspace']
OL_ATTRS =

Since:

  • v1.12.0

['type', 'compact', 'start']
OPTION_ELT =

Since:

  • v1.12.0

['option']
OPTGROUP_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'disabled']
OPTION_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'disabled', 'label', 'selected', 'value']
PARAM_ATTRS =

Since:

  • v1.12.0

['id', 'value', 'valuetype', 'type']
WIDTH_ATTR =

Since:

  • v1.12.0

['width']
PRE_CONTENT =

Since:

  • v1.12.0

[PHRASE, 'tt', 'i', 'b', 'u', 's', 'strike', 'a', 'br',
'script', 'map', 'q', 'span', 'bdo', 'iframe']
SCRIPT_ATTRS =

Since:

  • v1.12.0

['charset', 'src', 'defer', 'event', 'for']
LANGUAGE_ATTR =

Since:

  • v1.12.0

['language']
SELECT_CONTENT =

Since:

  • v1.12.0

['optgroup', 'option']
SELECT_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'name', 'size', 'multiple', 'disabled', 'tabindex',
'onfocus', 'onblur', 'onchange']
STYLE_ATTRS =

Since:

  • v1.12.0

[I18N, 'media', 'title']
TABLE_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'summary', 'width', 'border', 'frame', 'rules',
'cellspacing', 'cellpadding', 'datapagesize']
TABLE_DEPR =

Since:

  • v1.12.0

['align', 'bgcolor']
TABLE_CONTENTS =

Since:

  • v1.12.0

['caption', 'col', 'colgroup', 'thead', 'tfoot', 'tbody',
'tr']
TR_ELT =

Since:

  • v1.12.0

['tr']
TALIGN_ATTRS =

Since:

  • v1.12.0

[ATTRS, CELLHALIGN, CELLVALIGN]
TH_TD_DEPR =

Since:

  • v1.12.0

['nowrap', 'bgcolor', 'width', 'height']
TH_TD_ATTR =

Since:

  • v1.12.0

[ATTRS, 'abbr', 'axis', 'headers', 'scope', 'rowspan',
'colspan', CELLHALIGN, CELLVALIGN]
TEXTAREA_ATTRS =

Since:

  • v1.12.0

[ATTRS, 'name', 'disabled', 'readonly', 'tabindex',
'accesskey', 'onfocus', 'onblur', 'onselect',
'onchange']
TR_CONTENTS =

Since:

  • v1.12.0

['th', 'td']
BGCOLOR_ATTR =

Since:

  • v1.12.0

['bgcolor']
LI_ELT =

Since:

  • v1.12.0

['li']
UL_DEPR =

Since:

  • v1.12.0

['type', 'compact']
DIR_ATTR =

Since:

  • v1.12.0

['dir']

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](tag_name) ⇒ Object

Get ElemementDescription for tag_name

Since:

  • v1.12.0



261
262
263
264
265
266
267
268
269
270
# File 'ext/nokogiri/html4_element_description.c', line 261

static VALUE
get_description(VALUE klass, VALUE tag_name)
{
  const htmlElemDesc *description = htmlTagLookup(
                                      (const xmlChar *)StringValueCStr(tag_name)
                                    );

  if (NULL == description) { return Qnil; }
  return Data_Wrap_Struct(klass, 0, 0, DISCARD_CONST_QUAL(void *, description));
}

Instance Method Details

#block?Boolean

Is this element a block element?

Returns:

  • (Boolean)

Since:

  • v1.12.0



7
8
9
# File 'lib/nokogiri/html4/element_description.rb', line 7

def block?
  !inline?
end

#default_sub_elementObject

The default sub element for this element

Since:

  • v1.12.0



89
90
91
92
# File 'ext/nokogiri/html4_element_description.c', line 89

def default_sub_element
  d = default_desc
  d ? d.defaultsubelt : nil
end

#deprecated?Boolean

Is this element deprecated?

Returns:

  • (Boolean)

Since:

  • v1.12.0



165
166
167
168
# File 'ext/nokogiri/html4_element_description.c', line 165

def deprecated?
  d = default_desc
  d ? d.depr : nil
end

#deprecated_attributesObject

A list of deprecated attributes for this element

Since:

  • v1.12.0



37
38
39
40
# File 'ext/nokogiri/html4_element_description.c', line 37

def deprecated_attributes
  d = default_desc
  d ? d.attrs_depr : []
end

#descriptionObject

The description for this element

Since:

  • v1.12.0



134
135
136
137
# File 'ext/nokogiri/html4_element_description.c', line 134

def description
  d = default_desc
  d ? d.desc : nil
end

#empty?Boolean

Is this an empty element?

Returns:

  • (Boolean)

Since:

  • v1.12.0



181
182
183
184
185
186
187
188
189
# File 'ext/nokogiri/html4_element_description.c', line 181

static VALUE
empty_eh(VALUE self)
{
  const htmlElemDesc *description;
  Data_Get_Struct(self, htmlElemDesc, description);

  if (description->empty) { return Qtrue; }
  return Qfalse;
}

#implied_end_tag?Boolean

Can the end tag be implied for this tag?

Returns:

  • (Boolean)

Since:

  • v1.12.0



213
214
215
216
# File 'ext/nokogiri/html4_element_description.c', line 213

def implied_end_tag?
  d = default_desc
  d ? d.endTag : nil
end

#implied_start_tag?Boolean

Can the start tag be implied for this tag?

Returns:

  • (Boolean)

Since:

  • v1.12.0



229
230
231
232
# File 'ext/nokogiri/html4_element_description.c', line 229

def implied_start_tag?
  d = default_desc
  d ? d.startTag : nil
end

#inline?Boolean

Is this element an inline element?

Returns:

  • (Boolean)

Since:

  • v1.12.0



149
150
151
152
153
154
155
156
157
# File 'ext/nokogiri/html4_element_description.c', line 149

static VALUE
inline_eh(VALUE self)
{
  const htmlElemDesc *description;
  Data_Get_Struct(self, htmlElemDesc, description);

  if (description->isinline) { return Qtrue; }
  return Qfalse;
}

#inspectObject

Inspection information

Since:

  • v1.12.0



19
20
21
# File 'lib/nokogiri/html4/element_description.rb', line 19

def inspect
  "#<#{self.class.name}: #{name} #{description}>"
end

#nameObject

Get the tag name for this ElemementDescription

Since:

  • v1.12.0



245
246
247
248
249
250
251
252
253
# File 'ext/nokogiri/html4_element_description.c', line 245

static VALUE
name(VALUE self)
{
  const htmlElemDesc *description;
  Data_Get_Struct(self, htmlElemDesc, description);

  if (NULL == description->name) { return Qnil; }
  return NOKOGIRI_STR_NEW2(description->name);
}

#optional_attributesObject

A list of optional attributes for this element

Since:

  • v1.12.0



63
64
65
66
# File 'ext/nokogiri/html4_element_description.c', line 63

def optional_attributes
  d = default_desc
  d ? d.attrs_opt : []
end

#required_attributesObject

A list of required attributes for this element

Since:

  • v1.12.0



11
12
13
14
# File 'ext/nokogiri/html4_element_description.c', line 11

def required_attributes
  d = default_desc
  d ? d.attrs_req : []
end

#save_end_tag?Boolean

Should the end tag be saved?

Returns:

  • (Boolean)

Since:

  • v1.12.0



197
198
199
200
# File 'ext/nokogiri/html4_element_description.c', line 197

def save_end_tag?
  d = default_desc
  d ? d.saveEndTag : nil
end

#sub_elementsObject

A list of allowed sub elements for this element.

Since:

  • v1.12.0



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'ext/nokogiri/html4_element_description.c', line 108

static VALUE
sub_elements(VALUE self)
{
  const htmlElemDesc *description;
  VALUE list;
  int i;

  Data_Get_Struct(self, htmlElemDesc, description);

  list = rb_ary_new();

  if (NULL == description->subelts) { return list; }

  for (i = 0; description->subelts[i]; i++) {
    rb_ary_push(list, NOKOGIRI_STR_NEW2(description->subelts[i]));
  }

  return list;
}

#to_sObject

Convert this description to a string

Since:

  • v1.12.0



13
14
15
# File 'lib/nokogiri/html4/element_description.rb', line 13

def to_s
  "#{name}: #{description}"
end