Method: Diary#to_chtml

Defined in:
lib/tdiary/io/pstore.rb

#to_chtml(opt) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/tdiary/io/pstore.rb', line 220

def to_chtml( opt )
  idx = 0
  r = ''
  each_section do |paragraph|
    if paragraph.subtitle then
      r << %Q[<P><A NAME="p#{'%02d' % idx += 1}">*</A> #{paragraph.subtitle}</P>]
    end
    if /^</ =~ paragraph.body then
      idx += 1
      r << paragraph.body
    elsif paragraph.subtitle
      r << %Q[<P>#{paragraph.body.collect{|l|l.chomp.sub( /^[  ]/u, '' )}.join( "</P>\n<P>" )}</P>]
    else
      r << %Q[<P><A NAME="p#{'%02d' % idx += 1}">*</A> ]
      if opt['multi_user'] and paragraph.author then
        r << %Q|[#{paragraph.author}]|
      end
      r << %Q[#{paragraph.body.collect{|l|l.chomp.sub( /^[  ]/u, '' )}.join( "</P>\n<P>" )}</P>]
    end
  end
  r
end