Class: Pubid::W3c::Renderer

Inherits:
Renderers::Base show all
Defined in:
lib/pubid/w3c/renderer.rb

Overview

Human-readable renderer for W3C identifiers.

Produces strings like:

"W3C WD-charmod-19991129"
"W3C NOTE-xml-names"
"W3C 2dcontext"

Registered as the :human format in the W3C format registry and invoked via render(format: :human). When id.with_publisher == false the leading "W3C " publisher token is dropped.

Constant Summary collapse

PUBLISHER =
"W3C"

Constants inherited from Renderers::Base

Renderers::Base::SEMANTIC_SPLIT, Renderers::Base::TYPED_STAGE_CSS

Instance Method Summary collapse

Methods inherited from Renderers::Base

#initialize, render

Constructor Details

This class inherits a constructor from Pubid::Renderers::Base

Instance Method Details

#render(context: nil, **opts) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/pubid/w3c/renderer.rb', line 18

def render(context: nil, **opts)
  id = @id
  body = +""
  body << "#{id.type_prefix}-" if id.type_prefix
  body << id.code.to_s
  body << "-#{id.date}" if id.date

  with_publisher?(id) ? "#{PUBLISHER} #{body}" : body
end