nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

python312Packages.mdformat-gfm-alerts: init at 1.0.1

Open Sigmanificient opened this issue 1 year ago • 6 comments

Description of changes

Fixes https://github.com/NixOS/nixpkgs/issues/328644

Things done

  • Built on platform(s)
    • [X] x86_64-linux
    • [ ] aarch64-linux
    • [ ] x86_64-darwin
    • [ ] aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • [ ] sandbox = relaxed
    • [ ] sandbox = true
  • [ ] Tested, as applicable:
  • [ ] Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • [ ] Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • [ ] (Package updates) Added a release notes entry if the change is major or breaking
    • [ ] (Module updates) Added a release notes entry if the change is significant
    • [ ] (Module addition) Added a release notes entry if adding a new NixOS module
  • [X] Fits CONTRIBUTING.md.

Add a :+1: reaction to pull requests you find important.

Sigmanificient avatar Jul 20 '24 21:07 Sigmanificient

I tested this in a dev shell:

{
  description = "mdformat-gfm-alerts test";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/1bca03dfe35b3a9a2b9442ba7c04d521abc9d055";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    {
      self,
      flake-utils,
      nixpkgs,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShell = pkgs.mkShell {
          packages = with pkgs; [
            (mdformat.withPlugins (p: with p; [
              mdformat-gfm
              mdformat-gfm-alerts
              mdformat-tables
            ]))
          ];
        };
      }
    );
}

Yet, it doesn't seem to work; GFM alerts are still being escaped:

➜ mdformat --number README.md

➜ git diff | rg NOTE
-> [!NOTE]
+> \[!NOTE\]

Am I setting this up correctly? I'm admittedly not too familiar with how withPlugins works, but the plugin doesn't seem to get picked up like mdformat-gfm and mdformat-tables:

➜ mdformat --help | rg plugins
Installed plugins: mdformat_gfm: 0.3.6, mdformat_tables: 0.4.1

sudoforge avatar Aug 04 '24 01:08 sudoforge

@sudoforge I am not sure why, but I was able to get it loaded by commenting out mdformat-gfm

Sigmanificient avatar Aug 04 '24 13:08 Sigmanificient

@Sigmanificient said:

@sudoforge I am not sure why, but I was able to get it loaded by commenting out mdformat-gfm

okay... this is weird. i can confirm that removing mdformat-gfm makes mdformat-gfm-alerts show up in the --help output:

➜ mdformat --help | rg plugins
Installed plugins: mdformat_gfm_alerts: 1.0.1

... but now mdformat-tables isn't loaded.

sudoforge avatar Aug 04 '24 14:08 sudoforge

i think perhaps mdformat-gfm is picked up first, and... for... reasons, mdformat-gfm-alerts isn't. and once mdformat-gfm is removed, i have no clue why mdformat-tables wouldn't be loaded.

could be an upstream issue. i only started using mdformat recently, but i haven't encountered this with other plugins.

sudoforge avatar Aug 04 '24 14:08 sudoforge

another weird observation...

inverting the order of the plugins in the withPlugins array (such that mdformat-tables comes before mdformat-gfm-alerts causes mdformat_tables to be loaded, but not mdformat_gfm_alerts:

➜ mdformat --help | rg plugins
Installed plugins: mdformat_tables: 0.4.1

flake.nix

{
  description = "mdformat-gfm-alerts test";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/1bca03dfe35b3a9a2b9442ba7c04d521abc9d055";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    {
      self,
      flake-utils,
      nixpkgs,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShell = pkgs.mkShell {
          packages = with pkgs; [
            (mdformat.withPlugins (p: with p; [
              mdformat-tables
              mdformat-gfm-alerts
            ]))
          ];
        };
      }
    );
}

i just tested this again after adding a bunch of random plugins available in nixpkgs and only mdformat_tables was loaded.

might be related to how withPlugins works, i guess, or possibly how mdformat loads its plugins. in any case, i don't think it would make sense to block this PR because of this issue.

sudoforge avatar Aug 04 '24 14:08 sudoforge

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1913

nixos-discourse avatar Aug 20 '24 01:08 nixos-discourse