From 58856e86f639a5b07ccd2fd157bddd828127f200 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Fri, 24 Sep 2021 15:21:22 +0200
Subject: [PATCH 1/3] flake.lock: Update
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Flake lock file changes:

• Updated input 'lowdown-src':
    'github:kristapsdz/lowdown/b4483d0ef85990f54b864158ab786b4a5b3904fa' (2021-08-06)
  → 'github:kristapsdz/lowdown/0b85e777f3cdacf4210f0d624a0ceec8df612e05' (2021-09-23)
---
 flake.lock | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/flake.lock b/flake.lock
index d562728e7..c477e7678 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,16 +3,15 @@
     "lowdown-src": {
       "flake": false,
       "locked": {
-        "lastModified": 1628247802,
-        "narHash": "sha256-4XSXGYvKqogR7bubyqYNwBHYCtrIn6XRGXj6+u+BXNs=",
+        "lastModified": 1632391204,
+        "narHash": "sha256-zjyNA4ZmaaIbbmz2JZDqMgY7+P/uGF0nLg28Nxfg5kI=",
         "owner": "kristapsdz",
         "repo": "lowdown",
-        "rev": "b4483d0ef85990f54b864158ab786b4a5b3904fa",
+        "rev": "0b85e777f3cdacf4210f0d624a0ceec8df612e05",
         "type": "github"
       },
       "original": {
         "owner": "kristapsdz",
-        "ref": "VERSION_0_8_6",
         "repo": "lowdown",
         "type": "github"
       }

From aedbc7b683c3110bb9627cbea376953b766eaf3d Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Fri, 24 Sep 2021 15:21:41 +0200
Subject: [PATCH 2/3] Use latest lowdown

This improves list rendering
(https://github.com/kristapsdz/lowdown/issues/73).
---
 flake.nix              | 4 ++--
 src/libcmd/markdown.cc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/flake.nix b/flake.nix
index 5f77e42d1..fc4836864 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,7 +2,7 @@
   description = "The purely functional package manager";
 
   inputs.nixpkgs.url = "nixpkgs/nixos-21.05-small";
-  inputs.lowdown-src = { url = "github:kristapsdz/lowdown/VERSION_0_8_6"; flake = false; };
+  inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; };
 
   outputs = { self, nixpkgs, lowdown-src }:
 
@@ -350,7 +350,7 @@
         };
 
         lowdown = with final; stdenv.mkDerivation rec {
-          name = "lowdown-0.8.6";
+          name = "lowdown-0.9.0";
 
           /*
           src = fetchurl {
diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc
index 737356284..29bb4d31e 100644
--- a/src/libcmd/markdown.cc
+++ b/src/libcmd/markdown.cc
@@ -25,7 +25,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
     Finally freeDoc([&]() { lowdown_doc_free(doc); });
 
     size_t maxn = 0;
-    auto node = lowdown_doc_parse(doc, &maxn, markdown.data(), markdown.size());
+    auto node = lowdown_doc_parse(doc, &maxn, markdown.data(), markdown.size(), nullptr);
     if (!node)
         throw Error("cannot parse Markdown document");
     Finally freeNode([&]() { lowdown_node_free(node); });
@@ -40,7 +40,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
         throw Error("cannot allocate Markdown output buffer");
     Finally freeBuffer([&]() { lowdown_buf_free(buf); });
 
-    int rndr_res = lowdown_term_rndr(buf, nullptr, renderer, node);
+    int rndr_res = lowdown_term_rndr(buf, renderer, node);
     if (!rndr_res)
         throw Error("allocation error while rendering Markdown");
 

From 32669a6bc95e590c6b3421240b270fda99288a24 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Mon, 27 Sep 2021 10:31:13 +0200
Subject: [PATCH 3/3] Use separate lowdown

Overriding the lowdown in nixpkgs can break nixUnstable.
---
 flake.nix | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/flake.nix b/flake.nix
index fc4836864..43123ca7e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -70,7 +70,7 @@
           [
             buildPackages.bison
             buildPackages.flex
-            (lib.getBin buildPackages.lowdown)
+            (lib.getBin buildPackages.lowdown-nix)
             buildPackages.mdbook
             buildPackages.autoconf-archive
             buildPackages.autoreconfHook
@@ -89,7 +89,7 @@
             openssl sqlite
             libarchive
             boost
-            lowdown
+            lowdown-nix
             gmock
           ]
           ++ lib.optionals stdenv.isLinux [libseccomp]
@@ -349,16 +349,9 @@
 
         };
 
-        lowdown = with final; stdenv.mkDerivation rec {
+        lowdown-nix = with final; stdenv.mkDerivation rec {
           name = "lowdown-0.9.0";
 
-          /*
-          src = fetchurl {
-            url = "https://kristaps.bsd.lv/lowdown/snapshots/${name}.tar.gz";
-            hash = "sha512-U9WeGoInT9vrawwa57t6u9dEdRge4/P+0wLxmQyOL9nhzOEUU2FRz2Be9H0dCjYE7p2v3vCXIYk40M+jjULATw==";
-          };
-          */
-
           src = lowdown-src;
 
           outputs = [ "out" "bin" "dev" ];