From patchwork Mon Sep 16 19:00:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_=C3=85gren?= X-Patchwork-Id: 11147679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97B4F1747 for ; Mon, 16 Sep 2019 19:00:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7642020830 for ; Mon, 16 Sep 2019 19:00:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GyvjU+8y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732853AbfIPTAw (ORCPT ); Mon, 16 Sep 2019 15:00:52 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40358 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfIPTAw (ORCPT ); Mon, 16 Sep 2019 15:00:52 -0400 Received: by mail-lf1-f66.google.com with SMTP id d17so818304lfa.7 for ; Mon, 16 Sep 2019 12:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RonXXUa1BfCEMjRNE8XfYd6dtxm3Y6HWnEz0sNI4IIQ=; b=GyvjU+8yAGaSbsf5Wu8NqIn2Z9+S9zuyXBNkOAumHUKnX7riOccwAdTMuHi+/oprjs 4b733fdw/RSZV/oUvFX9pPMp2bl4ERczPh2z/lOh8jzVDibiElHI0HLitxnGpUQKcXpS u6UUQCtVCKzcIsm/LU/Cqw6KUBNWpFK5Cxzi5ND/BMrkFtmiZEycJ50vhJHbs7NPDVLA ImcppUyEI4yxdy9hDbqHXrE6a39D5IHQQV5OKTONrqgBGy7kS72eslrpBb4cdxF72bR+ n5AT2w/kKEeV9h8nAyFHn+EwNeoKPYiI9bBGP8Rg+fRIn08KY7F9XO7R6UJoMBzw3uC9 x1ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RonXXUa1BfCEMjRNE8XfYd6dtxm3Y6HWnEz0sNI4IIQ=; b=Ck6OwNm+7TFJw9jbzOL/lxsPK0gn9VJiTPuzBQd7qP+7SW0uEQ8fpsqvNSvf/8uNiF QXM9lIoXllBX//xjm/nlb4mlXCQWJwd94Ll2OD/1H53RotRdfzVNBF31k+K22EIlC7gg njXjDHZXE+Ie+IvSam9A6Y4IWCsxugJlTHxTq+aLSJP//uuEYXRV9CcmJ9Pozwtbipey uE2lF1aAWRNqt/U57IlIwWbrZRFZfMmucPHEtIDfGOSRrqWyaA4maMLrqFYOMiPMAAEi p2/hOCjrsmtCfGL6DJTA94qZ3lFmDMr+TWmuVejdRetSQP/IBj8OMWZhbpPjDepjnXG0 y4Hw== X-Gm-Message-State: APjAAAUHbbf1oCbW9KWO03/KggIoYrNAIpdMYeuQlsyIRvNhTHvYdVLJ +THpBtYze9ROznh9gEP6vmdfkoCU X-Google-Smtp-Source: APXvYqx0GSWucxRY7q29K5jS5qi7n+YXNevAwZtIo7bHA96EItPBRXlZtLYtdRIvCIBMYKMW32f5xA== X-Received: by 2002:ac2:5925:: with SMTP id v5mr515079lfi.8.1568660449987; Mon, 16 Sep 2019 12:00:49 -0700 (PDT) Received: from localhost.localdomain (31-211-229-121.customers.ownit.se. [31.211.229.121]) by smtp.gmail.com with ESMTPSA id j28sm9127608lfh.57.2019.09.16.12.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 12:00:49 -0700 (PDT) From: =?utf-8?q?Martin_=C3=85gren?= To: git@vger.kernel.org Cc: Todd Zullinger , Jeff King , =?utf-8?q?SZE?= =?utf-8?q?DER_G=C3=A1bor?= , "brian m. carlson" , Junio C Hamano Subject: [PATCH v3 1/3] Doc/Makefile: give mansource/-version/-manual attributes Date: Mon, 16 Sep 2019 21:00:26 +0200 Message-Id: X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rather than hardcoding "Git Manual" and "Git" as the manual and source in asciidoc.conf, provide them as attributes `manmanual` and `mansource`. Rename the `git_version` attribute to `manversion`. These new attribute names are not arbitrary, see, e.g., [1]. For AsciiDoc (8.6.10) and Asciidoctor <1.5.7, this is a no-op. Starting with Asciidoctor 1.5.7, `manmanual` and `mansource` actually end up in the xml-files and eventually in the rendered manpages. In particular, the manpage headers now render just as with AsciiDoc. No versions of Asciidoctor pick up the `manversion` [2], and older versions don't pick up any of these attributes. -- We'll fix that with a bit of a hack in the next commit. [1] https://asciidoctor.org/docs/user-manual/#man-pages [2] Note how [1] says "Not used by Asciidoctor". Signed-off-by: Martin Ågren --- Documentation/Makefile | 3 ++- Documentation/asciidoc.conf | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index dbf5a0f276..a67bc04ae8 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -122,7 +122,8 @@ ASCIIDOC_HTML = xhtml11 ASCIIDOC_DOCBOOK = docbook ASCIIDOC_CONF = -f asciidoc.conf ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \ - -agit_version=$(GIT_VERSION) + -amanversion=$(GIT_VERSION) \ + -amanmanual='Git Manual' -amansource='Git' TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML) TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK) MANPAGE_XSL = manpage-normal.xsl diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index 2c16c536ba..8fc4b67081 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -78,9 +78,9 @@ template::[header-declarations] {mantitle} {manvolnum} -Git -{git_version} -Git Manual +{mansource} +{manversion} +{manmanual} {manname} From patchwork Mon Sep 16 19:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_=C3=85gren?= X-Patchwork-Id: 11147681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D696D14ED for ; Mon, 16 Sep 2019 19:00:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB18820830 for ; Mon, 16 Sep 2019 19:00:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VVC3zU8r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732937AbfIPTA5 (ORCPT ); Mon, 16 Sep 2019 15:00:57 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35963 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfIPTA5 (ORCPT ); Mon, 16 Sep 2019 15:00:57 -0400 Received: by mail-lf1-f68.google.com with SMTP id x80so840258lff.3 for ; Mon, 16 Sep 2019 12:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EAxd3Uf4ktT/GcOEQjNp+7eJUiWpfUxduKWXuS9Xik4=; b=VVC3zU8rs1wNp6n9WJGOKskgOfuA//lB5qhpd3+fk0gU7s8yIg1544Ga+GUE+4p2GX 1uH5Q6SnvsMKUWqExj8aWRtEVr1DEw/6/qgw/kDvWK+nvP7pnxQ2FTIaPj/OQa6xZ/ZV O606frGd3VyVuAyf//8WVdKC03uGfx2k2l7nAc+Quq35Rd14PG+U4zZzgUG4w39wA13i 471pJgTCH5gplb+9VP0XAfz/vjVLmNPc9Zfjv/tMiaYIZKcPyCjTwCDdfr1MJVJ6dvXA s4G+g9YG2f5WSEg9BRLaxROMUEYikge7icee/++IER75Lk9IQQChEzz63QUgtHwasnPr yP7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EAxd3Uf4ktT/GcOEQjNp+7eJUiWpfUxduKWXuS9Xik4=; b=i3mKXmV/7yJrD8JzoGM8TXuG+1mmrdDgmUv59vDHvYrVb/+jslxol3khI631qmHBV7 ME988OGBqGjLxy8/SiHDLe7eXwOETvJ4UkiMGE3302ONGPYdTwmudISsuS1+zEIPnBGS pkBomU1PYzCnpX0WqXjfICkV5elI1JdaSkiLdEuMJlwipu0a9cHYWiMk/NQoqa/MRW/u mXAi5s7iVMj1ceLO9C9Tvr/v4JD3EsnFwPgs/hiXEqbPU57VCyI1h90flZtvQh5VbSGR qdlbrreTJYQLeafVW7LzEFzm+auGdCYDo/F6NVSdXnrWtwTjT5rGiO8yn3KrPKNmn8KN Pctg== X-Gm-Message-State: APjAAAUxjaAFfgPC70eW2tKTguPpiB2Ao01RXyHQBkrPmIIxpncLp3ME o/Fd3YcJLeZ+6mDQYe/vTR8RSSoL X-Google-Smtp-Source: APXvYqx1+YaQh1JnAJ90WDWK1+PUtuQEquopQ4NlaMaD0UP49cW7HXrtOxAirs4vbod7gQynwdGnbw== X-Received: by 2002:ac2:4a89:: with SMTP id l9mr497835lfp.122.1568660452513; Mon, 16 Sep 2019 12:00:52 -0700 (PDT) Received: from localhost.localdomain (31-211-229-121.customers.ownit.se. [31.211.229.121]) by smtp.gmail.com with ESMTPSA id j28sm9127608lfh.57.2019.09.16.12.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 12:00:51 -0700 (PDT) From: =?utf-8?q?Martin_=C3=85gren?= To: git@vger.kernel.org Cc: Todd Zullinger , Jeff King , =?utf-8?q?SZE?= =?utf-8?q?DER_G=C3=A1bor?= , "brian m. carlson" , Junio C Hamano Subject: [PATCH v3 2/3] asciidoctor-extensions: provide `` Date: Mon, 16 Sep 2019 21:00:27 +0200 Message-Id: <4eb89fda71a647bd44aa1d308674e7694db7b17d.1568658269.git.martin.agren@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As can be seen from the previous commit, there are three attributes that we provide to AsciiDoc through asciidoc.conf. Asciidoctor ignores that file. After that patch, newer versions of Asciidoctor pick up the `manmanual` and `mansource` attributes as we invoke `asciidoctor`, but they don't pick up `manversion`. ([1] says: "Not used by Asciidoctor.") Older versions (<1.5.7) don't handle these attributes at all. As a result, we are missing one or three `` tags in each xml-file produced when we build with Asciidoctor. Because of this, xmlto doesn't include the Git version number in the rendered manpages. And in particular, with versions <1.5.7, the manpage footers instead contain the fairly ugly "[FIXME: source]". That Asciidoctor ignores asciidoc.conf is nothing new. This is why we implement the `linkgit:` macro in asciidoc.conf *and* in asciidoctor-extensions.rb. Follow suit and provide these tags in asciidoctor-extensions.rb, using a "postprocessor" extension where we just search and replace in the XML, treated as text. We may consider a few alternatives: * Inject these lines into the xml-files from the *Makefile*, e.g., using `sed`. That would reduce repetition, but it feels wrong to impose another step and another risk on the AsciiDoc-processing only to benefit the Asciidoctor-one. * I tried providing a "docinfo processor" to inject these tags, but could not figure out how to "merge" the two sections that resulted. To avoid xmlto barfing on the result, I needed to use `xmlto --skip-validation ...`, which seems unfortunate. Let's instead inject the missing tags using a postprocessor. We'll make it fairly obvious that we aim to inject the exact same three lines of `` that asciidoc.conf provides. We inject them in *post*-processing so we need to do the variable expansion ourselves. We do introduce the bug that asciidoc.conf already has in that we won't do any escaping, e.g., of funky versions like "some v <2.25, >2.20". The postprocessor we add here works on the XML as raw text and doesn't really use the full potential of XML to do a more structured injection. This is actually precisely what the Asciidoctor User Manual does in its postprocessor example [2]. I looked into two other approaches: 1. The nokogiri library is apparently the "modern" way of doing XML in ruby. I got it working fairly easily: require 'nokogiri' doc = Nokogiri::XML(output) doc.search("refmeta").each { |n| n.add_child(new_tags) } output = doc.to_xml However, this adds another dependency (e.g., the "ruby-nokogiri" package on Ubuntu). Using Asciidoctor is not our default, but it will probably need to become so soon. Let's avoid adding a dependency just so that we can say "search...add_child" rather than "sub(regex...)". 2. The older REXML is apparently always(?) bundled with ruby, but I couldn't even parse the original document: require 'rexml/document' doc = REXML::Document.new(output) ... The error was "no implicit conversion of nil into String" and I stopped there. I don't think it's unlikely that doing a plain old search-and-replace will work just as fine or better compared to parsing XML and worrying about libraries and library versions. [1] https://asciidoctor.org/docs/user-manual/#builtin-attributes [2] https://asciidoctor.org/docs/user-manual/#postprocessor-example Signed-off-by: Martin Ågren --- Documentation/asciidoctor-extensions.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb index 0089e0cfb8..85f14c7c11 100644 --- a/Documentation/asciidoctor-extensions.rb +++ b/Documentation/asciidoctor-extensions.rb @@ -20,9 +20,26 @@ module Git end end end + + class DocumentPostProcessor < Asciidoctor::Extensions::Postprocessor + def process document, output + if document.basebackend? 'docbook' + mansource = document.attributes['mansource'] + manversion = document.attributes['manversion'] + manmanual = document.attributes['manmanual'] + new_tags = "" \ + "#{mansource}\n" \ + "#{manversion}\n" \ + "#{manmanual}\n" + output = output.sub(/<\/refmeta>/, new_tags + "") + end + output + end + end end end Asciidoctor::Extensions.register do inline_macro Git::Documentation::LinkGitProcessor, :linkgit + postprocessor Git::Documentation::DocumentPostProcessor end From patchwork Mon Sep 16 19:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_=C3=85gren?= X-Patchwork-Id: 11147683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D4B776 for ; Mon, 16 Sep 2019 19:00:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B530206A4 for ; Mon, 16 Sep 2019 19:00:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GOIezQDI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732916AbfIPTA5 (ORCPT ); Mon, 16 Sep 2019 15:00:57 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:46806 "EHLO mail-lf1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732867AbfIPTA5 (ORCPT ); Mon, 16 Sep 2019 15:00:57 -0400 Received: by mail-lf1-f47.google.com with SMTP id t8so776683lfc.13 for ; Mon, 16 Sep 2019 12:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CgiWeZ3xLrTBK6SvmbN8GNtZu/96w1WtBI0fHu2DGu4=; b=GOIezQDIDNc9jA0G+pk3YQs60WeV+QfLeq22nlz2A/AWYw7Bl94V9o+Z0b0tztaDHr jofj3zoiCn/ZVAFSprAn/e1gPnnac2FFEIMlsf8iobdtA51fSSMOciqTcLyn+VRE+39T 73Wh6E3GjQDIYxa7LWYtGyyIbXQ5gAQA+1atYhbesKzq8NJCaeIElVoYbP7cSKqgJxRw 8kEaz113Ia5N+EaLuIZs0XsEF83UJxydp0F6dD3P3fd+KoyIJg+Cy06SBxxIFU7HZxVl e54SMGwQUcT9bubg9Q6uqoB5gGSMdWIw0MQAFNJkNW98UFQEb4jdW6iIbGE8WhEmAN2Z crkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CgiWeZ3xLrTBK6SvmbN8GNtZu/96w1WtBI0fHu2DGu4=; b=eB2NhGIYYsIEikZCPLlzp7UfHTBc+rvIMz740I/PFq341QOKRmTGqQhwI8Wz2AW/RV BfAYnk/GMYA0S6FjBDOadxokKrDV5R6DtlAJcsA+AyyOgIgrdQ6VD7toody1Axef3gJX QEZ+bvk43/Db1AmwWu8E7FEzRbDuuEjI12YmHaLBNfrZqTiozqzpmfKbVSSpBwd5meDU zYi+MmEijGCk4qS5b+4Wg05qr1Abvqn04Zu1vVVPZGOsk/YY8JMX7WFiWVn9+EHXGYva 8I2A3uysmXKnS8r5tLs54/y3RqT0OPIIe4mDDDvZWZMVEs9dy8eL+WZNfifmtvf7h5L/ 1GYQ== X-Gm-Message-State: APjAAAUWKwqYcIG4fElxdktlNajnSPV/hVa9DwtpZabK40jSzeUhpcYA p/scciGLF7HeuvDCapyePtiLMKfq X-Google-Smtp-Source: APXvYqzDR5Dj6/aUxIcN9GXmKKSy1Qtj7hOWOkAkhFSf3l8s3oUixjF5Mk6cSduMc42jE4FR+crMmA== X-Received: by 2002:ac2:4149:: with SMTP id c9mr509102lfi.128.1568660454689; Mon, 16 Sep 2019 12:00:54 -0700 (PDT) Received: from localhost.localdomain (31-211-229-121.customers.ownit.se. [31.211.229.121]) by smtp.gmail.com with ESMTPSA id j28sm9127608lfh.57.2019.09.16.12.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 12:00:53 -0700 (PDT) From: =?utf-8?q?Martin_=C3=85gren?= To: git@vger.kernel.org Cc: Todd Zullinger , Jeff King , =?utf-8?q?SZE?= =?utf-8?q?DER_G=C3=A1bor?= , "brian m. carlson" , Junio C Hamano Subject: [PATCH v3 3/3] doc-diff: replace --cut-header-footer with --cut-footer Date: Mon, 16 Sep 2019 21:00:28 +0200 Message-Id: X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org After the previous commit, AsciiDoc and Asciidoctor render the manpage headers identically, so we no longer need the "cut the header" part of our `--cut-header-footer` option. We do still need the "cut the footer" part, though. The previous commits improved the rendering of the footer in Asciidoctor by quite a bit, but the two programs still disagree on how to format the date in the footer: 01/01/1970 vs 1970-01-01. We could keep using `--cut-header-footer`, but it would be nice if we had a slightly smaller hammer `--cut-footer` that would be less likely to hide regressions. Rather than simply adding such an option, let's also drop `--cut-header-footer`, i.e., rework it to lose the "header" part of its name and functionality. `--cut-header-footer` is just a developer tool and it probably has no more than a handful of users, so we can afford to be aggressive. Signed-off-by: Martin Ågren --- Documentation/doc-diff | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Documentation/doc-diff b/Documentation/doc-diff index 3355be4798..88a9b20168 100755 --- a/Documentation/doc-diff +++ b/Documentation/doc-diff @@ -21,7 +21,7 @@ asciidoc use asciidoc with both commits to-asciidoc use asciidoc with the 'to'-commit to-asciidoctor use asciidoctor with the 'to'-commit asciidoctor use asciidoctor with both commits -cut-header-footer cut away header and footer +cut-footer cut away footer " SUBDIRECTORY_OK=1 . "$(git --exec-path)/git-sh-setup" @@ -31,7 +31,7 @@ force= clean= from_program= to_program= -cut_header_footer= +cut_footer= while test $# -gt 0 do case "$1" in @@ -55,8 +55,8 @@ do --asciidoc) from_program=-asciidoc to_program=-asciidoc ;; - --cut-header-footer) - cut_header_footer=-cut-header-footer ;; + --cut-footer) + cut_footer=-cut-footer ;; --) shift; break ;; *) @@ -118,8 +118,8 @@ construct_makemanflags () { from_makemanflags=$(construct_makemanflags "$from_program") && to_makemanflags=$(construct_makemanflags "$to_program") && -from_dir=$from_oid$from_program$cut_header_footer && -to_dir=$to_oid$to_program$cut_header_footer && +from_dir=$from_oid$from_program$cut_footer && +to_dir=$to_oid$to_program$cut_footer && # generate_render_makefile generate_render_makefile () { @@ -169,12 +169,11 @@ render_tree () { make -j$parallel -f - && mv "$tmp/rendered/$dname+" "$tmp/rendered/$dname" - if test "$cut_header_footer" = "-cut-header-footer" + if test "$cut_footer" = "-cut-footer" then for f in $(find "$tmp/rendered/$dname" -type f) do - tail -n +3 "$f" | head -n -2 | - sed -e '1{/^$/d}' -e '${/^$/d}' >"$f+" && + head -n -2 "$f" | sed -e '${/^$/d}' >"$f+" && mv "$f+" "$f" || return 1 done