Skip to main content

record python object to markdown file & convert to html.

Project description

# MDRec : Markdown Recorder from python

[![Current version on PyPI](http://img.shields.io/pypi/v/mdrec.svg)](PyPI)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)

MDRec creates markdown file easily from python object.
You can also convert this to html file at once.


## Installation

```bash
pip install mdrec
```

## Example

Here is example code, output result and raw_file respectively.

### Code

```python
from mdrec import MDRec

save_file = "./out/test_txt.md"
# set markdown file. (You may also try not to set this option.)
r = MDRec(save_file=save_file)

# suppoort header. write "#### testtest\n\n" in designated save_file.
r.rec("testtest", h=4)

# plain txt
r.rec("this is example below")

# express itemization via Iterable object
r.rec([1,2,3])

# draw vertical line
r.line()

# support ja
r.rec(["あ", "い", "う", {"え" : "お"}])

# you should draw a vertical line explicitly
r.line()

# support nested list, dict or Iterable.
r.rec([1,[1,2],[2,[3],4], [{"a": 100, "b": 234}], {"c" : [3,4,5]}])

## support quote
r.increase_quote_level()
## If you set raw option to be False, suppress markdown output in jupyter notebook.
r.rec("testtest", h=2, raw=False)

r.increase_quote_level()
r.rec(["z", 'x'])

r.reset_quote_level()

from pandas import DataFrame
# support DataFrame or Series ((NOT support list of list)
df = DataFrame([[12, 2, 4, 3], [3, 3, 3, 4]], columns=list("abcd"), index=["AB", "BB"])

# display table with title
r.rec(df, title="test", h=3)

# set link. support both url and local file path.
r.link(src="./test01.png", title="test", text="sample")

# image link with markdown syntax. To display image in jupyter notebook syncronously, set copy_sync=True
r.img(src="./test01.png", title="test", text="sample", copy_sync=True)

# export markdown file to html via github API. (You can set your username and password in ~/.grip/settings.py.)
r.to_html()
```

### Output

`<start>`

#### testtest

this is example below

- 1
- 2
- 3

---

- あ
- い
- う
- え: お

---

- 1
- - 1
- 2
- - 2
- - 3
- 4
- - a: 100
b: 234
- c:
- 3
- 4
- 5

> ## testtest
>
>> - z
>> - x
>>
### test
| | a | b | c | d |
|---|----:|----:|----:|----:|
|AB | 12| 2| 4| 3|
|BB | 3| 3| 3| 4|


[sample](../test01.png "test")

![sample](img/test01.png "test")



`<end>`

### Raw

```markdown
#### testtest

this is example below

- 1
- 2
- 3

---

- あ
- い
- う
- え: お

---

- 1
- - 1
- 2
- - 2
- - 3
- 4
- - a: 100
b: 234
- c:
- 3
- 4
- 5

> ## testtest
>
>> - z
>> - x
>>
### test
| | a | b | c | d |
|---|----:|----:|----:|----:|
|AB | 12| 2| 4| 3|
|BB | 3| 3| 3| 4|


[sample](../test01.png "test")

![sample](img/test01.png "test")
```

## Usage

+ By default, results are also displayed in jupyter notebook, so if you switch off the option, let `r.rec(obj, raw=False)`.

## Configuration

+ If you use `MDRec.to_html`, note that this call [Grip](https://github.com/joeyespo/grip) and github API implicitly. To set github username and password, see the link, https://github.com/joeyespo/grip#configuration.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdrec-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

mdrec-0.1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file mdrec-0.1.1.tar.gz.

File metadata

  • Download URL: mdrec-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mdrec-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3875091cb54c44755eb2f610a3248581d903d05e528f3ac5e500e208b245a8c7
MD5 75eb9a09394822f31750c9ad2a1ef247
BLAKE2b-256 27c5a81856b5d0f20b0f7f2c7fe7d6661c05e137e2d054fd19207f736a3f7b8b

See more details on using hashes here.

File details

Details for the file mdrec-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mdrec-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 689eb4dcb95bbac655f7fdf3b9a85f12043379f947b548497cece4081e0cb7a4
MD5 e37605d7bada269a49244332462f32a3
BLAKE2b-256 9304f818508dafd50cf6c0a9f74f8c36e7e16c67f8d66d94b2810acc9f643ce8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page