def test_convertItalics_twoItalicsInARow_fromUnderscores(self):

        text = '_italics_\n___bold and italics___'
        character = '*'

        expected = '*italics*\n__*bold and italics*__'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_boldAndItalics_sameCharacter_noChange(self):

        text = '***BoldAndItalics***'
        character = '*'

        expected = '***BoldAndItalics***'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_bold(self):

        text = '**Italics**'
        character = '_'

        expected = '**Italics**'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_fromOtherCharacter_underscore(self):

        text = '_Bold_'
        character = '*'

        expected = '*Bold*'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_empty(self):

        text = ''
        character = '_'

        expected = ''
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalicss_singleCharacter(self):

        text = '*I*'
        character = '_'

        expected = '_I_'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_fromOtherCharacter_asterisk(self):

        text = '*Italics*'
        character = '_'

        expected = '_Italics_'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_twoItalicsInARow_fromAsterisks(self):

        text = '*italics*\n***bold and italics***'
        character = '_'

        expected = '_italics_\n**_bold and italics_**'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_noChange(self):

        text = '_Italics_'
        character = '_'

        expected = '_Italics_'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_boldAndItalicsInMiddleOfSentence(self):

        text = 'There is both ***bold and italics*** in this sentence.'
        character = '_'

        expected = 'There is both **_bold and italics_** in this sentence.'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_italicsInMiddleOfSentence(self):

        text = 'There are *italics* in this sentence.'
        character = '_'

        expected = 'There are _italics_ in this sentence.'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_tooManyCharacters(self):

        text = '****too many****'
        character = '_'

        expected = '**_*too many*_**'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
    def test_convertItalics_wrappedTextEndsWithSpace(self):

        text = '*ends with space *'
        character = '_'

        expected = '*ends with space *'
        actual = italic_utils.convert_italics(text, character)

        self.assertEqual(actual, expected)
Exemplo n.º 14
0
    def test_cleanToClean(self):

        with open(CLEAN_FILE_PATH) as clean_file:
            expected = clean_file.read()

        actual = bold_utils.convert_bolds(expected)
        actual = header_utils.fix_header_balancing(actual)
        actual = horizontal_rule_utils.convert_horizontal_rules(actual)
        actual = italic_utils.convert_italics(actual)
        actual = link_utils.discover_missing_links(actual)
        actual = link_utils.format_link_reference_definitions(actual)
        actual = list_utils.alternate_unordered_list_delimiters(actual)
        actual = list_utils.fix_ordered_list_numbering(actual)
        actual = whitespace_utils.trim_nonbreaking_whitespace(actual)

        self.assertEqual(actual, expected)
Exemplo n.º 15
0
    def test_dirtyToClean_atx_unbalanced(self):

        with open(DIRTY_FILE_PATH) as dirty_file:
            text = dirty_file.read()
        with open(CLEAN_ANY_HEADER_UNBALANCED_FILE_PATH) as clean_file:
            expected = clean_file.read()

        actual = bold_utils.convert_bolds(text)
        actual = header_utils.fix_header_balancing(actual, balancing=header_utils.UNBALANCED)
        actual = horizontal_rule_utils.convert_horizontal_rules(actual)
        actual = italic_utils.convert_italics(actual)
        actual = link_utils.discover_missing_links(actual)
        actual = link_utils.format_link_reference_definitions(actual)
        actual = list_utils.alternate_unordered_list_delimiters(actual)
        actual = list_utils.fix_ordered_list_numbering(actual)
        actual = whitespace_utils.trim_nonbreaking_whitespace(actual)

        self.assertEqual(actual, expected)
Exemplo n.º 16
0
    def modify(self, text):
        """Converts any italics implementation into the one defined in the settings."""

        italics_character = pretty_markdown.settings().get('italics_character')
        return italic_utils.convert_italics(text, italics_character)
    def test_convertItalics_wrongCharacter(self):

        with self.assertRaisesRegex(AssertionError, 'character must be one of *'):
            italic_utils.convert_italics('', '^')