diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 70575b7..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,258 +0,0 @@ -# Changelog - -## [v1.8.1](https://github.com/didix21/mdutils/tree/v1.8.1) (2025-10-18) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.8.0...v1.8.1) - -**Implemented enhancements:** - -- Generate tables from 2D string arrays [\#114](https://github.com/didix21/mdutils/pull/114) ([skelsec](https://github.com/skelsec)) - -**Fixed bugs:** - -- Text starting with `**` \(bold\) breaks `new_list` method [\#116](https://github.com/didix21/mdutils/issues/116) -- fix: Text starting with \*\* \(bold\) breaks new\_list method [\#117](https://github.com/didix21/mdutils/pull/117) ([didix21](https://github.com/didix21)) - -**Merged pull requests:** - -- build and publish wheel [\#113](https://github.com/didix21/mdutils/pull/113) ([dimbleby](https://github.com/dimbleby)) - -## [v1.8.0](https://github.com/didix21/mdutils/tree/v1.8.0) (2025-07-10) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.7.0...v1.8.0) - -## [v1.7.0](https://github.com/didix21/mdutils/tree/v1.7.0) (2025-06-05) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.6.0...v1.7.0) - -**Implemented enhancements:** - -- Enable specifying title header style, default being setext [\#112](https://github.com/didix21/mdutils/pull/112) ([tonur](https://github.com/tonur)) -- Refactor Header [\#94](https://github.com/didix21/mdutils/pull/94) ([didix21](https://github.com/didix21)) - -**Fixed bugs:** - -- Cannot specify style of title, so the style of the first header is always "setext" even though the default style of other headers is "atx" [\#111](https://github.com/didix21/mdutils/issues/111) -- fix: add IDE support for List argument of text\_align in new\_table [\#109](https://github.com/didix21/mdutils/pull/109) ([natebwangsut](https://github.com/natebwangsut)) -- Remove extra spaces added by new\_line\(\) [\#103](https://github.com/didix21/mdutils/pull/103) ([bbodenmiller](https://github.com/bbodenmiller)) - -**Closed issues:** - -- Fix example for example provided [\#106](https://github.com/didix21/mdutils/issues/106) -- README.md Broken examples in Create Links section [\#105](https://github.com/didix21/mdutils/issues/105) -- . [\#102](https://github.com/didix21/mdutils/issues/102) -- Clarifying documentation around MdUtils filename param [\#98](https://github.com/didix21/mdutils/issues/98) -- Implement automated releases [\#88](https://github.com/didix21/mdutils/issues/88) - -**Merged pull requests:** - -- Update codecov github action and add analytics [\#110](https://github.com/didix21/mdutils/pull/110) ([didix21](https://github.com/didix21)) -- GH-105: README.md Broken examples in Create Links section [\#108](https://github.com/didix21/mdutils/pull/108) ([didix21](https://github.com/didix21)) -- GH-106: Fix example for example provided [\#107](https://github.com/didix21/mdutils/pull/107) ([didix21](https://github.com/didix21)) -- Update documentation for MdUtils filename param [\#99](https://github.com/didix21/mdutils/pull/99) ([3sbwya](https://github.com/3sbwya)) -- GH-88: Automate release candidate [\#97](https://github.com/didix21/mdutils/pull/97) ([didix21](https://github.com/didix21)) - -## [v1.6.0](https://github.com/didix21/mdutils/tree/v1.6.0) (2023-04-29) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.5.1...v1.6.0) - -**Implemented enhancements:** - -- DEPRECATION on setup.py [\#80](https://github.com/didix21/mdutils/issues/80) -- Code adherence to PEP 8 [\#46](https://github.com/didix21/mdutils/issues/46) -- GH-80: Support poetry build system [\#93](https://github.com/didix21/mdutils/pull/93) ([didix21](https://github.com/didix21)) -- GH-84: Add types to mdutils methods [\#85](https://github.com/didix21/mdutils/pull/85) ([didix21](https://github.com/didix21)) - -**Fixed bugs:** - -- DeprecationWarning with Python 3.11 [\#90](https://github.com/didix21/mdutils/issues/90) - -**Closed issues:** - -- Add types on mdutils methods [\#84](https://github.com/didix21/mdutils/issues/84) - -**Merged pull requests:** - -- GH-90: Avoid warning on python 3.11 [\#92](https://github.com/didix21/mdutils/pull/92) ([didix21](https://github.com/didix21)) -- Fix build badge [\#91](https://github.com/didix21/mdutils/pull/91) ([didix21](https://github.com/didix21)) -- GH-46: Add flake8 config [\#86](https://github.com/didix21/mdutils/pull/86) ([didix21](https://github.com/didix21)) - -## [v1.5.1](https://github.com/didix21/mdutils/tree/v1.5.1) (2023-03-11) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.5.0...v1.5.1) - -**Fixed bugs:** - -- MarkDownFile not accepting absolute file path anymore [\#81](https://github.com/didix21/mdutils/issues/81) -- Fix \#81: Absolute path are broken [\#83](https://github.com/didix21/mdutils/pull/83) ([didix21](https://github.com/didix21)) - -## [v1.5.0](https://github.com/didix21/mdutils/tree/v1.5.0) (2023-02-11) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.4.0...v1.5.0) - -**Implemented enhancements:** - -- Introduce `header_id` as parameter for headers [\#78](https://github.com/didix21/mdutils/pull/78) ([kieferro](https://github.com/kieferro)) - -**Fixed bugs:** - -- converting html tables to markdown creates unusable tables [\#73](https://github.com/didix21/mdutils/issues/73) - -**Closed issues:** - -- Add Id to header [\#77](https://github.com/didix21/mdutils/issues/77) -- mkreports package [\#71](https://github.com/didix21/mdutils/issues/71) - -**Merged pull requests:** - -- Update setup-python version [\#79](https://github.com/didix21/mdutils/pull/79) ([didix21](https://github.com/didix21)) -- Modify tests to fix flakiness [\#76](https://github.com/didix21/mdutils/pull/76) ([blazyy](https://github.com/blazyy)) -- Fix typos in README [\#75](https://github.com/didix21/mdutils/pull/75) ([kieferro](https://github.com/kieferro)) - -## [v1.4.0](https://github.com/didix21/mdutils/tree/v1.4.0) (2022-05-31) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.3.1...v1.4.0) - -**Implemented enhancements:** - -- Add fontsize increase option for Paragraph [\#54](https://github.com/didix21/mdutils/issues/54) -- Added `get_md_text` method to `MdUtils` class. [\#61](https://github.com/didix21/mdutils/pull/61) ([Patitotective](https://github.com/Patitotective)) - -**Fixed bugs:** - -- Unwanted line break in link url breaks the link [\#70](https://github.com/didix21/mdutils/issues/70) -- Varying Title level leads to IndexError in \_\_add\_new\_item\_table\_of\_content [\#68](https://github.com/didix21/mdutils/issues/68) -- GH-70, GH-73: fix unwanted link and table breaks [\#74](https://github.com/didix21/mdutils/pull/74) ([didix21](https://github.com/didix21)) -- Escape "|" in Table.create\_table [\#63](https://github.com/didix21/mdutils/pull/63) ([jaredliw](https://github.com/jaredliw)) - -**Closed issues:** - -- travis-ci.org is ceased and tests are not running [\#62](https://github.com/didix21/mdutils/issues/62) - -**Merged pull requests:** - -- Import coverage to codecov [\#66](https://github.com/didix21/mdutils/pull/66) ([didix21](https://github.com/didix21)) -- 62: Move test workflow from travis to github actions [\#65](https://github.com/didix21/mdutils/pull/65) ([didix21](https://github.com/didix21)) - -## [v1.3.1](https://github.com/didix21/mdutils/tree/v1.3.1) (2021-07-09) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.3.0...v1.3.1) - -**Fixed bugs:** - -- NameError: name 'create\_md\_file' is not define [\#50](https://github.com/didix21/mdutils/issues/50) -- Solve max text length [\#6](https://github.com/didix21/mdutils/issues/6) -- convert value to str before adding it to a char [\#56](https://github.com/didix21/mdutils/pull/56) ([anaskhl](https://github.com/anaskhl)) - -**Merged pull requests:** - -- Add release drafter action [\#58](https://github.com/didix21/mdutils/pull/58) ([didix21](https://github.com/didix21)) -- Add PR labeler action [\#57](https://github.com/didix21/mdutils/pull/57) ([didix21](https://github.com/didix21)) -- Fix \#6: add option to wrap text on new lines, paragraphs and writes [\#53](https://github.com/didix21/mdutils/pull/53) ([mhmdkanj](https://github.com/mhmdkanj)) -- make text\_align be a list not only str or None [\#47](https://github.com/didix21/mdutils/pull/47) ([sgsokol](https://github.com/sgsokol)) - -## [v1.3.0](https://github.com/didix21/mdutils/tree/v1.3.0) (2020-09-12) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.2.2...v1.3.0) - -**Implemented enhancements:** - -- Implement \#43 Allow table of contents to generate from arbitrary depth of headers [\#44](https://github.com/didix21/mdutils/pull/44) ([mythWizard](https://github.com/mythWizard)) - -**Fixed bugs:** - -- Default text align for tables should use --- [\#42](https://github.com/didix21/mdutils/issues/42) -- Fix \#42 Default table's text\_align should be '---' [\#45](https://github.com/didix21/mdutils/pull/45) ([didix21](https://github.com/didix21)) - -**Closed issues:** - -- Allow creation of Table of Contents with arbitrary depth [\#43](https://github.com/didix21/mdutils/issues/43) -- write file to specified path [\#41](https://github.com/didix21/mdutils/issues/41) - -## [v1.2.2](https://github.com/didix21/mdutils/tree/v1.2.2) (2020-06-21) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.2.1...v1.2.2) - -**Implemented enhancements:** - -- Add support for markdown lists [\#4](https://github.com/didix21/mdutils/issues/4) - -**Fixed bugs:** - -- Missing .md extension when filename has 'md' [\#37](https://github.com/didix21/mdutils/issues/37) -- Table of contents link does not work when headers contain special characters [\#36](https://github.com/didix21/mdutils/issues/36) -- Fix \#36: Delete special characters when creating toc links [\#40](https://github.com/didix21/mdutils/pull/40) ([didix21](https://github.com/didix21)) -- Fix \#37: Add .md extension if name contains md word [\#39](https://github.com/didix21/mdutils/pull/39) ([didix21](https://github.com/didix21)) - -**Closed issues:** - -- SyntaxError: invalid syntax [\#31](https://github.com/didix21/mdutils/issues/31) - -**Merged pull requests:** - -- Update issue templates [\#35](https://github.com/didix21/mdutils/pull/35) ([didix21](https://github.com/didix21)) -- Create CODE\_OF\_CONDUCT.md [\#34](https://github.com/didix21/mdutils/pull/34) ([didix21](https://github.com/didix21)) -- update Readme.md [\#32](https://github.com/didix21/mdutils/pull/32) ([Alexmod](https://github.com/Alexmod)) - -## [v1.2.1](https://github.com/didix21/mdutils/tree/v1.2.1) (2020-05-08) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.1.1...v1.2.1) - -**Merged pull requests:** - -- Add support list in markdown [\#30](https://github.com/didix21/mdutils/pull/30) ([didix21](https://github.com/didix21)) - -## [v1.1.1](https://github.com/didix21/mdutils/tree/v1.1.1) (2020-04-20) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.1.0...v1.1.1) - -## [v1.1.0](https://github.com/didix21/mdutils/tree/v1.1.0) (2020-04-20) - -[Full Changelog](https://github.com/didix21/mdutils/compare/v1.0.0...v1.1.0) - -**Implemented enhancements:** - -- Inline links [\#12](https://github.com/didix21/mdutils/issues/12) -- Create an Example [\#5](https://github.com/didix21/mdutils/issues/5) -- Add support for markdown images [\#3](https://github.com/didix21/mdutils/issues/3) -- Features to develop [\#2](https://github.com/didix21/mdutils/issues/2) - -**Closed issues:** - -- Add HTML for image support [\#28](https://github.com/didix21/mdutils/issues/28) -- Exclude IDE related files from project [\#24](https://github.com/didix21/mdutils/issues/24) -- how [\#23](https://github.com/didix21/mdutils/issues/23) -- Write to specified path? [\#22](https://github.com/didix21/mdutils/issues/22) -- TextUtils.text\_color adds an extra space [\#20](https://github.com/didix21/mdutils/issues/20) -- Reference-Style Links [\#14](https://github.com/didix21/mdutils/issues/14) - -**Merged pull requests:** - -- Add HTML for image support \#28 [\#29](https://github.com/didix21/mdutils/pull/29) ([didix21](https://github.com/didix21)) -- Add support for markdown images \#3 [\#27](https://github.com/didix21/mdutils/pull/27) ([didix21](https://github.com/didix21)) -- Add coveralls [\#26](https://github.com/didix21/mdutils/pull/26) ([arnsangra](https://github.com/arnsangra)) -- Exclude ide files [\#25](https://github.com/didix21/mdutils/pull/25) ([arnsangra](https://github.com/arnsangra)) -- FIX \#20: Delete TextUtils.text\_color\(\) extra spaces [\#21](https://github.com/didix21/mdutils/pull/21) ([didix21](https://github.com/didix21)) - -## [v1.0.0](https://github.com/didix21/mdutils/tree/v1.0.0) (2018-05-10) - -[Full Changelog](https://github.com/didix21/mdutils/compare/b1ce055fdb9c07ca0f4c8e748be0321dcc996937...v1.0.0) - -**Implemented enhancements:** - -- Improve new\_header giving the option of not to include a header in the table of contents. [\#11](https://github.com/didix21/mdutils/issues/11) -- New method to add code [\#10](https://github.com/didix21/mdutils/issues/10) -- Improve write method: give format to text and place it with markers [\#9](https://github.com/didix21/mdutils/issues/9) - -**Fixed bugs:** - -- when add text as inline code with color doesn't work. [\#8](https://github.com/didix21/mdutils/issues/8) -- Solve line break on new\_line method [\#7](https://github.com/didix21/mdutils/issues/7) - -**Merged pull requests:** - -- Development [\#1](https://github.com/didix21/mdutils/pull/1) ([didix21](https://github.com/didix21)) - - - -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 4302cf5..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at didaccoll_93@hotmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c6e2bde..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,22 +0,0 @@ -# Contributing - -When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. - -Please note we have a code of conduct, please follow it in all your interactions with the project. - -## Pull Request Process - -1. Squash all your commits before opening the PR. -2. Ensure you're pull-request contains a unique commit referencing the issue that solves in the commit message. Example: `Implement new features #7`. -3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. - -## Deployment - -1. The versioning scheme we use is [SemVer](http://semver.org/). -2. Increase the version number in the `mdutils/doc/source/config.py` file. -3. Increase the version number in the `mdutils/setup.py` file. -3. Increase the version number in the `mdutils/pyproject.toml` file. -4. Increase the version number in the `.github_changelog_generator` file. -5. Run `github_changelog_generator -u didix21 -p mdutils`. -6. Run `python -m build`. -7. Upload package to pypi: `twine upload dist/*`. diff --git a/README.md b/README.md deleted file mode 100644 index 7e65f43..0000000 --- a/README.md +++ /dev/null @@ -1,434 +0,0 @@ -# mdutils -![Build Status](https://github.com/didix21/mdutils/actions/workflows/main.yml/badge.svg) -[![Documentation Status](https://readthedocs.org/projects/mdutils/badge/?version=latest)](http://mdutils.readthedocs.io/en/latest/?badge=latest) -[![codecov](https://codecov.io/gh/didix21/mdutils/branch/master/graph/badge.svg?token=0DN72Z1B6V)](https://codecov.io/gh/didix21/mdutils) - -Table of Contents -================= -- [Overview](#overview) -- [Features](#features) - - [Writing and Reading Files](#writing-and-reading-files) - - [Markdown](#markdown) -- [Installation](#installation) -- [Markdown File Example](#markdown-file-example) - -Overview -======= -This Python package contains a set of basic tools that can help to create a markdown file while running a Python code. -Thus, if you are executing a Python code and you save the result in a text file, Why not format it? So -using files such as Markdown can give a great look to those results. In this way, mdutils will make things easy for -creating Markdown files. - -- Project Homepage: https://github.com/didix21/mdutils -- Download Page: https://pypi.python.org/pypi/mdutils -- Documentation: http://mdutils.readthedocs.io/en/latest/ - -MIT License, (C) 2018 Dídac Coll - -Features -======== -These are the following available features: - -Writing and Reading Files -------------------------- -- Write and Read Markdown files. -- Append data to the end of a Markdown file. -- Use markers to place text. - -Markdown --------- -- Implemented method to give format to the text: **bold**, _italics_, change color... -- Align text. -- Add headers of levels 1 til 6 (atx style) or 1 and 2 (setext style). -- Create tables. -- Create a table of contents. -- Add Links. -- Add Lists. -- Add Markdown Images. -- Add Html Images. - -**NOTE:** some available features will depend on which CSS you are using. For example, GitHub does not allow to give color to text. - -Installation -============ - -Pip ---- -Use pip to install mdutils: -```bash -$ pip install mdutils -``` - -Poetry ------- -Use poetry to install mdutils: -```bash -$ poetry add mdutils -``` - -Markdown File Example -===================== - -Contents -======== - -* [Overview](#overview) -* [This is what you can do](#this-is-what-you-can-do) - * [Create Markdown files](#create-markdown-files) - * [Create Headers](#create-headers) - * [Table of Contents](#table-of-contents) - * [Paragraph and Text Format](#paragraph-and-text-format) - * [Create a Table](#create-a-table) - * [Create Links](#create-links) - * [Create Lists](#create-lists) - * [Add images](#add-images) - * [Add HTML images](#add-html-images) - -# Overview - - -This is an example of a markdown file created using the mdutils python package. In this example you are going to see how to create a markdown file using this library. Moreover, you're finding the available features which makes easy the creation of this type of files while you are running Python code. - -**IMPORTANT:** some features available in this library have no effect with the GitHub Markdown CSS. Some of them are: coloring text, centering text... - - - -# This is what you can do - -## Create Markdown files - - -Using the `MdUtils` class, we can define a new Markdown object by specifying its filename and optionally it's title and author. The filename is used as the path for creating the the Markdown file. From here, Markdown syntax can be created using the provided methods in the `MdUtils` class (see below for examples). Finally, `create_md_file()` is called to create the file at the specified path. - - -```python -from mdutils.mdutils import MdUtils - - -mdFile = MdUtils(file_name='Example_Markdown',title='Markdown File Example') -# Additional Markdown syntax... -mdFile.create_md_file() -``` - -## Create Headers - - -Using the ``new_header`` method you can create headers of different levels depending on the style. There are two available styles: 'atx' and 'setext'. The first one has til 6 different header levels. Atx's levels 1 and 2 are automatically added to the table of contents unless the parameter ``add_table_of_contents`` is set to 'n'. The 'setext' style only has two levels of headers. - -```python -mdFile.new_header(level=1, title='Atx Header 1') -mdFile.new_header(level=2, title='Atx Header 2') -mdFile.new_header(level=3, title='Atx Header 3') -mdFile.new_header(level=4, title='Atx Header 4') -mdFile.new_header(level=5, title='Atx Header 5') -mdFile.new_header(level=6, title='Atx Header 6') -``` - -To give a header an ID (Extended Markdown syntax only), the `header_id` parameter can be used: -```python -mdFile.new_header(level=1, title='Header', header_id='firstheader') -``` -This will result in ``# Header {#firstheader}`` in the Markdown file. - -# Atx Header 1 - -## Atx Header 2 - -### Atx Header 3 - -#### Atx Header 4 - -##### Atx Header 5 - -###### Atx Header 6 - - -```python -mdFile.new_header(level=1, title='Setext Header 1', style='setext') -mdFile.new_header(level=2, title='Setext Header 2', style='setext') -``` -Setext Header 1 -=============== - -Setext Header 2 ---------------- - - - -## Table of Contents - - -If you have defined some headers of level 1 and 2, you can create a table of contents invoking the following command (Normally, the method will be called at the end of the code before calling ``create_md_file()``) - -```python -mdFile.new_table_of_contents(table_title='Contents', depth=2) -``` -## Paragraph and Text Format - - -mdutils allows you to create paragraphs, line breaks or simply write text: -### New Paragraph Method - - -```python -mdFile.new_paragraph("Using ``new_paragraph`` method you can very easily add a new paragraph" - " This example of paragraph has been added using this method. Moreover," - "``new_paragraph`` method make your live easy because it can give format" - " to the text. Lets see an example:") -``` - -Using ``new_paragraph`` method you can very easily add a new paragraph on your markdown file. This example of paragraph has been added using this method. Moreover, ``new_paragraph`` method makes your live easy because it can give format to the text. Lets see an example: - -```python -mdFile.new_paragraph("This is an example of text in which has been added color, bold and italics text.", bold_italics_code='bi', color='purple') -``` - -***This is an example of text in which has been added color, bold and italics text.*** -### New Line Method - - -``mdutils`` has a method which can create new line breaks. Lets see it. - -```python -mdFile.new_line("This is an example of line break which has been created with ``new_line`` method.") -``` -This is an example of line break which has been created with ``new_line`` method. - -As ``new_paragraph``, ``new_line`` allows users to give format to text using ``bold_italics_code`` and ``color`` parameters: - -```python -mdFile.new_line("This is an inline code which contains bold and italics text and it is centered", bold_italics_code='cib', align='center') -``` -***
``This is an inline code which contains bold and italics text and it is centered``
*** -### Write Method - - -``write`` method writes text in a markdown file without jump lines ``'\n'`` and as ``new_paragraph`` and ``new_line``, you can give format to text using the arguments ``bold_italics_code``, ``color`` and ``align``: - -```python -mdFile.write("The following text has been written with ``write`` method. You can use markdown directives to write:" - "**bold**, _italics_, ``inline_code``... or ") -mdFile.write("use the following available parameters: \n") -``` - -The following text has been written with ``write`` method. You can use markdown directives to write: **bold**, _italics_, ``inline_code``... or use the following available parameters: - - -```python -mdFile.write(' \n') -mdFile.write('bold_italics_code', bold_italics_code='bic') -mdFile.write(' \n') -mdFile.write('Text color', color='green') -mdFile.write(' \n') -mdFile.write('Align Text to center', align='center') -``` -***``bold_italics_code``*** -Text color -
Align Text to center
- -## Create a Table - - -The library implements a method called ``new_table`` that can create tables using a list of strings. This method only needs: the number of rows and columns that your table must have. Optionally you can align the content of the table using the parameter ``text_align`` - -```python -list_of_strings = ["Items", "Descriptions", "Data"] -for x in range(5): - list_of_strings.extend(["Item " + str(x), "Description Item " + str(x), str(x)]) -mdFile.new_line() -mdFile.new_table(columns=3, rows=6, text=list_of_strings, text_align='center') -``` - -|Items|Descriptions|Data| -| :---: | :---: | :---: | -|Item 0|Description Item 0|0| -|Item 1|Description Item 1|1| -|Item 2|Description Item 2|2| -|Item 3|Description Item 3|3| -|Item 4|Description Item 4|4| - -## Create Links - -### Create inline links - - -``new_inline_link`` method allows you to create a link of the style: ``[mdutils](https://github.com/didix21/mdutils)``. - - -Moreover, you can add bold, italics or code in the link text. Check the following examples: - - -```python -mdFile.new_line(' - Inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils', text='mdutils')) -mdFile.new_line(' - Bold inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils', text='mdutils', bold_italics_code='b')) -mdFile.new_line(' - Italics inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils', text='mdutils', bold_italics_code='i')) -mdFile.new_line(' - Code inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils', text='mdutils', bold_italics_code='i')) -mdFile.new_line(' - Bold italics code inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils', text='mdutils', bold_italics_code='cbi')) -mdFile.new_line(' - Another inline link: ' + mdFile.new_inline_link(link='https://github.com/didix21/mdutils')) -``` - - Inline link: [mdutils](https://github.com/didix21/mdutils) - - Bold inline link: [**mdutils**](https://github.com/didix21/mdutils) - - Italics inline link: [*mdutils*](https://github.com/didix21/mdutils) - - Code inline link: [``mdutils``](https://github.com/didix21/mdutils) - - Bold italics code inline link: [***``mdutils``***](https://github.com/didix21/mdutils) - - Another inline link: [https://github.com/didix21/mdutils](https://github.com/didix21/mdutils) -### Create reference links - - -``new_reference_link`` method allows you to create a link of the style: ``[mdutils][1]``. All references will be added at the end of the markdown file automatically as: - - -```python -[1]: https://github.com/didix21/mdutils -``` - -Lets check some examples: - - -```python -mdFile.write('\n - Reference link: ' + mdFile.new_reference_link(link='https://github.com/didix21/mdutils', text='mdutils', reference_tag='1')) -mdFile.write('\n - Reference link: ' + mdFile.new_reference_link(link='https://github.com/didix21/mdutils', text='another reference', reference_tag='md')) -mdFile.write('\n - Bold link: ' + mdFile.new_reference_link(link='https://github.com/didix21/mdutils', text='Bold reference', reference_tag='bold', bold_italics_code='b')) -mdFile.write('\n - Italics link: ' + mdFile.new_reference_link(link='https://github.com/didix21/mdutils', text='Bold reference', reference_tag='italics', bold_italics_code='i')) -``` - - Reference link: [mdutils][1] - - Reference link: [another reference][md] - - Bold link: [**Bold reference**][bold] - - Italics link: [*Italics reference*][italics] -## Create Lists - -### Create unordered lists - - -You can add Markdown unordered list using ``mdFile.new_list(items, marked_with)``. Lets check an example: - -``` -items = ['Item 1', 'Item 2', 'Item 3', 'Item 4', ['Item 4.1', 'Item 4.2', ['Item 4.2.1', 'Item 4.2.2'], 'Item 4.3', ['Item 4.3.1']], 'Item 5'] -mdFile.new_list(items) -``` -- Item 1 -- Item 2 -- Item 3 -- Item 4 - - Item 4.1 - - Item 4.2 - - Item 4.2.1 - - Item 4.2.2 - - Item 4.3 - - Item 4.3.1 -- Item 5 - -### Create ordered lists - - -You can add ordered ones easily, too: ``mdFile.new_list(items, marked_with='1')`` -1. Item 1 -2. Item 2 -3. Item 3 -4. Item 4 - 1. Item 4.1 - 2. Item 4.2 - 1. Item 4.2.1 - 2. Item 4.2.2 - 3. Item 4.3 - 1. Item 4.3.1 -5. Item 5 - - -Moreover, you can add mixed list, for example: - -``` -items = ['Item 1', 'Item 2', ['1. Item 2.1', '2. Item 2.2'], 'Item 3'] -mdFile.new_list(items) -``` -- Item 1 -- Item 2 - 1. Item 2.1 - 2. Item 2.2 -- Item 3 - - -Maybe you want to replace the default hyphen ``-`` by a ``+`` or ``*`` then you can do: ``mdFile.new_list(items, marked_with='*')``. -### Create checkbox lists - - -For creating checkbox lists you can use ``mdFile.new_checkbox_list(items)``. -- [ ] Item 1 -- [ ] Item 2 - - [ ] Item 2.1 - - [ ] Item 2.2 -- [ ] Item 3 - - -If you want to check all of them you can do: ``mdFile.new_checkbox_list(items, checked=True)`` -- [x] Item 1 -- [x] Item 2 - - [x] Item 2.1 - - [x] Item 2.2 -- [x] Item 3 - - -Or maybe you only want to check some of them, then you can add an ``x`` before each item that you want to check: - -``` -['Item 1', 'Item 2', ['Item 2.1', 'x Item 2.2'], 'x Item 3'] -mdFile.new_checkbox_list(items) -``` -- [ ] Item 1 -- [ ] Item 2 - - [ ] Item 2.1 - - [x] Item 2.2 -- [x] Item 3 - -## Add images - -### Inline Images - - -You can add inline images using ``new_inline_image`` method. Method will return: ``[image](../path/to/your/image.png)``. Check the following example: - -``` -mdFile.new_line(mdFile.new_inline_image(text='snow trees', path='./doc/source/images/photo-of-snow-covered-trees.jpg')) -``` -![snow trees](./doc/source/images/photo-of-snow-covered-trees.jpg) -### Reference Images - - -You can add inline images using ``new_reference_image`` method. Method will return: ``[image][im]``. Check the following example: - -``` -mdFile.new_line(mdFile.new_reference_image(text='snow trees', path='./doc/source/images/photo-of-snow-covered-trees.jpg', reference_tag='im')) -``` -![snow trees][im] -## Add HTML images - -### Change size to images - - -With ``Html.image`` you can change size of images in a markdown file. For example you can dothe following for changing width: ``mdFile.new_paragraph(Html.image(path=path, size='200'))`` - - - -Or maybe only want to change height: ``mdFile.new_paragraph(Html.image(path=path, size='x300'))`` - - - -Or change width and height: ``mdFile.new_paragraph(Html.image(path=path, size='300x300'))`` - - - -### Align images - - -Html.image allow to align images, too. For example you can run: ``mdFile.new_paragraph(Html.image(path=path, size='300x200', align='center'))`` - -

- -

- - -[1]: https://github.com/didix21/mdutils -[bold]: https://github.com/didix21/mdutils -[im]: ./doc/source/images/photo-of-snow-covered-trees.jpg -[italics]: https://github.com/didix21/mdutils -[md]: https://github.com/didix21/mdutils diff --git a/mdutils/mdutils.py b/mdutils/mdutils.py index 991d4af..0d51703 100644 --- a/mdutils/mdutils.py +++ b/mdutils/mdutils.py @@ -152,6 +152,8 @@ def __add_new_item_table_of_content(self, level: int, item: Union[List[str], str curr = self._table_titles for i in range(level - 1): + if not curr or len(curr) == 0: + curr.append([]) curr = curr[-1] curr.append(item)