user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/3] documentation build changes
@ 2016-09-01 18:20 Eric Wong
  2016-09-01 18:20 ` [PATCH 1/3] txt2pre: use public-inbox internal APIs Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2016-09-01 18:20 UTC (permalink / raw)
  To: meta

In preparation for more documentation...

Eric Wong (3):
      txt2pre: use public-inbox internal APIs
      txt2pre: allow overriding title via env
      doc: set release and section properly for manpages

 .gitignore                         |  1 +
 Documentation/.gitignore           |  2 +-
 Documentation/include.mk           | 23 ++++++++++++++++++-----
 Documentation/public-inbox-mda.pod |  4 ++--
 Documentation/txt2pre              | 33 ++++++++++++---------------------
 MANIFEST                           |  5 +++++
 6 files changed, 39 insertions(+), 29 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] txt2pre: use public-inbox internal APIs
  2016-09-01 18:20 [PATCH 0/3] documentation build changes Eric Wong
@ 2016-09-01 18:20 ` Eric Wong
  2016-09-01 18:20 ` [PATCH 2/3] txt2pre: allow overriding title via env Eric Wong
  2016-09-01 18:20 ` [PATCH 3/3] doc: set release and section properly for manpages Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-09-01 18:20 UTC (permalink / raw)
  To: meta

Since this is bundled with the source, we might as well use
internal APIs to avoid having duplicate code (and bugs :P)
---
 Documentation/include.mk |  3 ++-
 Documentation/txt2pre    | 30 ++++++++++--------------------
 2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/Documentation/include.mk b/Documentation/include.mk
index 5d73028..51a914b 100644
--- a/Documentation/include.mk
+++ b/Documentation/include.mk
@@ -52,7 +52,8 @@ all :: $(mantxt)
 Documentation/%.txt : Documentation/%.pod
 	$(podtext) $< $@+ && mv $@+ $@
 
-txt2pre = ./Documentation/txt2pre <$< >$@+ && touch -r $< $@+ && mv $@+ $@
+txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
+	touch -r $< $@+ && mv $@+ $@
 txt := INSTALL README COPYING TODO
 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt
 dtxt := $(addprefix Documentation/, $(dtxt)) $(mantxt)
diff --git a/Documentation/txt2pre b/Documentation/txt2pre
index 2dd1597..72de0b7 100755
--- a/Documentation/txt2pre
+++ b/Documentation/txt2pre
@@ -7,28 +7,18 @@
 # and requires indentation to output preformatted text.
 use strict;
 use warnings;
-use Encode qw/encode/;
+use PublicInbox::Linkify;
+use PublicInbox::Hval qw(ascii_html);
+
 my $str = eval { local $/; <> };
-my %xhtml_map = (
-	'"' => '&#34;',
-	'&' => '&#38;',
-	"'" => '&#39;',
-	'<' => '&lt;',
-	'>' => '&gt;',
-);
-$str =~ s/([<>&'"])/$xhtml_map{$1}/ge;
-$str = encode('us-ascii', $str, Encode::HTMLCREF);
 my ($title) = ($str =~ /\A([^\n]+)/);
-
-# temporarily swap &gt; for escape so our s!! to add href works.
-# there's probably a way to do this with only a single s!! ...
-$str =~ s!&gt;!\e!g;
-$str =~ s!\b((nntp|ftp|https?)://[\w+\+\&\?\.\%\;/#-]+)!<a
-href="$1"\n>$1</a>!g;
-
-$str =~ s!\e!&gt;!g; # swap escapes back to &gt;
+$title = ascii_html($title);
+my $l = PublicInbox::Linkify->new;
+$str = $l->linkify_1($str);
+$str = ascii_html($str);
+$str = $l->linkify_2($str);
 
 print '<html><head>',
-  '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
+  qq(<meta\nhttp-equiv="Content-Type"\ncontent="text/html; charset=utf-8"\n/>),
   "<title>$title</title>",
-  "</head><body>\n<pre>",  $str , '</pre></body></html>';
+  "</head><body><pre>",  $str , '</pre></body></html>';
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] txt2pre: allow overriding title via env
  2016-09-01 18:20 [PATCH 0/3] documentation build changes Eric Wong
  2016-09-01 18:20 ` [PATCH 1/3] txt2pre: use public-inbox internal APIs Eric Wong
@ 2016-09-01 18:20 ` Eric Wong
  2016-09-01 18:20 ` [PATCH 3/3] doc: set release and section properly for manpages Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-09-01 18:20 UTC (permalink / raw)
  To: meta

This will allow reasonable titles to be generated for
manpages.
---
 Documentation/include.mk | 2 +-
 Documentation/txt2pre    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/include.mk b/Documentation/include.mk
index 51a914b..4583f95 100644
--- a/Documentation/include.mk
+++ b/Documentation/include.mk
@@ -59,7 +59,7 @@ dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt
 dtxt := $(addprefix Documentation/, $(dtxt)) $(mantxt)
 
 %.html: %.txt
-	$(txt2pre)
+	TITLE="$(basename $(<F))" $(txt2pre)
 %.html: %
 	$(txt2pre)
 
diff --git a/Documentation/txt2pre b/Documentation/txt2pre
index 72de0b7..2f1799f 100755
--- a/Documentation/txt2pre
+++ b/Documentation/txt2pre
@@ -11,7 +11,8 @@ use PublicInbox::Linkify;
 use PublicInbox::Hval qw(ascii_html);
 
 my $str = eval { local $/; <> };
-my ($title) = ($str =~ /\A([^\n]+)/);
+my $title = $ENV{TITLE};
+($title) = ($str =~ /\A([^\n]+)/) unless $title;
 $title = ascii_html($title);
 my $l = PublicInbox::Linkify->new;
 $str = $l->linkify_1($str);
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] doc: set release and section properly for manpages
  2016-09-01 18:20 [PATCH 0/3] documentation build changes Eric Wong
  2016-09-01 18:20 ` [PATCH 1/3] txt2pre: use public-inbox internal APIs Eric Wong
  2016-09-01 18:20 ` [PATCH 2/3] txt2pre: allow overriding title via env Eric Wong
@ 2016-09-01 18:20 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-09-01 18:20 UTC (permalink / raw)
  To: meta

This will be important as we will have more of them.
---
 Documentation/include.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/include.mk b/Documentation/include.mk
index 4583f95..9d2c3b0 100644
--- a/Documentation/include.mk
+++ b/Documentation/include.mk
@@ -9,6 +9,7 @@ docs += $(shell git ls-files 'Documentation/*.txt')
 INSTALL = install
 PODMAN = pod2man
 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
+PODMAN_OPTS += -r public-inbox.git
 podman = $(PODMAN) $(PODMAN_OPTS)
 PODTEXT = pod2text
 PODTEXT_OPTS = --stderr
@@ -41,8 +42,8 @@ install-man: man
 	test -z "$(man5)" || $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
 	test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
 
-%.1 : Documentation/%.pod
-	$(podman) -s 1 $< $@+ && mv $@+ $@
+%.1 %.5 %.7 %.8 : Documentation/%.pod
+	$(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
 
 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(m1)))
 docs += $(mantxt)
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-01 18:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01 18:20 [PATCH 0/3] documentation build changes Eric Wong
2016-09-01 18:20 ` [PATCH 1/3] txt2pre: use public-inbox internal APIs Eric Wong
2016-09-01 18:20 ` [PATCH 2/3] txt2pre: allow overriding title via env Eric Wong
2016-09-01 18:20 ` [PATCH 3/3] doc: set release and section properly for manpages Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).