Mdut: a tool for generating Markdown URL tags

Related tags

Markdown/YAML mdut
Overview

mdut

mdut (pronounced "em-doot") is a tool for generating Markdown URL tags. It ships as both a standalone command-line program and Python library.

Examples

Command-line program:

# reference style is default
$ mdut https://example.com
Copied to clipboard:
[TODO]: https://example.com "Example Domain"

$ mdut -s inline https://example.com
Copied to clipboard:
[TODO](https://example.com "Example Domain")

Python library:

>>> import mdut
>>> mdut.reference("https://example.com")
'[TODO]: https://example.com "Example Domain"'
>>> mdut.inline("https://example.com")
'[TODO](https://example.com "Example Domain")'

Installation

If you plan on using mdut on the command-line, you're probably best off installing it via pipx, like so:

pipx install mdut

However, if you plan on using mdut as a library in your project, you should probably install it the same way as your other dependencies, for example via pip, Poetry, Pipenv, etc.

# pip
pip install mdut

# Poetry
poetry add mdut

# Pipenv
pipenv install mdut
You might also like...
Convert HTML to Markdown-formatted text.

html2text html2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to

Comprehensive Markdown plugin built for Django
Comprehensive Markdown plugin built for Django

Django MarkdownX Django MarkdownX is a comprehensive Markdown plugin built for Django, the renowned high-level Python web framework, with flexibility,

Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!

markdown-it-py Markdown parser done right. Follows the CommonMark spec for baseline parsing Configurable syntax: you can add new rules and even replac

A fast, extensible and spec-compliant Markdown parser in pure Python.

mistletoe mistletoe is a Markdown parser in pure Python, designed to be fast, spec-compliant and fully customizable. Apart from being the fastest Comm

Livemark is a static page generator that extends Markdown with interactive charts, tables, and more.

Livermark This software is in the early stages and is not well-tested Livemark is a static site generator that extends Markdown with interactive chart

A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.
A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

Remarkable Markdown Debian Package Fix

Remarkable debian package fix For some reason the Debian package for remarkable markdown editor has not been made to install properly on Ubuntu 20.04

Read a list in markdown and do something with it!

Markdown List Reader A simple tool for reading lists in markdown. Usage Begin by running the mdr.py file and input either a markdown string with the -

Comments
  • Handle httpx errors better

    Handle httpx errors better

    Some helpful error messages would be lovely, as currently they all just fall right through, like so:

    ❯ poetry run python src/mdut.py foo://bar
    Traceback (most recent call last):
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
        yield
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 187, in handle_request
        resp = self._pool.handle_request(req)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
        raise UnsupportedProtocol(
    httpcore.UnsupportedProtocol: Request URL has an unsupported protocol 'foo://'.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 68, in <module>
        mdut()
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
        return __callback(*args, **kwargs)
      File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 61, in mdut
        tag = markdown_url_tag(url, style)
      File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 39, in markdown_url_tag
        html = fetch_html(url)
      File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 20, in fetch_html
        return httpx.get(url).text
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_api.py", line 189, in get
        return request(
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_api.py", line 100, in request
        return client.request(
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 802, in request
        return self.send(request, auth=auth, follow_redirects=follow_redirects)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 889, in send
        response = self._send_handling_auth(
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 917, in _send_handling_auth
        response = self._send_handling_redirects(
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 954, in _send_handling_redirects
        response = self._send_single_request(request)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 990, in _send_single_request
        response = transport.handle_request(request)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 186, in handle_request
        with map_httpcore_exceptions():
      File "/opt/homebrew/Cellar/[email protected]/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
        self.gen.throw(typ, value, traceback)
      File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
    httpx.UnsupportedProtocol: Request URL has an unsupported protocol 'foo://'.
    
    enhancement 
    opened by nkantar 2
  • copy shortcut

    copy shortcut

    as a user: i want to see a link and press a special keyboard shortcut to activate mdut and copy the link, then go to my .md and paste it in there with all the syntax

    wontfix 
    opened by kirkkwang 1
  • Whitespace in titles can create problems

    Whitespace in titles can create problems

    URL: https://www.yamahamotorsports.com/sport-heritage/models/2018/xsr700 Example output:

    $ mdut -s reference https://www.yamahamotorsports.com/sport-heritage/models/2018/xsr700
    Copied to clipboard:
    [TODO]: https://www.yamahamotorsports.com/sport-heritage/models/2018/xsr700 "
    	
        2018 Yamaha XSR700 Sport Heritage Motorcycle - Model Home
    
    "
    
    bug 
    opened by nkantar 0
  • Add piping support + rethink copying

    Add piping support + rethink copying

    Currently mdut CLI puts the result into the system clipboard, which is super handy.

    However, it may make more sense for it to just pipe it to stdout, and have a -c flag for copying as well, or even do that by default.

    enhancement 
    opened by nkantar 0
Owner
Nik Kantar
Programmer, Python lover, Vim user, Mordor ditch digger, cat person, @Hufflepumpkinspice’s, he/him, et al.
Nik Kantar
Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files

Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. Mdformat is a Unix-style command-line tool as well as a Python library.

Executable Books 180 Jan 6, 2023
A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

stonepresto 4 Aug 13, 2022
Toci is a markdown tool to generate an outline from a given Jupyter notebook.

Toci is a markdown tool to generate an outline from a given Jupyter notebook. It traverses the markdown cells of a given ipynb file to form a toc for you.

Hakan Özler 7 Jan 22, 2022
A command line tool that can convert Day One data into markdown files.

Introduction Features Before Start Export data from Day One Check Integrity Special Cases for Photo Extension Name Audio Extension Name Usage Known Is

gyro永不抽风 26 Dec 31, 2022
A fast yet powerful Python Markdown parser with renderers and plugins.

Mistune v2 A fast yet powerful Python Markdown parser with renderers and plugins. NOTE: This is the re-designed v2 of mistune. Check v1 branch for ear

Hsiaoming Yang 2.2k Jan 4, 2023
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 30, 2022
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 31, 2022
Static site generator that supports Markdown and reST syntax. Powered by Python.

Pelican Pelican is a static site generator, written in Python. Write content in reStructuredText or Markdown using your editor of choice Includes a si

Pelican dev team 11.3k Jan 5, 2023
Extensions for Python Markdown

PyMdown Extensions Extensions for Python Markdown. Documentation Extension documentation is found here: https://facelessuser.github.io/pymdown-extensi

Isaac Muse 685 Jan 1, 2023
markdown2: A fast and complete implementation of Markdown in Python

Markdown is a light text markup format and a processor to convert that to HTML. The originator describes it as follows: Markdown is a text-to-HTML con

Trent Mick 2.4k Dec 30, 2022