1{ lib 2, buildPythonApplication 3, buildPythonPackage 4, fetchFromGitHub 5, importlib-metadata 6, makeWrapper 7, markdown-it-py 8, poetry-core 9, pytestCheckHook 10, python3 11, pythonOlder 12, setuptools 13, tomli 14, typing-extensions 15}: 16 17let 18 withPlugins = plugins: buildPythonApplication { 19 pname = "${package.pname}"; 20 inherit (package) version; 21 format = "other"; 22 23 disabled = pythonOlder "3.7"; 24 25 dontUnpack = true; 26 dontBuild = true; 27 doCheck = false; 28 29 nativeBuildInputs = [ 30 makeWrapper 31 ]; 32 33 installPhase = '' 34 makeWrapper ${package}/bin/mdformat $out/bin/mdformat \ 35 --prefix PYTHONPATH : "${package}/${python3.sitePackages}:$PYTHONPATH" 36 ln -sfv ${package}/lib $out/lib 37 ''; 38 39 propagatedBuildInputs = package.propagatedBuildInputs ++ plugins; 40 41 passthru = package.passthru // { 42 withPlugins = morePlugins: withPlugins (morePlugins ++ plugins); 43 }; 44 45 meta.mainProgram = "mdformat"; 46 }; 47 48 package = buildPythonPackage rec { 49 pname = "mdformat"; 50 version = "0.7.17"; 51 format = "pyproject"; 52 53 disabled = pythonOlder "3.7"; 54 55 src = fetchFromGitHub { 56 owner = "executablebooks"; 57 repo = pname; 58 rev = "refs/tags/${version}"; 59 hash = "sha256-umtfbhN6sDR/rFr1LwmJ21Ph9bK1Qq43bmMVzGCPD5s="; 60 }; 61 62 nativeBuildInputs = [ 63 poetry-core 64 setuptools 65 ]; 66 67 propagatedBuildInputs = [ 68 markdown-it-py 69 tomli 70 ] ++ lib.optionals (pythonOlder "3.10") [ 71 importlib-metadata 72 ] ++ lib.optionals (pythonOlder "3.7") [ 73 typing-extensions 74 ]; 75 76 nativeCheckInputs = [ 77 pytestCheckHook 78 ]; 79 80 disabledTests = [ 81 # AssertionError 82 "test_no_codeblock_trailing_newline" 83 # Issue with upper/lower case 84 "default_style.md-options0" 85 ]; 86 87 pythonImportsCheck = [ 88 "mdformat" 89 ]; 90 91 passthru = { inherit withPlugins; }; 92 93 meta = with lib; { 94 description = "CommonMark compliant Markdown formatter"; 95 homepage = "https://mdformat.rtfd.io/"; 96 changelog = "https://github.com/executablebooks/mdformat/blob/${version}/docs/users/changelog.md"; 97 license = with licenses; [ mit ]; 98 maintainers = with maintainers; [ fab aldoborrero ]; 99 mainProgram = "mdformat"; 100 }; 101 }; 102in 103package