Skip to content
This repository was archived by the owner on Nov 30, 2025. It is now read-only.

matthewdeanmartin/markmodule

Repository files navigation

markmodule

Import python from markdown files.

tests pre-commit.ci status Downloads Python Version Release

Archived

This is more of a novelty than anything. Markdown is a middle area between jupyter notebooks and .py files.

Maybe I'll unarchive it again someday if I get interested in that sort of "literate" programming again.

Usage

In a file named hello_module.md define a function. I'm escaping the fence, use a real three-tick fence.

Here is a function

``(`)python
def hello() -> str:
    return "Hello"
``(`) 

Generate a type stub and import using the usual syntax. generate_side_by_side_pyi will write a .pyi file to the file system and enable IDEs type hinting to work.

import sys
import markmodule
markmodule.generate_side_by_side_pyi("hello_module")
sys.meta_path.append(markmodule.MdFinder())
import hello_module
print(hello_module.hello())

Import with path to file.

import markmodule
markmodule.import_md("hello_module.md")
import hello_module
print(hello_module.hello())

Markdown is a hammer, everything is a nail

You can use markdown:

  • as a place to put module code, markmodule, this library

The do-everything-with-markdown ecosystem is surprisingly robust.

Change Log

  • 0.1.0 - Basic idea.
  • 0.2.0 - Updates to readme
  • 0.3.0 - Generates pyi and you can use import syntax

Documentation

About

Import python from markdown files.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors