Class: HParser::Block::Quote
- Inherits:
-
Object
- Object
- HParser::Block::Quote
- Defined in:
- lib/hparser/block/quote.rb,
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/hatena.rb
Overview
Quote parser.
Defined Under Namespace
Classes: QuoteUrl
Constant Summary collapse
- @@start_pattern =
/^>(.*)>\s*$/
- @@end_pattern =
/^<<\s*$/
- @@blocks =
Concat.new(Or.new(*HParser::Parser.default_parser), Skip.new(Empty))
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
- #hatena_content ⇒ Object
- #hatena_filter(c) ⇒ Object
-
#initialize(items, url = nil) ⇒ Quote
constructor
A new instance of Quote.
- #latex_content ⇒ Object
- #text_content ⇒ Object
- #to_latex ⇒ Object
Methods included from Hatena
Methods included from Indent
Methods included from Text
Methods included from Html
Constructor Details
#initialize(items, url = nil) ⇒ Quote
Returns a new instance of Quote.
31 32 33 34 |
# File 'lib/hparser/block/quote.rb', line 31 def initialize(items, url = nil) @items = items @url = url end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
30 31 32 |
# File 'lib/hparser/block/quote.rb', line 30 def items @items end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
30 31 32 |
# File 'lib/hparser/block/quote.rb', line 30 def url @url end |
Class Method Details
.parse(scanner, context, inlines) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hparser/block/quote.rb', line 17 def self.parse(scanner,context,inlines) if scanner.scan(@@start_pattern) url = Url.parse(StringScanner.new "[#{scanner.matched_pattern[1]}]") items = [] until scanner.scan(@@end_pattern) break unless scanner.match? /.*/ items << @@blocks.parse(scanner,context,inlines)[0] end self.new(items, url) end end |
Instance Method Details
#==(o) ⇒ Object
36 37 38 |
# File 'lib/hparser/block/quote.rb', line 36 def ==(o) o and self.class == o.class and self.items == o.items and @url == o.url end |
#hatena_content ⇒ Object
54 55 56 |
# File 'lib/hparser/hatena.rb', line 54 def hatena_content @items end |
#hatena_filter(c) ⇒ Object
57 58 59 |
# File 'lib/hparser/hatena.rb', line 57 def hatena_filter c ">>\n"+c+"\n<<" end |
#latex_content ⇒ Object
111 112 113 |
# File 'lib/hparser/latex.rb', line 111 def latex_content @items end |
#text_content ⇒ Object
66 67 68 |
# File 'lib/hparser/text.rb', line 66 def text_content @items end |
#to_latex ⇒ Object
106 107 108 109 |
# File 'lib/hparser/latex.rb', line 106 def to_latex content = super %Q[\\begin{quotation}\n#{content}\n\\end{quotation}\n] end |