Class: HParser::Block::P

Inherits:
Object
  • Object
show all
Includes:
Collectable, Hatena, Html, Latex, Text
Defined in:
lib/hparser/block/p.rb,
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/hatena.rb

Overview

Normal line parser.

At hatena format, a line which is not parsed by any other parser is paragraph.

Constant Summary

Constants included from Html

Html::ESCAPE_TABLE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hatena

#to_hatena

Methods included from Text

#to_text

Methods included from Html

#escape, #to_html

Constructor Details

#initialize(content) ⇒ P

Returns a new instance of P.



46
47
48
# File 'lib/hparser/block/p.rb', line 46

def initialize(content)
  @content = content
end

Instance Attribute Details

#contentObject (readonly) Also known as: html_content, text_content, latex_content, hatena_content

Returns the value of attribute content.



38
39
40
# File 'lib/hparser/block/p.rb', line 38

def content
  @content
end

Class Method Details

.<=>(o) ⇒ Object



54
55
56
57
# File 'lib/hparser/block/p.rb', line 54

def self.<=>(o)
  # This parser should be last.
  o.class == P ? nil : 1
end

.parse(scanner, context, inlines) ⇒ Object



39
40
41
42
43
44
# File 'lib/hparser/block/p.rb', line 39

def self.parse(scanner,context,inlines)
  if scanner.scan(/./) then
    matched = scanner.matched
    P.new inlines.parse(matched, context)
  end
end

Instance Method Details

#==(o) ⇒ Object



50
51
52
# File 'lib/hparser/block/p.rb', line 50

def ==(o)
  self.class == o.class and self.content == o.content
end

#to_latexObject



64
65
66
67
68
# File 'lib/hparser/latex.rb', line 64

def to_latex
  content = super
  content += "\n\n"
  content
end