Giter VIP home page Giter VIP logo

mdformat-config's Introduction

Build Status PyPI version

mdformat-config

Mdformat plugin to beautify configuration and data-serialization formats

Description

mdformat-config is an mdformat plugin that makes mdformat beautify configuration and data-serialization formats. Currently supported formats are JSON, TOML and YAML.

Installing

pip install mdformat-config

Usage

mdformat YOUR_MARKDOWN_FILE.md

mdformat-config's People

Contributors

hukkin avatar hukkinj1 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mdformat-config's Issues

Ability to configure formatting preferences

Thank you for your work on mdformat and plugins @hukkinj1!! ❤️ 🎉

I'm looking to adopt mdformat as well as this plugin, but the practice across the repository I work is to indent YAML sequences / lists differently than is currently hardcoded in this project.

My preference

yaml.preserve_quotes = True
yaml.indent(mapping=2, sequence=4, offset=2)

Current hardcoding
https://github.com/hukkinj1/mdformat-config/blob/2afc92ce3f93396e1bd5a42395debdf05af6deab/mdformat_config/__init__.py#L21-L29


I looked into ruamel.yaml's documentation regarding configuring it, and didn't find a simple way to do it without forcing this plugin to expose configuration options to pass onwards =/

I also didn't conclude it would be easy when I inspected the source code.

What do you think, would it be in scope of this project to expose some configuration to pass onwards to ruamel.yaml? My experience in general is that its really tiresome to have to do this 1:1 mapping of configuration, because its often no end to the amount of options you end up needing to map, so its nice if it can be done quite generic.

Option to select/unselect formats

I would like to unselect formatting of TOML snippets, because IMO the result is not that good:

[build-system]
requires = ["pdm-pep517"]
build-backend = "pdm.pep517.api"

[project]
name = "package-name"
description = "The package description."
version = "0.1.0"
authors = [{name = "Timothée Mazzucotelli", email = "[email protected]"}]
license = "ISC"
readme = "README.md"
requires-python = ">=3.7"
keywords = ["some", "keywords"]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3 :: Only",
    "Typing :: Typed",
]

...is formatted to:

[build-system]
requires = [ "pdm-pep517",]
build-backend = "pdm.pep517.api"

[project]
name = "package-name"
description = "The package description."
version = "0.1.0"
license = "ISC"
readme = "README.md"
requires-python = ">=3.7"
keywords = [ "some", "keywords",]
classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Typing :: Typed",]
[[project.authors]]
name = "Timothée Mazzucotelli"
email = "[email protected]"

Things I don't like in the formatted block:

  • arrays start with a space, but do not end with one
  • arrays are inlined (line breaks removed) (this is the most crazy one 😅)
  • trailing commas are added to already inlined arrays
  • trailing commas are not removed after inlining arrays
  • inline mappings are moved after the current object
  • no space is added before a moved mapping

I suspect you don't do anything special in this project and just load and re-dump the TOML data.

So in the end I'd just like to prevent TOML formatting and just keep JSON and YAML 🙂

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.