commit b9c3ac6a07bceae9c1136a47f871085f313830b1
parent af459e8a7296e9270d191ee64a3e0647cb36fb68
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 21 Jul 2025 13:00:29 +0100
add lcmark package
Diffstat:
5 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
@@ -4,7 +4,10 @@
probably not worth it
1. Read a directory full of markdown/textile files
-* https://github.com/jgm/lunamark/blob/master/README.markdown
+*
+(lcmark.convert "hello *world*" "html" { :yaml_parser #($1) })
+"<p>hello <em>world</em></p>
+" {}
2. index them by title
diff --git a/default.nix b/default.nix
@@ -13,12 +13,23 @@
let
luaPackages = lua53Packages;
fennel = luaPackages.fennel;
+ optparse = callPackage ./lcmark/optparse.nix {
+ inherit (luaPackages) buildLuarocksPackage luaAtLeast luaOlder ;
+ };
+ cmark-lua = callPackage ./lcmark/cmark.nix {
+ inherit (luaPackages) buildLuarocksPackage ;
+ };
+ lcmark = callPackage ./lcmark {
+ inherit (luaPackages) buildLuarocksPackage lpeg luaOlder ;
+ inherit optparse;
+ cmark = cmark-lua;
+ };
lua = lua5_3.withPackages (ps: with ps; [
luafilesystem
luaposix
readline
http
- markdown
+ lcmark
]);
pname = "cripslock";
in stdenv.mkDerivation {
diff --git a/lcmark/cmark.nix b/lcmark/cmark.nix
@@ -0,0 +1,22 @@
+{ buildLuarocksPackage, fetchFromGitHub, fetchurl }:
+buildLuarocksPackage {
+ pname = "cmark";
+ version = "0.31.1-1";
+ knownRockspec = (fetchurl {
+ url = "mirror://luarocks/cmark-0.31.1-1.rockspec";
+ sha256 = "00wdbvx3gmh7f08d2a5kvpa687rc922n5zgzxxqrip3xhll9hzwm";
+ }).outPath;
+ src = fetchFromGitHub {
+ owner = "jgm";
+ repo = "cmark-lua";
+ rev = "0.31.1";
+ hash = "sha256-elI+BYPTlFezkoWLjJyPBsAt2Pq2DRe/+YPmtG27ABY=";
+ };
+
+ meta = {
+ homepage = "https://github.com/jgm/cmark-lua";
+ description = "Lua wrapper for libcmark, CommonMark Markdown parsing\
+ and rendering library";
+ license.fullName = "BSD2";
+ };
+}
diff --git a/lcmark/default.nix b/lcmark/default.nix
@@ -0,0 +1,26 @@
+{ buildLuarocksPackage, cmark, fetchFromGitHub, fetchurl, lpeg, luaOlder, optparse }:
+buildLuarocksPackage {
+ pname = "lcmark";
+ version = "0.31.1-1";
+ knownRockspec = (fetchurl {
+ url = "mirror://luarocks/lcmark-0.31.1-1.rockspec";
+ sha256 = "0k1d1cqnj19p35qfaiascxllmv1x6i1sywrcyjv6fb150yym2f8m";
+ }).outPath;
+ src = fetchFromGitHub {
+ owner = "jgm";
+ repo = "lcmark";
+ rev = "0.31.1-1";
+ hash = "sha256-Ii4NZ98f8LQGT5jHXepckymIB1ieQJD3I063OraTiK8=";
+ };
+
+ disabled = luaOlder "5.1";
+ buildInputs = [ cmark lpeg ];
+ propagatedBuildInputs = [ cmark lpeg optparse ];
+
+ meta = {
+ homepage = "https://github.com/jgm/lcmark";
+ description = "A command-line CommonMark converter with flexible\
+ features, and a lua module that exposes these features.";
+ license.fullName = "BSD2";
+ };
+}
diff --git a/lcmark/optparse.nix b/lcmark/optparse.nix
@@ -0,0 +1,21 @@
+{ buildLuarocksPackage, fetchurl, fetchzip, luaAtLeast, luaOlder }:
+buildLuarocksPackage {
+ pname = "optparse";
+ version = "1.5-2";
+ knownRockspec = (fetchurl {
+ url = "mirror://luarocks/optparse-1.5-2.rockspec";
+ sha256 = "12hijk3wrhr6cc173qisgagd7sfdnbrfxyi7ksq4wcdrcazly0j8";
+ }).outPath;
+ src = fetchzip {
+ url = "http://github.com/gvvaughan/optparse/archive/v1.5.zip";
+ sha256 = "1kkpx21f4cqldlvwp9n5r5vmqi341absvxcidc7wd48ragfm1byq";
+ };
+
+ disabled = luaOlder "5.1" || luaAtLeast "5.5";
+
+ meta = {
+ homepage = "http://gvvaughan.github.io/optparse";
+ description = "Parse and process command-line options";
+ license.fullName = "MIT/X11";
+ };
+}