Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change log
All notable changes to this project will be documented in this file.

## [v1.0.0](https://github.com/didix21/mdutils/tree/v1.0.0)
Released on 2018-05-11.

#### Added
- Initial release of mdutils.
- Added by [didix21](https://github.com/didix21).
82 changes: 81 additions & 1 deletion doc/source/examples/Example_Markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Contents
* [Table of Contents](#table-of-contents)
* [Paragraph and Text Format](#paragraph-and-text-format)
* [Create a Table](#create-a-table)

* [Create Links](#create-links)
* [Add images](#add-images)

# Overview


Expand Down Expand Up @@ -164,3 +166,81 @@ mdFile.new_table(columns=3, rows=6, text=list_of_strings, text_align='center')
|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]
## 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='../images/photo-of-snow-covered-trees.jpg'))
```
![snow trees](../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='../images/photo-of-snow-covered-trees.jpg', reference_tag='im'))
```
![snow trees][im]


[1]: https://github.com/didix21/mdutils
[bold]: https://github.com/didix21/mdutils
[im]: ../images/photo-of-snow-covered-trees.jpg
[italics]: https://github.com/didix21/mdutils
[md]: https://github.com/didix21/mdutils
89 changes: 88 additions & 1 deletion doc/source/examples/Example_Python.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,95 @@
mdFile.new_line()
mdFile.new_table(columns=3, rows=6, text=list_of_strings, text_align='center')

# ********************************************************************************************************************
# ************************************************** Create Link *****************************************************
# ********************************************************************************************************************

mdFile.new_header(2, "Create Links")

# *********************************************** Inline link ********************************************************

mdFile.new_header(3, "Create inline links")

link = "https://github.com/didix21/mdutils"
text = "mdutils"

mdFile.new_paragraph("``new_inline_link`` method allows you to create a link of the style: "
"``[mdutils](https://github.com/didix21/mdutils)``.\n")
mdFile.new_paragraph("Moreover, you can add bold, italics or code in the link text. Check the following examples: \n")

mdFile.insert_code("mdFile.new_line(' - Inline link: '"
" + mdFile.new_inline_link(link='{}', text='{}')) \n".format(link, text) +
"mdFile.new_line(' - Bold inline link: ' "
"+ mdFile.new_inline_link(link='{}', text='{}', bold_italics_code='b') \n".format(link, text) +
"mdFile.new_line(' - Italics inline link: ' "
"+ mdFile.new_inline_link(link='{}', text='{}', bold_italics_code='i') \n".format(link, text) +
"mdFile.new_line(' - Code inline link: ' "
"+ mdFile.new_inline_link(link='{}', text='{}', bold_italics_code='i') \n".format(link, text) +
"mdFile.new_line(' - Bold italics code inline link: ' "
"+ mdFile.new_inline_link(link='{}', text='{}', bold_italics_code='cbi') \n".format(link, text) +
"mdFile.new_line(' - Another inline link: ' + mdFile.new_inline_link(link='{}') \n".format(link),
language='python')

mdFile.new_line(' - Inline link: ' + mdFile.new_inline_link(link=link, text=text))
mdFile.new_line(' - Bold inline link: ' + mdFile.new_inline_link(link=link, text=text, bold_italics_code='b'))
mdFile.new_line(' - Italics inline link: ' + mdFile.new_inline_link(link=link, text=text, bold_italics_code='i'))
mdFile.new_line(' - Code inline link: ' + mdFile.new_inline_link(link=link, text=text, bold_italics_code='c'))
mdFile.new_line(' - Bold italics code inline link: ' + mdFile.new_inline_link(link=link, text=text, bold_italics_code='cbi'))
mdFile.new_line(' - Another inline link: ' + mdFile.new_inline_link(link=link))

# *********************************************** Reference link ******************************************************
mdFile.new_header(3, "Create reference links")

mdFile.new_paragraph("``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: \n")

mdFile.insert_code("[1]: https://github.com/didix21/mdutils", language="python")
mdFile.new_paragraph("Lets check some examples: \n")

link="https://github.com/didix21/mdutils"

mdFile.insert_code("mdFile.write('\\n - Reference link: ' "
"+ mdFile.new_reference_link(link='{}', text='mdutils', reference_tag='1')\n".format(link) +
"mdFile.write('\\n - Reference link: ' "
"+ mdFile.new_reference_link(link='{}', text='another reference', reference_tag='md')\n".format(link) +
"mdFile.write('\\n - Bold link: ' "
"+ mdFile.new_reference_link(link='{}', text='Bold reference', reference_tag='bold', bold_italics_code='b')\n".format(link) +
"mdFile.write('\\n - Italics link: ' "
"+ mdFile.new_reference_link(link='{}', text='Bold reference', reference_tag='italics', bold_italics_code='i')\n".format(link),
language="python")

mdFile.write("\n - Reference link: " + mdFile.new_reference_link(link=link, text='mdutils', reference_tag='1'))
mdFile.write("\n - Reference link: " + mdFile.new_reference_link(link=link, text='another reference', reference_tag='md'))
mdFile.write("\n - Bold link: " + mdFile.new_reference_link(link=link, text='Bold reference', reference_tag='bold', bold_italics_code='b'))
mdFile.write("\n - Italics link: " + mdFile.new_reference_link(link=link, text='Italics reference', reference_tag='italics', bold_italics_code='i'))

# ********************************************************************************************************************
# ************************************************** Add Images ******************************************************
# ********************************************************************************************************************

mdFile.new_header(2, "Add images")

# *********************************************** Inline Image *******************************************************

image_text="snow trees"
path="../images/photo-of-snow-covered-trees.jpg"

mdFile.new_header(3, "Inline Images")

mdFile.new_paragraph("You can add inline images using ``new_inline_image`` method. Method will return: "
"``[image](../path/to/your/image.png)``. Check the following example: ")
mdFile.insert_code("mdFile.new_line(mdFile.new_inline_image(text='{}', path='{}'))".format(image_text, path))
mdFile.new_line(mdFile.new_inline_image(text=image_text, path=path))

# *********************************************** Reference Image *****************************************************
mdFile.new_header(3, "Reference Images")
mdFile.new_paragraph("You can add inline images using ``new_reference_image`` method. Method will return: "
"``[image][im]``. Check the following example: ")
mdFile.insert_code("mdFile.new_line(mdFile.new_reference_image(text='{}', path='{}', reference_tag='im'))".format(image_text, path))
mdFile.new_line(mdFile.new_reference_image(text=image_text, path=path, reference_tag='im'))

# Create a table of contents
mdFile.new_table_of_contents(table_title='Contents', depth=2)

mdFile.create_md_file()

Binary file added doc/source/images/photo-of-snow-covered-trees.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mdutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from mdutils.mdutils import MdUtils
from mdutils.fileutils import fileutils
from mdutils.tools import tools
from mdutils.tools import Header, Link, Image, TextUtils, Table, TableOfContents
Loading