class LATEXBuidlerTest

Public Instance Methods

column_helper(review) click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 605
def column_helper(review)
  compile_block(review)
end
on_appendix?() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 963
def on_appendix?
  true
end
setup() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 10
def setup
  @builder = LATEXBuilder.new
  @config = ReVIEW::Configure.values
  @config.merge!(
    'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
    'toclevel' => 2,
    'stylesheet' => nil, # for EPUBBuilder
    'image_scale2width' => false,
    'texcommand' => 'uplatex'
  )
  @book = Book::Base.new(nil)
  @book.config = @config
  @compiler = ReVIEW::Compiler.new(@builder)
  @chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
  location = Location.new(nil, nil)
  @builder.bind(@compiler, @chapter, location)
  I18n.setup('ja')
end
test_appendix_image() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 1013
  def test_appendix_image
    @chapter.instance_eval do
      def on_appendix?
        true
      end
    end

    def @chapter.image(_id)
      item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
      item.instance_eval { @path = './images/chap1-sampleimg.png' }
      item
    end

    src = <<-EOS
@<img>{sampleimg}
//image[sampleimg][FOO]{
//}
EOS
    expected = <<-EOS

\\reviewimageref{A.1}{image:chap1:sampleimg}

\\begin{reviewimage}
\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
\\caption{FOO}
\\label{image:chap1:sampleimg}
\\end{reviewimage}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_appendix_list() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 961
  def test_appendix_list
    @chapter.instance_eval do
      def on_appendix?
        true
      end
    end
    src = <<-EOS
@<list>{foo}
//list[foo][FOO]{
//}
EOS
    expected = <<-EOS

\\reviewlistref{A.1}

\\reviewlistcaption{リストA.1: FOO}
\\begin{reviewlist}
\\end{reviewlist}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_appendix_table() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 984
  def test_appendix_table
    @chapter.instance_eval do
      def on_appendix?
        true
      end
    end
    src = <<-EOS
@<table>{foo}
//table[foo][FOO]{
A       B
//}
EOS
    expected = <<-EOS

\\reviewtableref{A.1}{table:chap1:foo}

\\begin{table}[h]
\\reviewtablecaption{FOO}
\\label{table:chap1:foo}
\\begin{reviewtable}{|l|l|}
\\hline
\\reviewth{A} & B \\\\  \\hline
\\end{reviewtable}
\\end{table}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_bib() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 579
def test_bib
  def @chapter.bibpaper(_id)
    Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
  end

  assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
end
test_bibpaper() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 587
def test_bibpaper
  def @chapter.bibpaper(_id)
    Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
  end

  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
  assert_equal %Q([1] sample bib \\textbf{bold}\n\\label{bib:samplebib}\n\nab\n\n), actual
end
test_bibpaper_without_body() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 596
def test_bibpaper_without_body
  def @chapter.bibpaper(_id)
    Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
  end

  actual = compile_block("//bibpaper[samplebib][sample bib]\n")
  assert_equal %Q([1] sample bib\n\\label{bib:samplebib}\n\n), actual
end
test_block_raw0() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 904
def test_block_raw0
  actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
  expected = %Q(<>!"\n& )
  assert_equal expected, actual
end
test_block_raw1() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 910
def test_block_raw1
  actual = compile_block(%Q(//raw[|latex|<>!"\\n& ]\n))
  expected = %Q(<>!"\n& )
  assert_equal expected, actual
end
test_block_raw2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 916
def test_block_raw2
  actual = compile_block(%Q(//raw[|html, latex|<>!"\\n& ]\n))
  expected = %Q(<>!"\n& )
  assert_equal expected, actual
end
test_block_raw3() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 922
def test_block_raw3
  actual = compile_block(%Q(//raw[|html, idgxml|<>!"\\n& ]\n))
  expected = ''
  assert_equal expected, actual
end
test_block_raw4() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 928
def test_block_raw4
  actual = compile_block(%Q(//raw[|latex <>!"\\n& ]\n))
  expected = %Q(|latex <>!"\n& )
  assert_equal expected, actual
end
test_centering() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 393
def test_centering
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n), actual
end
test_cmd() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 264
def test_cmd
  actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
end
test_cmd_caption() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 269
def test_cmd_caption
  actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
end
test_cmd_lst() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 274
def test_cmd_lst
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\\vspace{-1.5em}\\begin{reviewcmdlst}[title={\\relax},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewcmdlst}\n), actual
end
test_column_1() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 609
  def test_column_1
    review = <<-EOS
===[column] prev column

inside prev column

===[column] test

inside column

===[/column]
EOS
    expected = <<-EOS

\\begin{reviewcolumn}
\\hypertarget{column:chap1:1}{}
\\reviewcolumnhead{}{prev column}
\\addcontentsline{toc}{subsection}{prev column}

inside prev column

\\end{reviewcolumn}

\\begin{reviewcolumn}
\\hypertarget{column:chap1:2}{}
\\reviewcolumnhead{}{test}
\\addcontentsline{toc}{subsection}{test}

inside column

\\end{reviewcolumn}
EOS
    @config['toclevel'] = 3
    assert_equal expected, column_helper(review)
  end
test_column_2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 645
  def test_column_2
    review = <<-EOS
===[column] test

inside column

=== next level
EOS
    expected = <<-EOS

\\begin{reviewcolumn}
\\hypertarget{column:chap1:1}{}
\\reviewcolumnhead{}{test}

inside column

\\end{reviewcolumn}

\\subsection*{next level}
\\label{sec:1-0-1}
EOS

    @config['toclevel'] = 1
    assert_equal expected, column_helper(review)
  end
test_column_3() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 671
  def test_column_3
    review = <<-EOS
===[column] test

inside column

===[/column_dummy]
EOS
    assert_raise(ReVIEW::ApplicationError) do
      column_helper(review)
    end
  end
test_comment() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 934
def test_comment
  actual = compile_block('//comment[コメント]')
  assert_equal '', actual
end
test_comment_for_draft() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 939
def test_comment_for_draft
  @config['draft'] = true
  actual = compile_block('//comment[コメント]')
  assert_equal %Q(\\pdfcomment{コメント}\n), actual
end
test_cont() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 716
  def test_cont
    src = <<-EOS
  * AAA
    -AA
  * BBB
    -BB
EOS
    expected = <<-EOS

\\begin{itemize}
\\item AAA{-}AA
\\item BBB{-}BB
\\end{itemize}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_customize_cellwidth() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 535
def test_customize_cellwidth
  actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
  assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\  \\hline\n\\end{reviewtable}\n), actual

  actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
  assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\  \\hline\n\\end{reviewtable}\n), actual

  actual = compile_block("//tsize[|html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
  assert_equal %Q(\\begin{reviewtable}{|l|l|l|}\n\\hline\n\\reviewth{A} & B & C \\\\  \\hline\n\\end{reviewtable}\n), actual

  actual = compile_block("//tsize[|latex|2,3,5]\n//table{\nA\tB\tC\n//}\n")
  assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\  \\hline\n\\end{reviewtable}\n), actual

  actual = compile_block("//tsize[|latex||p{5mm}|cr|]\n//table{\nA\tB\tC\n//}\n")
  assert_equal %Q(\\begin{reviewtable}{|p{5mm}|cr|}\n\\hline\n\\reviewth{A} & B & C \\\\  \\hline\n\\end{reviewtable}\n), actual
end
test_dlist() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 249
def test_dlist
  actual = compile_block(": foo\n  foo.\n  bar.\n")
  assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
end
test_dlist_beforeulol() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 259
def test_dlist_beforeulol
  actual = compile_block(" : foo\n  foo.\n\npara\n\n : foo\n  foo.\n\n 1. bar\n\n : foo\n  foo.\n\n * bar\n")
  assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\npara\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{enumerate}\n\\item bar\n\\end{enumerate}\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{itemize}\n\\item bar\n\\end{itemize}\n), actual
end
test_dlist_with_bracket() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 254
def test_dlist_with_bracket
  actual = compile_block(": foo[bar]\n    foo.\n    bar.\n")
  assert_equal %Q(\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
end
test_emlist() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 281
def test_emlist
  actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
end
test_emlist_caption() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 301
def test_emlist_caption
  actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
end
test_emlist_lst() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 286
def test_emlist_lst
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
  assert_equal %Q(\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
end
test_emlist_lst_without_lang() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 293
def test_emlist_lst_without_lang
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  @book.config['highlight']['lang'] = 'sql'
  actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
  assert_equal %Q(\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
end
test_emlist_with_tab() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 306
def test_emlist_with_tab
  actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
  assert_equal %Q(\n\\begin{reviewemlist}\n        foo\n                bar\n\n        buz\n\\end{reviewemlist}\n), actual
end
test_emlist_with_tab4() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 311
def test_emlist_with_tab4
  @config['tabwidth'] = 4
  actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
  assert_equal %Q(\n\\begin{reviewemlist}\n    foo\n        bar\n\n    buz\n\\end{reviewemlist}\n), actual
end
test_emlistnum_caption() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 317
def test_emlistnum_caption
  actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n), actual
end
test_emtable() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 552
def test_emtable
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
  assert_equal "\\begin{table}[h]\n\\reviewtablecaption*{foo}\n\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\  \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\  \\hline\n\\end{reviewtable}\n\\end{table}\n\n\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\  \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\  \\hline\n\\end{reviewtable}\n",
               actual
end
test_flushright() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 388
def test_flushright
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n), actual
end
test_headline_level1() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 29
def test_headline_level1
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q(\\chapter{this is test.}\n\\label{chap:chap1}\n), actual
end
test_headline_level1_with_inlinetag() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 40
def test_headline_level1_with_inlinetag
  actual = compile_block(%Q(={test} this @<b>{is} test.<&"_>\n))
  assert_equal %Q(\\chapter{this \\textbf{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n), actual
end
test_headline_level1_without_secno() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 34
def test_headline_level1_without_secno
  @config['secnolevel'] = 0
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q(\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n), actual
end
test_headline_level2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 45
def test_headline_level2
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q(\\section{this is test.}\n\\label{sec:1-1}\n\\label{test}\n), actual
end
test_headline_level3() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 50
def test_headline_level3
  actual = compile_block("==={test} this is test.\n")
  assert_equal %Q(\\subsection*{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
end
test_headline_level3_with_secno() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 55
def test_headline_level3_with_secno
  @config['secnolevel'] = 3
  actual = compile_block("==={test} this is test.\n")
  assert_equal %Q(\\subsection{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
end
test_href() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 66
def test_href
  actual = compile_inline('@<href>{http://github.com,GitHub}')
  assert_equal '\\href{http://github.com}{GitHub}', actual
end
test_href_mailto() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 86
def test_href_mailto
  actual = compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
  assert_equal '\\href{mailto:takahashim@example.com}{takahashim@example.com}', actual
end
test_href_with_underscore() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 81
def test_href_with_underscore
  actual = compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
  assert_equal '\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}', actual
end
test_href_without_label() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 76
def test_href_without_label
  actual = compile_inline('@<href>{http://github.com}')
  assert_equal '\\url{http://github.com}', actual
end
test_image() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 403
def test_image
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
end
test_image_with_metric() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 414
def test_image_with_metric
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
end
test_image_with_metric2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 437
def test_image_with_metric2
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
end
test_image_with_metric2_width() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 448
def test_image_with_metric2_width
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  @config['image_scale2width'] = true
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
end
test_image_with_metric_width() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 425
def test_image_with_metric_width
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  @config['image_scale2width'] = true
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
end
test_imgtable() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 558
  def test_imgtable
    def @chapter.image(_id)
      item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample img')
      item.instance_eval { @path = './images/chap1-sampleimg.png' }
      item
    end

    actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")

    expected = <<-EOS
\\begin{table}[h]
\\reviewimgtablecaption{test for imgtable}
\\label{table:chap1:sampleimg}
\\begin{reviewimage}
\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
\\end{reviewimage}
\\end{table}
EOS
    assert_equal expected, actual
  end
test_indepimage() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 460
def test_indepimage
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
end
test_indepimage_with_metric() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 483
def test_indepimage_with_metric
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
end
test_indepimage_with_metric2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 506
def test_indepimage_with_metric2
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
end
test_indepimage_with_metric_width() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 494
def test_indepimage_with_metric_width
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  @config['image_scale2width'] = true
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
end
test_indepimage_without_caption() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 471
def test_indepimage_without_caption
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  # FIXME: indepimage's caption should not be with a counter.
  actual = compile_block("//indepimage[sampleimg]\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
end
test_indepimage_without_caption_but_with_metric() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 517
def test_indepimage_without_caption_but_with_metric
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  # FIXME: indepimage's caption should not be with a counter.
  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
  assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
end
test_inline_b() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 136
def test_inline_b
  actual = compile_inline('abc@<b>{def}')
  assert_equal 'abc\\textbf{def}', actual
end
test_inline_b_and_escape() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 141
def test_inline_b_and_escape
  actual = compile_inline('test @<b>{inline<&;\\ test} test2')
  assert_equal 'test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
end
test_inline_br() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 91
def test_inline_br
  actual = compile_inline('@<br>{}')
  assert_equal %Q(\\\\\n), actual
end
test_inline_br_with_other_strings() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 96
def test_inline_br_with_other_strings
  actual = compile_inline('abc@<br>{}def')
  assert_equal %Q(abc\\\\\ndef), actual
end
test_inline_code() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 116
def test_inline_code
  actual = compile_inline('abc@<code>{def}ghi')
  assert_equal 'abc\\texttt{def}ghi', actual
end
test_inline_comment() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 945
def test_inline_comment
  actual = compile_inline('test @<comment>{コメント} test2')
  assert_equal 'test  test2', actual
end
test_inline_comment_for_draft() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 950
def test_inline_comment_for_draft
  @config['draft'] = true
  actual = compile_inline('test @<comment>{コメント} test2')
  assert_equal 'test \\pdfcomment{コメント} test2', actual
end
test_inline_dtp() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 111
def test_inline_dtp
  actual = compile_inline('abc@<dtp>{def}ghi')
  assert_equal 'abcghi', actual
end
test_inline_em() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 146
def test_inline_em
  actual = compile_inline('abc@<em>{def}')
  assert_equal 'abc\\reviewem{def}', actual
end
test_inline_endash() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 875
def test_inline_endash
  actual = compile_inline('- -- --- ----')
  assert_equal '{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}', actual
end
test_inline_fence() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 956
def test_inline_fence
  actual = compile_inline('test @<code>|@<code>{$サンプル$}|')
  assert_equal 'test \\texttt{@\\textless{}code\\textgreater{}\\{\\textdollar{}サンプル\\textdollar{}\\}}', actual
end
test_inline_hd_chap() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 193
def test_inline_hd_chap
  def @chapter.headline_index
    items = [Book::HeadlineIndex::Item.new('chap1|test', [1, 1], 'te_st')]
    Book::HeadlineIndex.new(items, self)
  end

  @config['secnolevel'] = 3
  actual = compile_inline('test @<hd>{chap1|test} test2')
  assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
end
test_inline_href() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 71
def test_inline_href
  actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
  assert_equal '\\href{http://github.com}{Git,Hub}', actual
end
test_inline_i() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 101
def test_inline_i
  actual = compile_inline('abc@<i>{def}ghi')
  assert_equal 'abc\\textit{def}ghi', actual
end
test_inline_i_and_escape() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 106
def test_inline_i_and_escape
  actual = compile_inline('test @<i>{inline<&;\\ test} test2')
  assert_equal 'test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
end
test_inline_idx() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 219
def test_inline_idx
  actual = compile_inline('@<idx>{__TEST%$}, @<hidx>{__TEST%$}')
  assert_equal '\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}', actual
end
test_inline_idx_yomi() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 224
def test_inline_idx_yomi
  begin
    require 'MeCab'
    require 'nkf'
  rescue LoadError
    $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
    return true
  end
  tmpdir = Dir.mktmpdir
  File.write("#{tmpdir}/sample.dic", "強運\tはーどらっく\n")
  @book.config['pdfmaker']['makeindex'] = true
  @book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
  @builder.setup_index
  actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
  FileUtils.remove_entry_secure(tmpdir)
  assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
end
test_inline_imgref() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 880
def test_inline_imgref
  def @chapter.image(_id)
    item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
  assert_equal expected, actual
end
test_inline_imgref2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 892
def test_inline_imgref2
  def @chapter.image(_id)
    item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
    item.instance_eval { @path = './images/chap1-sampleimg.png' }
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
  assert_equal expected, actual
end
test_inline_m() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 161
def test_inline_m
  actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
  assert_equal 'abc $\\alpha^n = \\inf < 2$ ghi', actual
end
test_inline_m2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 166
def test_inline_m2
  ## target text: @<m>{X = \{ {x_1\},{x_2\}, \cdots ,{x_n\} \\\}}
  actual = compile_inline('@<m>{X = \\{ {x_1\\},{x_2\\}, \\cdots ,{x_n\\} \\\\\\}}')
  ## expected text: $X = \{ {x_1},{x_2}, \cdots ,{x_n} \}$
  assert_equal ' $X = \\{ {x_1},{x_2}, \\cdots ,{x_n} \\}$ ', actual
end
test_inline_pageref() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 204
def test_inline_pageref
  actual = compile_inline('test p.@<pageref>{p1}')
  assert_equal 'test p.\pageref{p1}', actual
end
test_inline_raw() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 121
def test_inline_raw
  actual = compile_inline('@<raw>{@<tt>{inline!$%\\}}')
  assert_equal '@<tt>{inline!$%}', actual
end
test_inline_raw0() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 851
def test_inline_raw0
  assert_equal 'normal', compile_inline('@<raw>{normal}')
end
test_inline_raw1() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 855
def test_inline_raw1
  assert_equal 'body', compile_inline('@<raw>{|latex|body}')
end
test_inline_raw2() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 859
def test_inline_raw2
  assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
end
test_inline_raw3() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 863
def test_inline_raw3
  assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
end
test_inline_raw4() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 867
def test_inline_raw4
  assert_equal '|latex body', compile_inline('@<raw>{|latex body}')
end
test_inline_raw5() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 871
def test_inline_raw5
  assert_equal "nor\nmal", compile_inline('@<raw>{|latex|nor\\nmal}')
end
test_inline_ruby_comma() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 209
def test_inline_ruby_comma
  actual = compile_inline('@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}')
  assert_equal '\\ruby{foo, bar, buz}{フー・バー・バズ}', actual
end
test_inline_strong() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 151
def test_inline_strong
  actual = compile_inline('abc@<strong>{def}')
  assert_equal 'abc\\reviewstrong{def}', actual
end
test_inline_sub() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 131
def test_inline_sub
  actual = compile_inline('abc@<sub>{def}')
  assert_equal 'abc\\textsubscript{def}', actual
end
test_inline_sup() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 126
def test_inline_sup
  actual = compile_inline('abc@<sup>{def}')
  assert_equal 'abc\\textsuperscript{def}', actual
end
test_inline_tt() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 173
def test_inline_tt
  actual = compile_inline('test @<tt>{inline test} test2')
  assert_equal 'test \\texttt{inline test} test2', actual
end
test_inline_tt_endash() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 178
def test_inline_tt_endash
  actual = compile_inline('test @<tt>{in-line --test ---foo ----bar -----buz} --test2')
  assert_equal 'test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2', actual
end
test_inline_ttb() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 188
def test_inline_ttb
  actual = compile_inline('test @<ttb>{inline test} test2')
  assert_equal 'test \\texttt{\\textbf{inline test}} test2', actual
end
test_inline_tti() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 183
def test_inline_tti
  actual = compile_inline('test @<tti>{inline test} test2')
  assert_equal 'test \\texttt{\\textit{inline test}} test2', actual
end
test_inline_u() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 156
def test_inline_u
  actual = compile_inline('abc@<u>{def}ghi')
  assert_equal 'abc\\reviewunderline{def}ghi', actual
end
test_inline_uchar() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 214
def test_inline_uchar
  actual = compile_inline('test @<uchar>{2460} test2')
  assert_equal 'test \\UTF{2460} test2', actual
end
test_jis_x_0201_kana() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 242
def test_jis_x_0201_kana
  # uplatex can handle half-width kana natively
  actual = compile_inline('foo・カンジ、テスト')
  assert_equal 'foo・カンジ、テスト', actual
  # assert_equal %Q(foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト), actual
end
test_label() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 61
def test_label
  actual = compile_block("//label[label_test]\n")
  assert_equal %Q(\\label{label_test}\n), actual
end
test_list() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 322
def test_list
  actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n), actual
end
test_list_lst() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 327
def test_list_lst
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
  assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
end
test_list_lst_with_lang() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 334
def test_list_lst_with_lang
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  @book.config['highlight']['lang'] = 'sql'
  actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
  assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
end
test_listnum() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 342
def test_listnum
  actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n//}\n")
  assert_equal %Q(\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2:   def foo\n 3:     bar\n 4: \n 5:     buz\n 6:   end\n 7: end\n\\end{reviewlist}\n), actual
end
test_listnum_linenum() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 347
def test_listnum_linenum
  actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n//}\n")
  assert_equal %Q(\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n100: class Foo\n101:   def foo\n102:     bar\n103: \n104:     buz\n105:   end\n106: end\n\\end{reviewlist}\n), actual
end
test_listnum_lst() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 352
def test_listnum_lst
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n//}\n")
  assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={}]\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n\\end{reviewlistnumlst}\n), actual
end
test_listnum_lst_linenum() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 359
def test_listnum_lst_linenum
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n//}\n")
  assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]\nclass Foo\n  def foo\n    bar\n\n    buz\n  end\nend\n\\end{reviewlistnumlst}\n), actual
end
test_major_blocks() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 817
def test_major_blocks
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual

  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
  expected = %Q(\\begin{reviewminicolumn}\nA\n\nB\n\\end{reviewminicolumn}\n\\begin{reviewminicolumn}\n\\reviewminicolumntitle{caption}\nA\n\\end{reviewminicolumn}\n)
  assert_equal expected, actual
end
test_memo() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 383
def test_memo
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q(\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest\\textit{2}\n\\end{reviewminicolumn}\n), actual
end
test_noindent() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 398
def test_noindent
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
  assert_equal %Q(\\noindent\nfoo\nbar\n\nfoo2\nbar2\n), actual
end
test_ol() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 784
  def test_ol
    src = <<-EOS
  3. AAA
  3. BBB
EOS

    expected = <<-EOS

\\begin{enumerate}
\\item AAA
\\item BBB
\\end{enumerate}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ol_with_bracket() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 801
  def test_ol_with_bracket
    src = <<-EOS
  1. AAA
  2. []BBB
EOS
    expected = <<-EOS

\\begin{enumerate}
\\item AAA
\\item \\lbrack{}]BBB
\\end{enumerate}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_quote() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 378
def test_quote
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n), actual
end
test_source() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 366
def test_source
  actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n), actual
end
test_source_lst() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 371
def test_source_lst
  @book.config['highlight'] = {}
  @book.config['highlight']['latex'] = 'listings'
  actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q(\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewsourcelst}\n), actual
end
test_table() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 529
def test_table
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
  assert_equal "\\begin{reviewtable}{|l|l|}\n\\hline\n\\reviewth{aaa} & \\reviewth{bbb} \\\\  \\hline\nccc & ddd\\textless{}\\textgreater{}\\& \\\\  \\hline\n\\end{reviewtable}\n",
               actual
end
test_ul() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 684
  def test_ul
    src = <<-EOS
  * AAA
  * BBB
EOS
    expected = <<-EOS

\\begin{itemize}
\\item AAA
\\item BBB
\\end{itemize}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest1() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 734
  def test_ul_nest1
    src = <<-EOS
  * AAA
  ** AA
EOS

    expected = <<-EOS

\\begin{itemize}
\\item AAA

\\begin{itemize}
\\item AA
\\end{itemize}

\\end{itemize}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest3() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 755
  def test_ul_nest3
    src = <<-EOS
  * AAA
  ** AA
  * BBB
  ** BB
EOS

    expected = <<-EOS

\\begin{itemize}
\\item AAA

\\begin{itemize}
\\item AA
\\end{itemize}

\\item BBB

\\begin{itemize}
\\item BB
\\end{itemize}

\\end{itemize}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_with_bracket() click to toggle source
# File ../../../../../test/test_latexbuilder.rb, line 700
  def test_ul_with_bracket
    src = <<-EOS
  * AAA
  * []BBB
EOS
    expected = <<-EOS

\\begin{itemize}
\\item AAA
\\item \\lbrack{}]BBB
\\end{itemize}
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end