Skip to main content

Convert plain text files to Markdown with automatic heading, list and code detection

Project description

txt2md-cli

PyPI version Python 3.8+ License: MIT GitHub

Convert plain text files to Markdown with automatic heading, list, and code detection — one command, no config.


The Problem

You have a .txt file full of notes, documentation, or exported content and want to quickly turn it into clean Markdown without manually adding #, -, or backticks everywhere. txt2md does this heuristically with zero configuration.


Installation

pip install txt2md-cli

Requires Python 3.8+. No external dependencies — only Python stdlib.


Usage

CLI

txt2md input.txt output.md

Python API

from txt2md_cli import convert_file, line_to_md

# Convert a full file
convert_file("notes.txt", "notes.md")

# Convert a single line
print(line_to_md("INTRODUCTION"))      # → # Introduction
print(line_to_md("- item one"))        # → - item one
print(line_to_md("some/path/file"))    # → `some/path/file`
print(line_to_md("Normal sentence."))  # → Normal sentence.

Detection Rules

Applied in order to each line:

Rule Condition Output
Heading ALL-CAPS, ≤60 chars, no period # Title Case
Bullet list Starts with - or * Preserved as-is
Numbered list Starts with 1., 2., etc. Preserved as-is
Inline code >10 chars, <2 spaces `text`
Paragraph Everything else Plain text

Example

Input (notes.txt):

INTRODUCTION

This is a normal paragraph with some text.

- First item
- Second item

1. Step one
2. Step two

/usr/local/bin/python3

CONCLUSION

Output (notes.md):

# Introduction

This is a normal paragraph with some text.

- First item
- Second item

1. Step one
2. Step two

`/usr/local/bin/python3`

# Conclusion

License

MIT © Santt997

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

txt2md_cli-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

txt2md_cli-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file txt2md_cli-0.1.0.tar.gz.

File metadata

  • Download URL: txt2md_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for txt2md_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae6ec361f71080917ee278b7dc3b458d5210109d330cf94c430bc8b81a1efec1
MD5 551ec5579622415d21594269b1c53c2a
BLAKE2b-256 23e5ca2fa932d590307a0c0cf5a6e10b5e435f914eeca74dce943ac6c30d43e1

See more details on using hashes here.

File details

Details for the file txt2md_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: txt2md_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for txt2md_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f15a0546adb2b73eefe1835ab3b272f28b3b378329281064dc938a133569c2a4
MD5 88212fe4208a8e4de548259dc11ada8b
BLAKE2b-256 3065be4e05b72414b6635eb00e5cc860dc01b0106ef682d6b0d69a7a486f6236

See more details on using hashes here.

Supported by

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