Class: Kramdown::Element

Inherits:
Object show all
Defined in:
lib/kramdown-rfc2629.rb

Constant Summary collapse

STUDLY_ATTR =

occasionally regenerate the studly attribute name list via script in data/studly.rb

%w(
asciiAbbrev asciiFullname asciiInitials asciiName asciiSurname
asciiValue blankLines derivedAnchor derivedContent derivedCounter
derivedLink displayFormat docName expiresDate hangIndent hangText
indexInclude iprExtract keepWithNext keepWithPrevious originalSrc
prepTime quoteTitle quotedFrom removeInRFC sectionFormat seriesNo
showOnFrontPage slugifiedName sortRefs submissionType symRefs tocDepth
tocInclude
)
STUDLY_ATTR_MAP =
TRUTHY =
Hash.new {|h, k| k}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attrmangle(k) ⇒ Object

explicit or automatic studlification note that explicit (including trailing “_”) opts out of automatic



319
320
321
322
323
# File 'lib/kramdown-rfc2629.rb', line 319

def self.attrmangle(k)
  if (d = k.gsub(/_(.|$)/) { $1.upcase }) != k or d = STUDLY_ATTR_MAP[k]
    d
  end
end

Instance Method Details

#rfc2629_fix(opts) ⇒ Object



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/kramdown-rfc2629.rb', line 325

def rfc2629_fix(opts)
  if a = attr
    if anchor = a.delete('id')
      a['anchor'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
    end
    if anchor = a.delete('href')
      a['target'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
    end
    if lang = a.delete('lang-')
      a['xml:lang'] = lang
    end
    if av = a.delete('noabbrev')      # pseudo attribute -> opts
      opts = opts.merge(noabbrev: TRUTHY[av]) # updated copy
    end
    attr.keys.each do |k|
      if d = self.class.attrmangle(k)
        a[d] = a.delete(k)
      end
    end
  end
  opts
end