{"thread":{"id":"1573","subject":"[PATCH] Add Makefile target glossary.html","startedAt":"2005-08-18T15:28:57Z","lastAt":"2005-08-18T15:28:57Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7505","messageId":"Pine.LNX.4.63.0508181727560.31642@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1573","inReplyTo":null,"subject":"[PATCH] Add Makefile target glossary.html","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-18T15:28:57Z","receivedAt":"2005-08-18T15:28:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This also includes a script which does the sorting, and introduces\nhyperlinks for every described term.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n Documentation/Makefile         |    7 +++-\n Documentation/sort_glossary.pl |   70 ++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 76 insertions(+), 1 deletions(-)\n create mode 100644 Documentation/sort_glossary.pl\n\na080898e91dce96c5bac6f0527236e37aeedd156\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -1,7 +1,7 @@\n MAN1_TXT=$(wildcard git-*.txt)\n MAN7_TXT=git.txt\n \n-DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT))\n+DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT)) glossary.html\n \n DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))\n DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))\n@@ -54,3 +54,8 @@ clean:\n %.xml : %.txt\n \tasciidoc -b docbook -d manpage $<\n \n+glossary.html : glossary.txt sort_glossary.pl\n+\tcat $< | \\\n+\tperl sort_glossary.pl | \\\n+\tasciidoc -b xhtml11 - > glossary.html\n+\ndiff --git a/Documentation/sort_glossary.pl b/Documentation/sort_glossary.pl\nnew file mode 100644\n--- /dev/null\n+++ b/Documentation/sort_glossary.pl\n@@ -0,0 +1,70 @@\n+#!/usr/bin/perl\n+\n+%terms=();\n+\n+while(<>) {\n+\tif(/^(\\S.*)::$/) {\n+\t\tmy $term=$1;\n+\t\tif(defined($terms{$term})) {\n+\t\t\tdie \"$1 defined twice\\n\";\n+\t\t}\n+\t\t$terms{$term}=\"\";\n+\t\tLOOP: while(<>) {\n+\t\t\tif(/^$/) {\n+\t\t\t\tlast LOOP;\n+\t\t\t}\n+\t\t\tif(/^\t\\S/) {\n+\t\t\t\t$terms{$term}.=$_;\n+\t\t\t} else {\n+\t\t\t\tdie \"Error 1: $_\";\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+sub format_tab_80 ($) {\n+\tmy $text=$_[0];\n+\tmy $result=\"\";\n+\t$text=~s/\\s+/ /g;\n+\t$text=~s/^\\s+//;\n+\twhile($text=~/^(.{1,72})(|\\s+(\\S.*)?)$/) {\n+\t\t$result.=\"\t\".$1.\"\\n\";\n+\t\t$text=$3;\n+\t}\n+\treturn $result;\n+}\n+\n+sub no_spaces ($) {\n+\tmy $result=$_[0];\n+\t$result=~tr/ /_/;\n+\treturn $result;\n+}\n+\n+print 'GIT Glossary\n+============\n+Aug 2005\n+\n+This list is sorted alphabetically:\n+\n+';\n+\n+@keys=sort {uc($a) cmp uc($b)} keys %terms;\n+$pattern='(\\b'.join('\\b|\\b',reverse @keys).'\\b)';\n+foreach $key (@keys) {\n+\t$terms{$key}=~s/$pattern/sprintf \"<<ref_\".no_spaces($1).\",$1>>\";/eg;\n+\tprint '[[ref_'.no_spaces($key).']]'.$key.\"::\\n\"\n+\t\t.format_tab_80($terms{$key}).\"\\n\";\n+}\n+\n+print '\n+\n+Author\n+------\n+Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> and\n+the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the link:git.html[git] suite\n+';\n+\n"}]}