Skip to contentSkip to conversation

docs: use lynx to produce better formatted text from markdown

PATCH New Matt Wilson 1 participant 1 message Jul 31, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 docs: use lynx to produce better formatted text from markdown

Markdown, while easy to read and write, isn't the most consumable format for users reading documentation on a terminal. This patch uses lynx to format markdown produced HTML into text files.

Changes since v3:
* remove bogus "html/%.txt: %.txt" rule

docs/Docs.mk +1 -0
diff -r 1809175cdc9b -r c3faef18d97d docs/Docs.mk
@@ -10,3 +10,4 @@ POD2TEXT	:= pod2text
 DOT		:= dot
 NEATO		:= neato
 MARKDOWN	:= markdown
+LYNX		:= lynx
docs/Makefile +11 -3
diff -r 1809175cdc9b -r c3faef18d97d docs/Makefile
@@ -131,9 +131,17 @@ txt/%.txt: %.txt
 	$(call move-if-changed,[email protected],$@)
 
 txt/%.txt: %.markdown
-	$(INSTALL_DIR) $(@D)
-	cp $< [email protected]
-	$(call move-if-changed,[email protected],$@)
+	@$(INSTALL_DIR) $(@D)
+	@set -e ; \
+	if which $(MARKDOWN) >/dev/null 2>&1 && \
+		which $(LYNX) >/dev/null 2>&1 ; then \
+		echo "Running markdown to generate $*.txt ... "; \
+		$(MARKDOWN) $< | lynx -dump -stdin > [email protected] ; \
+		$(call move-if-changed,[email protected],$@) ; \
+	else \
+		echo "markdown or lynx not installed; just copying $<."; \
+		cp $< $@; \
+	fi
 
 txt/man/%.1.txt: man/%.pod.1 Makefile
 	$(INSTALL_DIR) $(@D)