Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files

Overview

Documentation Status Build Status codecov.io PyPI version

mdformat

CommonMark compliant Markdown formatter

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.

Find out more in the docs.

Installing

Install with CommonMark support:

pip install mdformat

Alternatively install with GitHub Flavored Markdown (GFM) support:

pip install mdformat-gfm

Or with Markedly Structured Text (MyST) support:

pip install mdformat-myst

Command line usage

Format files

Format files README.md and CHANGELOG.md in place

mdformat README.md CHANGELOG.md

Format .md files in current working directory recursively

mdformat .

Read Markdown from standard input until EOF. Write formatted Markdown to standard output.

mdformat -

Check formatting

mdformat --check README.md CHANGELOG.md

This will not apply any changes to the files. If a file is not properly formatted, the exit code will be non-zero.

Options

foo@bar:~$ mdformat --help
usage: mdformat [-h] [--check] [--version] [--number] [--wrap {keep,no,INTEGER}] [--end-of-line {lf,crlf}] [paths [paths ...]]

CommonMark compliant Markdown formatter

positional arguments:
  paths                 files to format

optional arguments:
  -h, --help            show this help message and exit
  --check               do not apply changes to files
  --version             show program's version number and exit
  --number              apply consecutive numbering to ordered lists
  --wrap {keep,no,INTEGER}
                        paragraph word wrap mode (default: keep)
  --end-of-line {lf,crlf}
                        output file line ending mode (default: lf)

Documentation

This README merely provides a quickstart guide for the command line interface. For more information refer to the documentation. Here's a few pointers to get you started:

Frequently Asked Questions

Why not use Prettier instead?

Mdformat is pure Python code! Python is pre-installed on macOS and virtually any Linux distribution, meaning that typically little to no additional installations are required to run mdformat. This argument also holds true when using together with pre-commit (also Python). Prettier on the other hand requires Node.js/npm.

Prettier suffers from numerous bugs, many of which cause changes in Markdown AST and rendered HTML. Many of these bugs are a consequence of using remark-parse v8.x as Markdown parser which, according to the author themselves, is inferior to markdown-it used by mdformat. remark-parse v9.x is advertised as CommonMark compliant and presumably would fix many of the issues, but is not used by Prettier (v2.3.1) yet.

Prettier (v2.3.1), being able to format many languages other than Markdown, is a large package with 65 direct dependencies (mdformat only has 2 in Python 3.8+). This can be a disadvantage in many environments, one example being size optimized Docker images.

Mdformat's parser extension plugin API allows not only customization of the Markdown specification in use, but also advanced features like automatic table of contents generation. Also provided is a code formatter plugin API enabling integration of embedded code formatting for any programming language.

What's wrong with the mdformat logo? It renders incorrectly and is just terrible in general.

Nope, the logo is actually pretty great – you're terrible. The logo is more a piece of art than a logo anyways, depicting the horrors of poorly formatted text documents. I made it myself!

That said, if you have any graphic design skills and want to contribute a revised version, a PR is more than welcome πŸ˜„ .

Comments
  • ✨ Add plugin system for extending the parser

    ✨ Add plugin system for extending the parser

    ~~This is not quite the finished product yet, but it outlines the basic functionality of what I'm looking to implement~~ now basically complete

    closes #13

    opened by chrisjsewell 18
  • ✨ Allow options to be updated on the `MarkdownIt` instance

    ✨ Allow options to be updated on the `MarkdownIt` instance

    This provides a hook for passing variables to the parsing/render process, which in-turn provides a simple way of allowing plugins to accept variable arguments from the API or CLI.

    ~~Note this is back-incompatible for parser plugins, since update_mdit now also gets passed this env dict.~~

    opened by chrisjsewell 14
  • Add `--end-of-line=native`

    Add `--end-of-line=native`

    Context

    I have a repo that uses mdformat as a pre-commit hook; it works beautifully on Linux and macOS.

    If I clone the repo on Windows, under Git's default settings (core.autocrlf = true), the Markdown files in the working tree have CRLF newlines. When the pre-commit hook runs, it replaces newlines with LF (as expected in the absence of --end-of-line). This leads to the confusing situation where:

    • pre-commit reports no errors, yet
    • after the commit, there remain unstaged changes (consisting of CRLF -> LF replacement).

    Specifying --end-of-line=crlf can fix this, but we would need to specify this on Windows only, and there is no way to do so in .pre-commit-config.yaml or .mdformat.toml, as far as I can tell.

    It is probably also possible to work around this using .gitattributes, but that adds more things to maintain.

    Proposal

    • Add the choice native, in addition to the current choices (lf, crlf), to the --end-of-line option.
      • And similarly to the end_of_line key of .mdformat.toml.
    • When --end-of-line=native is given, use the value of os.linesep to determine the newlines to use.
    • The default newline remains lf to maintain compatibility.

    The choice of the name native is bikesheddable (perhaps auto?).

    Tasks and updates

    • [x] Settle on a name (native, auto, or other)
    • [ ] Implement
    enhancement 
    opened by marktsuchida 13
  • Integrate with Markdown Linters

    Integrate with Markdown Linters

    I use a Markdown linter with pre-commit and GitLab CI pipelines. It's useful but I'd like to use a formatter before running the linter: one of the biggest problems I have is that, as well as raising rule violations that require manual correction, the linter frequently raises large numbers of trivial formatting rule violations that could very easily be corrected automatically by a formatter. If they are going to be coupled, it's really important that the formatter and linter work together and don't conflict. I would like to suggest that mdformat be designed from the beginning to integrate with Markdown linters, particularly markdownlint [1].

    I expect that this means mdformat will have to observe the markdownlint rules and the rule structure, to avoid creating linting conflicts. The advantage of this is that there's an existing structure and code (largely regexps) which can inform mdformat development.

    What do you think?

    [1] There are two Markdown linters I'm aware of: a Ruby version https://github.com/markdownlint/markdownlint and a node.js version: https://github.com/DavidAnson/markdownlint, both named "markdownlint" and the respective authors and maintainers work together to ensure that there is minimal divergence of rules between the two versions.

    enhancement 
    opened by jamesquilty 11
  • Support Admonitions

    Support Admonitions

    Describe the problem/need and solution

    Problem

    Right now, mdformat breaks indentation for admonitions. Below is a repeatable example based on the first snippet from the admonition documentation

    ~/Developer > pipx install mdformat-gfm --include-deps
      installed package mdformat-gfm 0.3.5, installed using Python 3.10.2
      These apps are now globally available
        - markdown-it
        - mdformat
    done! ✨ 🌟 ✨
    ~/Developer > pbpaste > ad_test.md
    ~/Developer > bat ad_test.md
    ───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
           β”‚ File: ad_test.md
    ───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       1   β”‚ !!! type "optional explicit title within double quotes"
       2   β”‚     Any number of other indented markdown elements.
       3   β”‚
       4   β”‚     This is the second paragraph.
    ───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ~/Developer > mdformat ad_test.md
    ~/Developer > bat ad_test.md
    ───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
           β”‚ File: ad_test.md
    ───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       1   β”‚ !!! type "optional explicit title within double quotes"
       2   β”‚ Any number of other indented markdown elements.
       3   β”‚
       4   β”‚ ```
       5   β”‚ This is the second paragraph.
       6   β”‚ ```
    ───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    

    Solution

    admonitions are not part of the CommonMark specification and would be best handled by a plugin (i.e. mdformat-admonition)

    I would be happy to try writing one, but I wanted to open an issue first so that I'm not duplicating effort. I saw that there was at least one other issue with admonition problems, but there didn't seem to be any updates since: #53 (https://github.com/executablebooks/mdformat/issues/53#issuecomment-928306196)

    Benefit

    Would be nice to have support for admonitions (particular for mkdocs which uses the markdown extension)

    Guide for implementation

    No response

    Tasks and updates

    No response

    enhancement plugin 
    opened by KyleKing 10
  • Links should not be

    Links should not be "resolved"

    Hmm, this is interesting. Running mdformat on:

    # mdformat-tables
    
    [![Build Status][ci-badge]][ci-link]
    [![codecov.io][cov-badge]][cov-link]
    [![PyPI version][pypi-badge]][pypi-link]
    
    An [mdformat](https://github.com/executablebooks/mdformat) plugin for rendering tables.
    
    [ci-badge]: https://github.com/executablebooks/mdformat-tables/workflows/CI/badge.svg?branch=master
    [ci-link]: https://github.com/executablebooks/mdformat/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush
    [cov-badge]: https://codecov.io/gh/executablebooks/mdformat-tables/branch/master/graph/badge.svg
    [cov-link]: https://codecov.io/gh/executablebooks/mdformat-tables
    [pypi-badge]: https://img.shields.io/pypi/v/mdformat-tables.svg
    [pypi-link]: https://pypi.org/project/mdformat-tables
    

    goes to

    # mdformat-tables
    
    [![Build Status](https://github.com/executablebooks/mdformat-tables/workflows/CI/badge.svg?branch=master)](<https://github.com/executablebooks/mdformat/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush>)
    [![codecov.io](https://codecov.io/gh/executablebooks/mdformat-tables/branch/master/graph/badge.svg)](<https://codecov.io/gh/executablebooks/mdformat-tables>)
    [![PyPI version](https://img.shields.io/pypi/v/mdformat-tables.svg)](<https://pypi.org/project/mdformat-tables>)
    
    An [mdformat](<https://github.com/executablebooks/mdformat>) plugin for rendering tables.
    

    I'd say that's not ideal behaviour 😬

    If not in "core", I think we at least want a plugin that can "inhibit" this type of behaviour.

    enhancement 
    opened by chrisjsewell 10
  • New release 0.7.12 wants 4 spaces infront of `<br/>`

    New release 0.7.12 wants 4 spaces infront of `
    `

    Describe the problem

    I have a README.md which has something like this:

    text
    <br/>
    text
    

    For some reason the new release of mdformat now wants to add 4 spaces infront of the <br/>. This breaks all my build pipelines. Since I see no reason why there must be 4 spaces I would say this is a bug.

    Could you please patch this and make a patch release?

    Many thanks Philip

    Link to your repository or website

    https://github.com/telekom/HPOflow/blob/main/README.md

    Steps to reproduce

    see above

    The version of Python you're using

    3.9

    Your operating system

    Linux

    Versions of your packages

    No response

    Additional context

    No response

    bug 
    opened by PhilipMay 9
  • ✨ NEW: Keep link references

    ✨ NEW: Keep link references

    Utilise the new store_labels option I introduced in mardown-it-py, to keep link/image reference labels, instead of their resolved href. Then output the (sorted) references at the end of the document.

    Notes:

    • I've left a "hook" to turn this feature on/off: markdown_it.options["mdformat"] = {"keep_references": True}, this could be turned into a CLI option, if desired.
    • References are always normalized using str.upper() in markdown-it, but, as a style choice, I convert them to str.lower()
    • I've added a finalize key-word argument to MDRenderer.render. This is for use by plugins (like mdformat-tables) that need to run "nested rendering", during which they do not want these references output.
    opened by chrisjsewell 9
  • `--check` doesn't work with `--end-of-line=crlf`

    `--check` doesn't work with `--end-of-line=crlf`

    Describe the bug

    context running mdformat --check --end-of-line=crlf on a correctly formated markdonw file result in error.

    expectation I expected mdformat to succede and nothing to happen

    bug But instead an error is rased that the file is not formated:

    $ mdformat --check --end-of-line=crlf test.md
    Error: File "D:\Downloads\temp\mdformat\test.md" is not formatted.
    

    related code

    I belive the problem thems from here:

    https://github.com/executablebooks/mdformat/blob/24f9d25960d28efc75cbfa051881bac5fc46a842/src/mdformat/_cli.py#L85-L87

    debugging reveald the content of formatted_str and original_str to have different lineendings:

    original_str: '# Test file\r\n\r\nHello world\r\n'
    formatted_str: '# Test file\n\nHello world\n'
    

    I assume that the formating process internally does a universal newline conversion, resulting in all newline types beeing converted to \n

    Reproduce the bug

    1. create a well formated mardkown file test.md with dos-style line endings (\r\n):

      # Test file
      
      Hello world
      
      
    2. run mdformat on it with the --check and --end-of-line=crlf options:

      mdformat --check --end-of-line=crlf test.md
      
    3. get error

    List your environment

    OS: windows 10 Python: v3.10.6 mdformat: 0.7.15

    bug 
    opened by Cube707 8
  • Link tokens [] are escaped

    Link tokens [] are escaped

    Describe the bug

    - [KiCAD](KiCAD)
    - [KiCAD - Scripts](KiCAD - Scripts)
    - [KiCAD - CNC](KiCAD - CNC)
    

    is converted to

    - [KiCAD](KiCAD)
    - \[KiCAD - Scripts\](KiCAD - Scripts)
    - \[KiCAD - CNC\](KiCAD - CNC)
    

    Rendering the links useless.

    There are links that are properly resolved in gitlab.

    expectation The link is maintained.

    problem This is a problem because this breaks the expected behaviour after applying mdformat.

    Reproduce the bug

    Apply mdformat on

    - [KiCAD](KiCAD)
    - [KiCAD - Scripts](KiCAD - Scripts)
    - [KiCAD - CNC](KiCAD - CNC)
    

    List your environment

    I suggest you update the hint to get the version (jupyter-hook does not exist).

    $ mdformat --version
    mdformat 0.7.13 (mdformat_frontmatter: 0.4.1, mdformat_gfm: 0.3.5,
    mdformat_tables: 0.4.1)
    $ python --version
    Python 3.9.10
    

    pre-commit configuration:

      - repo: https://github.com/executablebooks/mdformat
        # Do this before other tools "fixing" the line endings
        rev: 0.7.13
        hooks:
          - id: mdformat
            name: Format Markdown
            entry: mdformat  # Executable to run, with fixed options
            language: python
            types: [markdown]
            args: [--wrap, '75', --number]
            additional_dependencies:
              - mdformat-toc
    
    bug invalid 
    opened by mdeweerd 8
  • Support reading configuration options from a file

    Support reading configuration options from a file

    Description / Summary

    mdformat supports three configuration options via switches to the command line interface:

      --number              apply consecutive numbering to ordered lists
      --wrap {keep,no,INTEGER}
                            paragraph word wrap mode (default: keep)
      --end-of-line {lf,crlf}
                            output file line ending mode (default: lf)
    

    However, there does not seem to be support for configuring these options from a file that could be committed to source control.

    Value / benefit

    A configuration file would assist in ensuring consistent behavior between executing manually in a terminal, an editor integration, and when running as a pre-commit hook.

    Implementation details

    I find yaml files to be excellent for implementing configurations that are more often parsed by humans than by programs. But I do not have a strong opinion about this. toml is also an option that is gaining traction in the python ecosystem.

    To discover the configuration file, I suggest this logic to follow the xdg base directory spec:

    1. Check ./.mdformat-config.yaml
    2. If not found, check $XDG_CONFIG_HOME/mdformat-config.yaml
    3. If not found, check $HOME/mdformat-config.yaml
    4. If not found, check $HOME/.mdformat-config.yaml

    If command-line switches are passed, they should over-ride conflicting options in the configuration file.

    Tasks to complete

    • [ ] Decide on a configuration file format.
    • [ ] Decide on a discovery path for the configuration file.
    • [ ] Code it!
    enhancement 
    opened by rpdelaney 8
  • Let plugins add options to `.mdformat.toml` file

    Let plugins add options to `.mdformat.toml` file

    Context

    Currently, mdformat plugins are allowed to implement a add_cli_options function to add arguments to the mdformat ArgumentParser, but there is no way to allow those options to be added to the .mdformat.toml file without monkey patching the mdformat._conf module to add the new options to the DEFAULT_OPTS dictionary or _validate_keys and _validate_values functions.

    Proposal

    Add a way for plugins to declare acceptable options and values for the mdformat.toml file.

    Along the way, maybe also slightly reformat how the options are declared, so that they are not hard-coded in two different places (_conf and _cli) independently. An option for this would be to have them declared only inside _conf, with a way for plugins to alter them, and then have both the _cli.ArgumentParser and the _conf validation functions read and use them.

    Tasks and updates

    No response

    enhancement 
    opened by csala 0
  • Document a new plugin for shorter thematic breaks

    Document a new plugin for shorter thematic breaks

    Context

    I am using mdformat but having troubles with the current thematic break rendering composed of 70 underscore characters, which I am rather used to typing as three dashes ---.

    My (very personal and opinionated) reasons being:

    1. The default vim highlighting for Markdown syntax breaks when multiple underscores are put together, because it conflicts with the italics format. Notice that this can probably be solved with Vim plugins or configuration tweaks, but the origin of the problem is about raw vim with no plugins.
    2. Typing --- while writing a document is quick and easy, while typing a line of exactly 70 underscores is comparatively much harder and needs some sort of copy/paste action. My usual coding workflow involves code style checkers like mdformat and black as pre-commit hooks, but in general I try to type in code and documentation that is already valid to minimize the number of times that these tools have to modify what I have typed, which forces me to redo the review, git add and pre-commit loop.

    I admit that these are very personal reasons, so I do not wish to engange in any discussions about the current rendering style and the rationale behind it.

    Instead, I thought best to take the route of coding a new plugin which overrides the rendering style for thematic breaks with three dashes, so anyone who wants can take advantage of it without having to do any change in the main mdformat project: https://github.com/csala/mdformat-simple-breaks

    Proposal

    The proposal is just to add the plugin to the corresponding list in the documentation I'm happy to make a PR for it.

    Tasks and updates

    • [ ] Discuss and decide if a PR is wanted
    • [ ] Do the corresponding PR
    enhancement 
    opened by csala 1
  • inconsistent indenting of nested lists

    inconsistent indenting of nested lists

    Describe the bug

    context When I run MdFormat on this notebook through nbqa…

    expectation I expected to get nested lists indented a certain number of spaces.

    bug But instead some are indented two spaces, while some are indented three.

    diff --git hw_0.ipynb hw_0.ipynb
    index 4aaa010..ef99e82 100644
    --- hw_0.ipynb
    +++ hw_0.ipynb
    @@ -11,16 +11,16 @@
         "Kaggle, like JupyterHub and Google Colab, is built around Jupyter notebooks. They are not _exactly_ the same, but will feel similar. For this homework
    :\n",
         "\n",
         "1. Do following Kaggle [Learn Python](https://www.kaggle.com/learn/python) tutorials and exercises. You do not need to turn these in.\n",
    -    "    - [Hello, Python](https://www.kaggle.com/colinmorris/hello-python)\n",
    -    "    - [Booleans and Conditionals](https://www.kaggle.com/colinmorris/booleans-and-conditionals)\n",
    -    "    - [Strings and Dictionaries](https://www.kaggle.com/colinmorris/strings-and-dictionaries)\n",
    +    "   - [Hello, Python](https://www.kaggle.com/colinmorris/hello-python)\n",
    +    "   - [Booleans and Conditionals](https://www.kaggle.com/colinmorris/booleans-and-conditionals)\n",
    +    "   - [Strings and Dictionaries](https://www.kaggle.com/colinmorris/strings-and-dictionaries)\n",
         "1. Read about:\n",
    -    "    - [Tuples, lists, and dictionaries](http://sthurlow.com/python/lesson06/)\n",
    -    "    - [Errors and exceptions](https://swcarpentry.github.io/python-novice-inflammation/09-errors/index.html)\n",
    +    "   - [Tuples, lists, and dictionaries](http://sthurlow.com/python/lesson06/)\n",
    +    "   - [Errors and exceptions](https://swcarpentry.github.io/python-novice-inflammation/09-errors/index.html)\n",
         "1. Do the coding challenges below.\n",
         "1. Do the following Kaggle tutorials and exercises. You do not need to turn these in.\n",
    -    "    - [Python Lists](https://www.kaggle.com/colinmorris/lists)\n",
    -    "    - [Creating, Reading, and Writing with Pandas](https://www.kaggle.com/residentmario/creating-reading-and-writing)\n",
    +    "   - [Python Lists](https://www.kaggle.com/colinmorris/lists)\n",
    +    "   - [Creating, Reading, and Writing with Pandas](https://www.kaggle.com/residentmario/creating-reading-and-writing)\n",
         "1. Post a question, per the instructions at the bottom.\n",
         "1. [Turn in this notebook.](https://python-public-policy.afeld.me/en/latest/README.html#turning-in-assignments)\n",
         "\n",
    @@ -163,8 +163,8 @@
         "We will now make an interactive tool to assess people for unemployment benefits. We will use a simplified version of [the rules from the New York Stat
    e Department of Labor](https://www.labor.ny.gov/formsdocs/ui/TC318.3e.pdf#page=18), as follows. To be elegible, one must:\n",
         "\n",
         "- Have lost employment\n",
    -    "- Have made at least $10,000 in the past year\n",
    -    "    - Ask for their salary rather than as a yes-or-no question\n",
    +    "- Have made at least \\$10,000 in the past year\n",
    +    "  - Ask for their salary rather than as a yes-or-no question\n",
         "- Be ready, willing and able to work immediately\n",
         "- Be actively seeking work\n",
         "\n",
    

    problem This is a problem because I'm publishing that notebook via JupyterBook, and it's Markdown parser only seems to support nested lists indented 3+ spaces.

    cc https://github.com/executablebooks/mdformat/issues/331#issuecomment-1224279288 for the option to make that configurable for more fragile Markdown parsers

    Reproduce the bug

    1. Download this notebook

    2. Run Mdformat through nbqa:

      nbqa mdformat hw_0.ipynb --nbqa-md
      

    List your environment

    $ jupyter-book --version
    Jupyter Book      : 0.13.1
    External ToC      : 0.2.4
    MyST-Parser       : 0.15.2
    MyST-NB           : 0.13.2
    Sphinx Book Theme : 0.3.3
    Jupyter-Cache     : 0.4.3
    NbClient          : 0.5.13
    $ nbqa --version
    nbqa 1.5.3
    $ mdformat --version
    mdformat 0.7.16 (mdformat_myst: 0.1.5, mdformat_tables: 0.4.1, mdformat_frontmatter: 0.4.1)
    
    question 
    opened by afeld 2
  • Documentation for using plugins with MDRenderer

    Documentation for using plugins with MDRenderer

    Context

    The plugins documentation shows how to pass plugins to mdformat.text, but not how to do this using the Renderer API.

    At the moment I have rendered = MDRenderer().render(tokens, md.options, env) which works fine for plain markdown, but not if I have front_matter tokens which then gives the error below.

    It would be good if the documentation made it clearer if this can be done using mdformat.renderer directly.

    Traceback (most recent call last):
      File "/Users/g/gbin/mdh", line 25, in <module>
        run(fle, findtext, replacetext)
      File "/Users/g/gbin/markdown_helper/fix_image_paths.py", line 31, in run
        fix_image_paths(text, findtext, replacetext)
      File "/Users/g/gbin/markdown_helper/fix_image_paths.py", line 23, in fix_image_paths
        rendered = MDRenderer().render(tokens, md.options, env)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/__init__.py", line 57, in render
        return self.render_tree(tree, options, env, finalize=finalize)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/__init__.py", line 91, in render_tree
        text = tree.render(render_context)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/_tree.py", line 11, in render
        text = renderer(self, context)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 50, in render_children
        return separator.join(out for out in render_outputs if out)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 50, in <genexpr>
        return separator.join(out for out in render_outputs if out)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 49, in <genexpr>
        render_outputs = (child.render(context) for child in node.children)
      File "/opt/homebrew/lib/python3.10/site-packages/mdformat/renderer/_tree.py", line 10, in render
        renderer = context.renderers[self.type]
    KeyError: 'front_matter'
    

    Proposal

    • Extend the docs with an example how to use plugins with Renderer if this is possible
    • I am happy to write the docs and more examples covering frontmatter, tables, etc if someone can show me a basic example of how use Renderer() with a plugin.

    Tasks and updates

    No response

    enhancement 
    opened by sixhobbits 1
  • Enforce consistent emphasis / strength style

    Enforce consistent emphasis / strength style

    Context

    markdownlint has rules for this:

    They seem like good rules and mdformat can do this.

    Proposal

    Pick a style for emphasis and strength, and have mdformat swap the other to the chosen format.

    I don't have a strong opinion about which should win, but if it's a coin-toss then I guess _Italic_ and **Strong** would be easiest for humans to differentiate?

    Tasks and updates

    No response

    enhancement 
    opened by rpdelaney 1
Owner
Executable Books
An open collaboration to create executable books with Jupyter
Executable Books
Provides syntax for Python-Markdown which allows for the inclusion of the contents of other Markdown documents.

Markdown-Include This is an extension to Python-Markdown which provides an "include" function, similar to that found in LaTeX (and also the C pre-proc

Chris MacMackin 85 Dec 30, 2022
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
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.

Γ‡algan AygΓΌn 213 Dec 22, 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
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

Alireza Savand 1.3k Dec 31, 2022
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,

neutronX 740 Jan 8, 2023
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

null 659 Jan 4, 2023
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

Executable Books 398 Dec 24, 2022
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

Mi Yu 546 Jan 1, 2023
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

Frictionless Data 86 Dec 25, 2022
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

Eric Seifert 37 Jan 2, 2023
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 -

Esteban Garcia 3 Sep 13, 2021
Lightweight Markdown dialect for Python desktop apps

Litemark is a lightweight Markdown dialect originally created to be the markup language for the Codegame Platform project. When you run litemark from the command line interface without any arguments, the Litemark Viewer opens and displays the rendered demo.

null 10 Apr 23, 2022
A Discord Bot for rendering Markdown

Markdown to PDF Bot A discord bot that accepts markdown files (or messages) and displays them as images. Prerequisite To install, you must have have :

null 1 Oct 21, 2021