# coding:utf-8
from base import TestBase

class TestItalic(TestBase):
    """Test for attributes 'bracket'"""

    # for debug
    # def tearDown(self):
    #     pass

    # TODO: How can we remove "autolink=true" only in these tests below ?

    bracket_text = \
"""

<!-- MarkdownTOC autolink=true -->

<!-- /MarkdownTOC -->

# this is _italic_
# _this is italic_
# _this is not italic __
# this _is italic_
# _ this is not italic _
# 2 _ this is not italic _
# _this is not italic with markdown error _
# 2 _this is not italic with markdown error _
"""

    def test_italic_in_inheading1(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [this is _italic_](#this-is-italic)', toc)

    def test_italic_in_inheading2(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [_this is italic_](#this-is-italic-1)', toc)

    def test_italic_in_inheading3(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [_this is not italic __](#_this-is-not-italic-__)', toc)

    def test_italic_in_inheading4(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [this _is italic_](#this-is-italic-2)', toc)

    def test_italic_in_inheading5(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [_ this is not italic _](#_-this-is-not-italic-_)', toc)

    def test_italic_in_inheading6(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [2 _ this is not italic _](#2-_-this-is-not-italic-_)', toc)

    def test_italic_in_inheading7(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [_this is not italic with markdown error _](#_this-is-not-italic-with-markdown-error-_)', toc)

    def test_italic_in_inheading8(self):
        toc = self.init_update(self.bracket_text)['toc']
        self.assert_In('- [2 _this is not italic with markdown error _](#2-_this-is-not-italic-with-markdown-error-_)', toc)

@@ -546,16 +546,148 @@
 error _%0A
+# %60_should ignore underscores in codeblocks_%60%0A# %60_should ignore underscores in codeblocks 2_ %60%0A# this is %60 _more complex_ %60 exmaple%0A
 %22%22%22%0A%0A   
@@ -2164,28 +2164,680 @@
 th-markdown-error-_)', toc)%0A
+%0A    def test_italic_in_inheading8(self):%0A        toc = self.init_update(self.bracket_text)%5B'toc'%5D%0A        self.assert_In('- %5B%60_should ignore underscores in codeblocks_%60%5D(#_should-ignore-underscores-in-codeblocks_)', toc)%0A%0A    def test_italic_in_inheading8(self):%0A        toc = self.init_update(self.bracket_text)%5B'toc'%5D%0A        self.assert_In('- %5B%60_should ignore underscores in codeblocks 2_ %60%5D(#_should-ignore-underscores-in-codeblocks-2_-)', toc)%0A%0A    def test_italic_in_inheading8(self):%0A        toc = self.init_update(self.bracket_text)%5B'toc'%5D%0A        self.assert_In('- %5Bthis is %60 _more complex_ %60 exmaple%5D(#this-is-_more-complex_-exmaple)', toc)%0A

Add more complex edge cases for italic in headings