~toastal/sourcehut-asciidoc-renderer

df9f1bb13ae946a310c38f911aec359bb22eced4 — toastal 1 year, 9 months ago ff69f0b
Rename srht_markup_massage; unwrap more <p>s

I wanted the name to be more focused
9 files changed, 19 insertions(+), 18 deletions(-)

M flake.nix
D markup_massager/result
M srht-adoc-renderer.nix
R markup_massager/default.nix => srht_markup_massager/default.nix
R markup_massager/dune => srht_markup_massager/dune
R markup_massager/dune-project => srht_markup_massager/dune-project
A srht_markup_massager/result
R markup_massager/markup_massager.ml => srht_markup_massager/srht_markup_massager.ml
R markup_massager/markup_massager.opam => srht_markup_massager/srht_markup_massager.opam
M flake.nix => flake.nix +2 -2
@@ 21,14 21,14 @@
          pkgs = import nixpkgs { inherit system; };
        in
        {
          markup_massager = import ./markup_massager/default.nix {
          srht_markup_massager = import ./srht_markup_massager/default.nix {
            inherit (pkgs) lib ocamlPackages;
            pygments = pkgs.python3Packages.pygments;
          };

          "${name}" = import ./srht-adoc-renderer.nix {
            inherit (pkgs) lib writeShellApplication asciidoctor;
            inherit (self.packages.${system}) markup_massager;
            inherit (self.packages.${system}) srht_markup_massager;
          };

          "${name}-readme" = self.renderAsciiDoc {

D markup_massager/result => markup_massager/result +0 -1
@@ 1,1 0,0 @@
/nix/store/m2glcz0ib6h9j37lwwzqh7kms4ppi82q-ocaml4.13.1-markup_massager-2022-05-15-unstable
\ No newline at end of file

M srht-adoc-renderer.nix => srht-adoc-renderer.nix +3 -3
@@ 1,14 1,14 @@
{ lib
, writeShellApplication
, asciidoctor
, markup_massager
, srht_markup_massager
}:

(writeShellApplication {
  name = "srht-adoc-renderer";
  runtimeInputs = [
    asciidoctor
    markup_massager
    srht_markup_massager
  ];
  text = ''
    asciidoctor \


@@ 20,6 20,6 @@
        --base-dir "$1" \
        --out-file - \
        "$2" \
      | markup_massager
      | srht_markup_massager
  '';
}) // { meta.license = lib.licenses.lgpl3Only; }

R markup_massager/default.nix => srht_markup_massager/default.nix +2 -2
@@ 4,10 4,10 @@
}:

ocamlPackages.buildDunePackage rec {
  pname = "markup_massager";
  pname = "srht_markup_massager";
  meta.license = lib.licenses.lgpl3Only;
  src = ./.;
  version = "2022-05-15-unstable";
  version = "2022-07-24-unstable";
  minimumSupportedOcamlVersion = "4.08";
  useDune2 = true;
  propagatedBuildInputs = [

R markup_massager/dune => srht_markup_massager/dune +2 -2
@@ 1,4 1,4 @@
(executable
 (name markup_massager)
 (public_name markup_massager)
 (name srht_markup_massager)
 (public_name srht_markup_massager)
 (libraries fileutils lambdasoup))

R markup_massager/dune-project => srht_markup_massager/dune-project +1 -1
@@ 1,2 1,2 @@
(lang dune 2.9)
(name markup_massager)
(name srht_markup_massager)

A srht_markup_massager/result => srht_markup_massager/result +1 -0
@@ 0,0 1,1 @@
/nix/store/m2glcz0ib6h9j37lwwzqh7kms4ppi82q-ocaml4.13.1-markup_massager-2022-05-15-unstable
\ No newline at end of file

R markup_massager/markup_massager.ml => srht_markup_massager/srht_markup_massager.ml +7 -6
@@ 1,5 1,5 @@
(* SPDX-License-Identifier: LGPL-3.0
© 2022 toastal markup_massager
© 2022 toastal srht_markup_massager
*)
let unicon node =
	let () = Soup.remove_class "icon" node in


@@ 9,6 9,10 @@ let mk_del node =
	let () = Soup.remove_class "line-through" node in
	Soup.set_name "del" node

let unwrap_lone_p soup parent_selector =
	Soup.select (String.concat "" [ parent_selector; ">"; "p:only-child" ]) soup
	|> Soup.iter Soup.unwrap

let unwrap_definition_list_items node =
	match Soup.parent node with
	| Some parent ->


@@ 88,12 92,9 @@ let () =
	let soup = Soup.read_channel stdin |> Soup.parse in
	(* Admonitions contain incompatible class *)
	let () = Soup.select "td.icon" soup |> Soup.iter unicon in
	(* Personally I think this is bug in Asciidoctor, but visually it
	adds unnecessary space *)
	let () = Soup.select "li > p:only-child" soup |> Soup.iter Soup.unwrap in
	(* Personally I think this is bug in Asciidoctor, but visually it
	(* Personally I think these are bugs in Asciidoctor, but visually it
	adds unnecessary space *)
	let () = Soup.select "td > p:only-child" soup |> Soup.iter Soup.unwrap in
	let () = List.iter (unwrap_lone_p soup) [ "dd"; "li"; "th"; "td" ] in
	(* Personally I think this is bug in Asciidoctor, as this is the
	wrong element *)
	let () = Soup.select "span.line-through" soup |> Soup.iter mk_del in

R markup_massager/markup_massager.opam => srht_markup_massager/srht_markup_massager.opam +1 -1
@@ 1,5 1,5 @@
opam-version: "2.0"
name: "markup_massager"
name: "srht_markup_massager"
maintainer: "toastal <toastal@posteo.net>"
authors: "toastal <toastal@posteo.net>"
license: "LGPL-3.0"