Beispiel #1
0
    def new_checkbox_list(self, items: [str], checked: bool = False):
        """Add checkbox list in MarkDown file.

        :param items: Array of items for generating the checkbox list.
        :type items: [str]
        :param checked: if you set this to ``True``. All checkbox will be checked. By default is ``False``.
        :type checked: bool
        :return:
        """

        mdcheckbox = MDCheckbox(items=items, checked=checked)
        self.___update_file_data('\n' + mdcheckbox.get_md())
Beispiel #2
0
    def test_checkbox_with_some_items_checked(self):
        expected_checkbox_list = self.basic_list + \
                       "- [ ] Item 4\n" \
                       "    - [ ] Item 4.1\n" \
                       "    - [x] Item 4.2\n" \
                       "        - [x] Item 4.2.1\n" \
                       "        - [x] Item 4.2.2\n" \
                       "    - [ ] Item 4.3\n" \
                       "        - [x] Item 4.3.1\n" \
                       "- [ ] Item 5\n"
        complex_items = self.basic_items + [
            "Item 4",
            [
                "Item 4.1", "x Item 4.2", ["x Item 4.2.1", "x Item 4.2.2"],
                "Item 4.3", ["x Item 4.3.1"]
            ], "Item 5"
        ]
        checkbox = MDCheckbox(complex_items)

        self.assertEqual(expected_checkbox_list, checkbox.get_md())
Beispiel #3
0
    def test_complex_checkbox(self):
        checkbox = MDCheckbox(self.complex_items)
        expected_checkbox_list = self.complex_list

        self.assertEqual(expected_checkbox_list, checkbox.get_md())
Beispiel #4
0
    def test_complex_checkbox_checked(self):
        checkbox = MDCheckbox(self.complex_items, checked=True)
        expected_checkbox_list = self.complex_list.replace('[ ]', '[x]')

        self.assertEqual(expected_checkbox_list, checkbox.get_md())
Beispiel #5
0
    def test_basic_checkbox(self):
        checkbox = MDCheckbox(self.basic_items)
        expected_checkbox_list = self.basic_list

        self.assertEqual(expected_checkbox_list, checkbox.get_md())