Coder Social home page Coder Social logo

mdrec's Introduction

MDRec : Markdown Recorder from python

Current version on PyPI MIT License

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

Installation

pip install mdrec

Example

Here is example code, output result and raw_file respectively.

Code

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

sample

<end>

Raw

#### 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

mdrec's People

Contributors

knknkn1162 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

mdrec's Issues

comprehensive test on component.link

Test component.link comprehensively in that

  1. links
  • check url link
  • check link of local file with designated local markdown file.
  1. images
  • check images with file copy or not <= `copy = True/False'
  • check images with file not found. <= `ignore = True/False'
  • check images with designated local markdown file <= md_dir option

MDRec :ModuleNotFoundError after `pip install mdrec`

After registering mdrec in PyPI and running pip install mdrec,

$ python
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MDRec
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MDRec'

Maybe this is because python setup.py sdist is executed while not copying mdrec.py. see also #53.

twine upload dist/* error

while running twine upload dist/*, the problem occurs:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading mdrec-0.1-py3-none-any.whl
HTTPError: 400 Client Error: classifiers: 'Framework:: IPython' is not a valid choice for this field for url: https://upload.pypi.org/legacy/

refactor MDRec._save

MDRec.counter is redundant. We need only MDRec.refresh, if MDRec._save is refactored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.