MeridianMERIDIAN

HTML Content

container.object.htmlsince finetype v0.5.1

HTML (HyperText Markup Language) content stored as VARCHAR. Detected by the presence of HTML tags (<p>, <div>, <a href=, <br>, <img>, etc.). Unlike XML, HTML5 allows unclosed tags, unquoted attributes, optional closing tags, and void elements. Common in CMS exports, email templates, web scraping data, and rich text fields.

Worked samples

DuckDB 1.5.5 · finetype 0.6.64

ValueAs VARCHARtag_counttext_content
<p>Hello world</p>Hello world1Hello world
<div class="test"><a href="url">link</a></div>link2link
<br><img src="photo.jpg">2
<h1>Title</h1><p>Content here.</p>TitleContent here.2TitleContent here.
<ul><li>Item 1</li><li>Item 2</li></ul>Item 1Item 23Item 1Item 2
<table><tr><td>Cell</td></tr></table>Cell3Cell

Shape

Length at least 3 characters.

Pattern
^.*<(p|div|span|a|br|img|h[1-6]|ul|ol|li|table|tr|td|th|strong|em|b|i|form|input|button|select|textarea|header|footer|nav|section|article|main|aside|figure|figcaption|blockquote|pre|code|script|style|link|meta|head|body|html)[\s>/ ].*$
ValueLengthShape
<p>Hello world</p>18matches
<div class="test"><a href="url">link</a></div>46matches
<br><img src="photo.jpg">25matches
<h1>Title</h1><p>Content here.</p>34matches
<ul><li>Item 1</li><li>Item 2</li></ul>39matches
<table><tr><td>Cell</td></tr></table>37matches
p>Hello world</p>17rejected: first character dropped

Told apart

1 of the 6 other object types accept every one of these samples on shape alone.

Detection relies on recognizing common HTML tag names to distinguish from XML (which requires well-formedness).

Background

Origin

Tim Berners-Lee specified HTML and wrote the browser and server software in late 1990, according to Wikipedia's history of the language.[1] The first publicly available description of HTML was a document called "HTML Tags", first mentioned on the Internet by Tim Berners-Lee in late 1991.[1] The "HTML Tags" document describes 18 elements.[1] Except for the hyperlink tag, the elements in "HTML Tags" were strongly influenced by CERN SGML, an in-house SGML-based documentation format at CERN.[1]

RFC 1866, Hypertext Markup Language - 2.0, was published in November 1995.[2] Wikipedia describes HTML 2.0 as the first HTML specification intended to be treated as a standard against which future implementations should be based.[1] Since 1996, the HTML specifications have been maintained by the World Wide Web Consortium (W3C), with input from commercial software vendors.[1] Development of HTML5 began in 2004 in the Web Hypertext Application Technology Working Group (WHATWG).[1] HTML5 was published as a W3C Recommendation on 28 October 2014.[1] On 28 May 2019, the W3C announced that WHATWG would be the sole publisher of the HTML and DOM standards.[1]

HTML5 abandoned any attempt to be an SGML application and explicitly defined its own "html" serialisation, alongside an XML-based XHTML5 serialisation.[1]

Use

The HTML Standard defines a set of void elements: area, base, br, col, embed, hr, img, input, link, meta, source, track and wbr.[3] The HTML Standard says void elements only have a start tag, and end tags must not be specified for them.[3] The HTML Standard allows certain tags to be omitted.[3] Under the HTML Standard, an li element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.[3] The HTML Standard permits an unquoted attribute value syntax, in which the value must not contain literal ASCII whitespace or quotation marks.[3] Treat an HTML column as HTML in its own right, and do not expect an XML tool to read it. (Meridian's view)

The HTML Standard classes script and style as raw text elements.[3] Check for script and style elements before trusting text produced by stripping tags. (Meridian's view)

Python's html.unescape converts named and numeric character references such as &gt;, &#62; and &#x3e; into the corresponding Unicode characters.[4] Python's html.parser module defines an HTMLParser class that can parse invalid markup.[5] When you need the readable text of an HTML field, prefer a real HTML parser over a pattern, and decode character references afterwards. (Meridian's view)

Where you'll meet it

The official Hacker News API documents the text field of stories, comments and polls as HTML.[6] The official Hacker News API documents a user's optional self-description, the about field, as HTML.[6]

Detection notes

New in v0.5.1. HTML is NOT well-formed XML: HTML5 allows unclosed tags (<br>, <img>), unquoted attributes, optional closing. Transform strips all HTML tags to extract plain text content. Detection relies on recognizing common HTML tag names to distinguish from XML (which requires well-formedness). Common in CMS exports (Shopify, HubSpot), email templates, and web scraping datasets.

Use it

CLI · DuckDB
$ finetype infer -i "<p>Hello world</p>" --mode column
→ container.object.html

SELECT ft_infer('<p>Hello world</p>');
-- → 'container.object.html'
Cast expression
REGEXP_REPLACE({col}, '<[^>]+>', '', 'g')

Schema

https://meridian.online/schemas/container.object.html · Frictionless type string

finetype taxonomy container.object.html -o json-schema

Aliases

html_contenthtml_fragment

Type Registry