364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
# File 'lib/ribit/contentparser.rb', line 364
def parse( text, contentDoc )
newContainers = Array.new
urls = text.scan( /\[[^\]]+\]/ )
str = text
urls.each do |url|
firstIndex = str.index( url )
newContainers.push( TextContainer.new( str[0, firstIndex] ) )
pageName = url.delete( '[]' )
if ( /^http:\/\/.+$/.match( pageName ) != nil )
newContainers.push( ReferenceLinkContainer.new( pageName, contentDoc ) )
else
newContainers.push( RibitLinkContainer.new( pageName, contentDoc ) )
end
str = str[ firstIndex + url.size, str.size]
end
if ( str != nil and str.size() > 0 )
newContainers.push( TextContainer.new( str ) )
end
if ( newContainers.size == 0 )
return [TextContainer.new( text )]
end
return newContainers
end
|