Method: ReVIEW::LATEXBuilder#make_code_block_args

Defined in:
lib/review/latexbuilder.rb

#make_code_block_args(title, caption, lang, first_line_num: 1) ⇒ Object



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/review/latexbuilder.rb', line 524

def make_code_block_args(title, caption, lang, first_line_num: 1)
  caption_str = compile_inline((caption || ''))
  if title == 'title' && caption_str == '' && @book.config.check_version('2', exception: false)
    caption_str = '\relax' ## dummy charactor to remove lstname
  end
  lexer = if @book.config['highlight'] && @book.config['highlight']['lang']
            @book.config['highlight']['lang'] # default setting
          else
            ''
          end
  lexer = lang if lang.present?
  args = "language={#{lexer}}"
  if title == 'title' && caption_str == ''
    # ignore
  else
    args = "#{title}={#{caption_str}}," + args
  end
  if first_line_num != 1
    args << ",firstnumber=#{first_line_num}"
  end
  args
end