Add support to generate man pages in txt and md

Manual pages can now be generated in plain ASCII text as
well as in markdown. This is in addition to the prviously
generated postscript, troff and rst.  All output types are
generated when the build doc CMake configuration variable
is set high.

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: Ib98e6df65c32944807a99a6c5b80859182038c4d
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index c344477..fe59f5e 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -94,8 +94,8 @@
 	# for each source, build a specific command that runs tfm to generate the
 	# troff output as a gzipped file. Sed is needed to remove the leading blank
 	# that tfm likes to insert even if indention is 0. We also generate postscript
-	# and rts output which are left in the build directory for the developer to 
-	# use as needed.
+	# markdown, plain ascii and rts output which are left in the build directory 
+	# for the developer to use as needed.
 	#
 	foreach( nm IN LISTS man_names )
 	  set( out ${CMAKE_BINARY_DIR}/${nm} )
@@ -104,10 +104,17 @@
 	  add_custom_command(
 			OUTPUT ${out}.gz
 			DEPENDS ${in}
-			COMMAND bash -c "export OUTPUT_RST=0; export LIB=${CMAKE_SOURCE_DIR}/doc/src; \
-				${tfm} ${in} stdout | sed 's/^ //' | gzip >${out}.gz; \
-				export OUTPUT_RST=1; ${tfm} ${in} ${out}.rst; \
-				${pfm} ${in} ${out}.ps"
+			COMMAND bash -c "export LIB=${CMAKE_SOURCE_DIR}/doc/src; \
+				export OUTPUT_TYPE=troff; \
+					${tfm} ${in} stdout | sed 's/^ //' | gzip >${out}.gz; \
+				export OUTPUT_TYPE=rst; \
+					${tfm} ${in} ${out}.rst; \
+				export OUTPUT_TYPE=txt; \
+				  ${tfm} ${in} ${out}.txt; \
+				export OUTPUT_TYPE=markdown; \
+					${tfm} ${in} stdout | sed 's/^ //' >${out}.md; \
+				export OUTPUT_TYPE=postscript; \
+					${pfm} ${in} ${out}.ps"
 			WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 			COMMENT "Building manpage ${out}"
 			VERBATIM
diff --git a/doc/src/man/rmr.7.xfm b/doc/src/man/rmr.7.xfm
index affdf24..1c973c6 100644
--- a/doc/src/man/rmr.7.xfm
+++ b/doc/src/man/rmr.7.xfm
@@ -23,22 +23,8 @@
 	Date		29 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** and rst.im will cause rst to be generated depending on OUTPUT_TYPE env
-.** var.
-.** if formatting with pfm, then pretty postscript will be generated
-
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 =
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_alloc_msg.3.xfm b/doc/src/man/rmr_alloc_msg.3.xfm
index a9dad95..cd9da7f 100644
--- a/doc/src/man/rmr_alloc_msg.3.xfm
+++ b/doc/src/man/rmr_alloc_msg.3.xfm
@@ -23,22 +23,10 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im
 
 &line_len(6i)
-
 &h1(RMR Library Functions)
 &h2(NAME)
 	rmr_alloc_msg
diff --git a/doc/src/man/rmr_bytes2meid.3.xfm b/doc/src/man/rmr_bytes2meid.3.xfm
index fcc3955..0699cdf 100644
--- a/doc/src/man/rmr_bytes2meid.3.xfm
+++ b/doc/src/man/rmr_bytes2meid.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_bytes2payload.3.xfm b/doc/src/man/rmr_bytes2payload.3.xfm
index a8f99e2..b9412a8 100644
--- a/doc/src/man/rmr_bytes2payload.3.xfm
+++ b/doc/src/man/rmr_bytes2payload.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_bytes2xact.3.xfm b/doc/src/man/rmr_bytes2xact.3.xfm
index dbfe679..97fb5a3 100644
--- a/doc/src/man/rmr_bytes2xact.3.xfm
+++ b/doc/src/man/rmr_bytes2xact.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_call.3.xfm b/doc/src/man/rmr_call.3.xfm
index d83151e..edd8a5b 100644
--- a/doc/src/man/rmr_call.3.xfm
+++ b/doc/src/man/rmr_call.3.xfm
@@ -25,19 +25,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_close.3.xfm b/doc/src/man/rmr_close.3.xfm
index 8b05f0b..3fe439c 100644
--- a/doc/src/man/rmr_close.3.xfm
+++ b/doc/src/man/rmr_close.3.xfm
@@ -24,19 +24,8 @@
 	Date		21 February 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_free_msg.3.xfm b/doc/src/man/rmr_free_msg.3.xfm
index e29f8d9..5c0fd91 100644
--- a/doc/src/man/rmr_free_msg.3.xfm
+++ b/doc/src/man/rmr_free_msg.3.xfm
@@ -24,19 +24,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_meid.3.xfm b/doc/src/man/rmr_get_meid.3.xfm
index 427fbd6..939a372 100644
--- a/doc/src/man/rmr_get_meid.3.xfm
+++ b/doc/src/man/rmr_get_meid.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_rcvfd.3.xfm b/doc/src/man/rmr_get_rcvfd.3.xfm
index 8300d4e..54cc515 100644
--- a/doc/src/man/rmr_get_rcvfd.3.xfm
+++ b/doc/src/man/rmr_get_rcvfd.3.xfm
@@ -24,19 +24,8 @@
 	Date		11 February 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_src.3.xfm b/doc/src/man/rmr_get_src.3.xfm
index 42146e8..98ec5a5 100644
--- a/doc/src/man/rmr_get_src.3.xfm
+++ b/doc/src/man/rmr_get_src.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 =
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_srcip.3.xfm b/doc/src/man/rmr_get_srcip.3.xfm
index 050f1f2..7db7efe 100644
--- a/doc/src/man/rmr_get_srcip.3.xfm
+++ b/doc/src/man/rmr_get_srcip.3.xfm
@@ -24,19 +24,8 @@
 	Date		11 June 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 =
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_trace.3.xfm b/doc/src/man/rmr_get_trace.3.xfm
index f22596a..21c0285 100644
--- a/doc/src/man/rmr_get_trace.3.xfm
+++ b/doc/src/man/rmr_get_trace.3.xfm
@@ -24,19 +24,8 @@
 	Date		19 April 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_get_trlen.3.xfm b/doc/src/man/rmr_get_trlen.3.xfm
index 1f0d774..770935c 100644
--- a/doc/src/man/rmr_get_trlen.3.xfm
+++ b/doc/src/man/rmr_get_trlen.3.xfm
@@ -23,19 +23,8 @@
 	Date		19 April 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 
 &line_len(6i)
diff --git a/doc/src/man/rmr_init.3.xfm b/doc/src/man/rmr_init.3.xfm
index 83a0f18..3871d03 100644
--- a/doc/src/man/rmr_init.3.xfm
+++ b/doc/src/man/rmr_init.3.xfm
@@ -24,19 +24,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_init_trace.3.xfm b/doc/src/man/rmr_init_trace.3.xfm
index 8d6b1da..b6e534b 100644
--- a/doc/src/man/rmr_init_trace.3.xfm
+++ b/doc/src/man/rmr_init_trace.3.xfm
@@ -24,19 +24,8 @@
 	Date		19 April 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_mt_call.3.xfm b/doc/src/man/rmr_mt_call.3.xfm
index b0246bb..ecb65ca 100644
--- a/doc/src/man/rmr_mt_call.3.xfm
+++ b/doc/src/man/rmr_mt_call.3.xfm
@@ -25,19 +25,8 @@
 	Date		24 May 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_mt_rcv.3.xfm b/doc/src/man/rmr_mt_rcv.3.xfm
index 7c83f18..8be015a 100644
--- a/doc/src/man/rmr_mt_rcv.3.xfm
+++ b/doc/src/man/rmr_mt_rcv.3.xfm
@@ -23,19 +23,8 @@
 	Date		24 May 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_payload_size.3.xfm b/doc/src/man/rmr_payload_size.3.xfm
index 7dbfa69..9e8bf1c 100644
--- a/doc/src/man/rmr_payload_size.3.xfm
+++ b/doc/src/man/rmr_payload_size.3.xfm
@@ -23,19 +23,8 @@
 	Date		29 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 
 &line_len(6i)
diff --git a/doc/src/man/rmr_rcv_msg.3.xfm b/doc/src/man/rmr_rcv_msg.3.xfm
index b432f9d..6b0c40c 100644
--- a/doc/src/man/rmr_rcv_msg.3.xfm
+++ b/doc/src/man/rmr_rcv_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		29 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_ready.3.xfm b/doc/src/man/rmr_ready.3.xfm
index 9a82010..61ea2f8 100644
--- a/doc/src/man/rmr_ready.3.xfm
+++ b/doc/src/man/rmr_ready.3.xfm
@@ -23,19 +23,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_rts_msg.3.xfm b/doc/src/man/rmr_rts_msg.3.xfm
index 830f6a6..a5251d4 100644
--- a/doc/src/man/rmr_rts_msg.3.xfm
+++ b/doc/src/man/rmr_rts_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_send_msg.3.xfm b/doc/src/man/rmr_send_msg.3.xfm
index 5b5a206..9d9b625 100644
--- a/doc/src/man/rmr_send_msg.3.xfm
+++ b/doc/src/man/rmr_send_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_set_stimeout.3.xfm b/doc/src/man/rmr_set_stimeout.3.xfm
index 5550d24..b8747d2 100644
--- a/doc/src/man/rmr_set_stimeout.3.xfm
+++ b/doc/src/man/rmr_set_stimeout.3.xfm
@@ -23,19 +23,8 @@
     Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-    .im &{lib}/generic_ps.im
-.ei
-    .gv e OUTPUT_RST use_rst
-    .if .ev &use_rst 1 =
-    	.im &{lib}/rst.im
-    .ei
-    	.im &{lib}/roff.im
-    .fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_set_trace.3.xfm b/doc/src/man/rmr_set_trace.3.xfm
index 2ee05ba..bb9a1f4 100644
--- a/doc/src/man/rmr_set_trace.3.xfm
+++ b/doc/src/man/rmr_set_trace.3.xfm
@@ -24,19 +24,8 @@
 	Date		19 April 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_str2meid.3.xfm b/doc/src/man/rmr_str2meid.3.xfm
index 81ed6c9..1b741a4 100644
--- a/doc/src/man/rmr_str2meid.3.xfm
+++ b/doc/src/man/rmr_str2meid.3.xfm
@@ -24,19 +24,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_str2xact.3.xfm b/doc/src/man/rmr_str2xact.3.xfm
index 1f14cd6..6bc40d0 100644
--- a/doc/src/man/rmr_str2xact.3.xfm
+++ b/doc/src/man/rmr_str2xact.3.xfm
@@ -25,19 +25,8 @@
 	Date		8 March 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_support.3.xfm b/doc/src/man/rmr_support.3.xfm
index b4cdd7f..29a228a 100644
--- a/doc/src/man/rmr_support.3.xfm
+++ b/doc/src/man/rmr_support.3.xfm
@@ -28,19 +28,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_torcv_msg.3.xfm b/doc/src/man/rmr_torcv_msg.3.xfm
index 0482419..b38b9ad 100644
--- a/doc/src/man/rmr_torcv_msg.3.xfm
+++ b/doc/src/man/rmr_torcv_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		29 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_trace_ref.3.xfm b/doc/src/man/rmr_trace_ref.3.xfm
index a5db1dd..fc3e213 100644
--- a/doc/src/man/rmr_trace_ref.3.xfm
+++ b/doc/src/man/rmr_trace_ref.3.xfm
@@ -24,19 +24,8 @@
 	Date		11 July 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_tralloc_msg.3.xfm b/doc/src/man/rmr_tralloc_msg.3.xfm
index 64a0d72..0f26cf1 100644
--- a/doc/src/man/rmr_tralloc_msg.3.xfm
+++ b/doc/src/man/rmr_tralloc_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		19 April 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_wh_close.3.xfm b/doc/src/man/rmr_wh_close.3.xfm
index 3ee4b34..e122a28 100644
--- a/doc/src/man/rmr_wh_close.3.xfm
+++ b/doc/src/man/rmr_wh_close.3.xfm
@@ -24,19 +24,8 @@
 	Date		21 February 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_wh_open.3.xfm b/doc/src/man/rmr_wh_open.3.xfm
index c271651..417a7de 100644
--- a/doc/src/man/rmr_wh_open.3.xfm
+++ b/doc/src/man/rmr_wh_open.3.xfm
@@ -24,19 +24,8 @@
 	Date		20 February 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/rmr_wh_send_msg.3.xfm b/doc/src/man/rmr_wh_send_msg.3.xfm
index 38bf85f..460d9cb 100644
--- a/doc/src/man/rmr_wh_send_msg.3.xfm
+++ b/doc/src/man/rmr_wh_send_msg.3.xfm
@@ -23,19 +23,8 @@
 	Date		28 January 2019
 .fi
 
-.** if formatting with tfm, the roff.im will cause roff output to be generated
-.** if formatting with pfm, then pretty postscript will be generated
 .gv e LIB lib
-.if pfm
-	.im &{lib}/generic_ps.im
-.ei
-	.gv e OUTPUT_RST use_rst
-	.if .ev &use_rst 1 = 
-		.im &{lib}/rst.im
-	.ei
-		.im &{lib}/roff.im
-	.fi
-.fi
+.im &{lib}/man/setup.im 
 
 &line_len(6i)
 
diff --git a/doc/src/man/setup.im b/doc/src/man/setup.im
new file mode 100644
index 0000000..546dfa1
--- /dev/null
+++ b/doc/src/man/setup.im
@@ -0,0 +1,53 @@
+.if false
+==================================================================================
+	Copyright (c) 2019 Nokia
+	Copyright (c) 2018-2019 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+.fi
+
+.if false
+	Mnemonic:	setup.im
+	Abstract:	Look at environment variables and pull in the correct setup prep
+				imbed file based on the desired output type (when running tfm).
+				Obviously, when running pfm we are always generating postscirpt
+				so this isn't really doing much.
+	Date:		29 July 2019
+.fi
+
+
+.gv e LIB lib
+.if ! lib
+	.dv lib ..
+.fi
+
+.** CAUTION:  xfm comparisons are reverse polish so  "a b ="  is true if a == b.
+.if pfm
+	.im &{lib}/generic_ps.im
+.ei
+	.gv e OUTPUT_TYPE ot
+	.if "&ot" "txt" =
+		.im &{lib}/txt.im
+	.fi
+	.if "&ot" "rst" =
+		.im &{lib}/rst.im
+	.fi
+	.if "&ot" "markdown" =
+		.im &{lib}/markdown.im
+	.fi
+	.if "&ot" "troff" =
+		.im &{lib}/roff.im
+	.fi
+.fi
+.xx 0
diff --git a/doc/src/markdown.im b/doc/src/markdown.im
new file mode 100644
index 0000000..f31281d
--- /dev/null
+++ b/doc/src/markdown.im
@@ -0,0 +1,121 @@
+.if false
+==================================================================================
+	Copyright (c) 2019 Nokia
+	Copyright (c) 2018-2019 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+.fi
+
+.if false
+	Mnemonic:	markdown.im
+	Abstract:	This is a setup for a very basic generation of markdown from the few
+				macros which are designed for the RMR doc.  It is very scaled down from
+				the markdown imbed file supplied with {X}fm.
+
+	Author:		E. Scott Danils
+	Date:		26 October 2016
+-------------------------------------------------------------------------------
+.fi
+
+
+.dh 1 m=.5i  e=no s=21 i=0 p=16 f=Helvetica-bold
+.dh 2  m=.5i s=21 i=0      p=14 f=Helvetica-bold
+.dh 3  m=.5i s=10 i=0      p=12 f=Helvetica-bold
+
+.ju on
+.hn off
+
+
+.** super sccript number for start_note macro
+.dv ss_num 1
+
+.**  these macros are common for prfm/tfm, markdown will override some
+.dv indent .ll -.5i .in +.25i
+.dv uindent .in -.25i .ll +.5i
+.dv smindent .ll -.2i .in +.1i
+.dv smuindent .in -.1i .ll +.2i
+
+.dv def_list .bd $1
+.dv end_dlist .ed
+.dv bd .bd $1
+.dv ed .ed
+
+.dv ex_start .sp .5 .ll -.25i .in +.25i .sf Courier .st ^&extextsize .fo off
+.** ex_end macro calls _must_ be placed in col 0 to cause an exit from no-format mode.
+.dv ex_end .fo on .sf ^&textfont .st ^&textsize .in -.25i .ll +.25i .sp .1
+
+.dv h1 .sp .1 .h1 $1
+.dv h2 .sp .1 .h2 $1
+.dv h3 .sp .1 .h3 $1
+.dv di .di $1 ^:
+
+.dv super .sm ^[ .sm ^&{ss_num}]
+.dv note .dv ss_num ^[ ^&ss_num 1 + ] ^: .sm ^[ .sm ^&{ss_num}]
+
+.dv start_note .cn start atend Times-roman 8p .5i
+.dv end_note .cn end
+.dv bold $1
+.dv cw $1
+.dv set_font_prop
+.dv ital $1
+.dv lic1 *
+.dv lic2 +
+
+.dv line_len .ll $1
+.dv space .sp 1
+.dv half_space .sp 1
+
+.** -----------------------------------------------
+.** not used, but might be needed if doc expanded
+.** .dv ta .br  ^.ta .br |
+.** .dv et .br ^.et .br
+.** .dv cl |
+.** .dv tr | .br ^.tr .br |
+.** .dv table_head $1
+.** .dv empty_cell &nbsp;
+.** -----------------------------------------------
+
+.dv break .sm ^`  ^` .br
+.dv br .sm ^`  ^` .br
+.ju off
+.dv image .ep ^[ .sm $2] ($3)
+
+.** no concept of a definition list in markdown; no start/end and just make the text bold to emulate
+.dv beg_dlist  .sp 1
+.dv bd  .sp 1
+.dv end_dlist .sp 1
+.dv ed .sp 1
+.dv di ^&break  **$1:**
+
+.dv beg_list .bl *
+.dv item .li
+.dv li .li
+.dv end_list .el
+
+.dv line .sp 1  ------
+
+.** leading indention is significant to markdown, so turn it off
+.in 0
+.dv indent
+.dv uindent .sp 2
+.dv smindent
+.dv smuindent .sp 2
+.dv bold ** .sm $1 .sm **
+.dv ital _ .sm $1 .sm _
+.dv h1 .sp 2 # $1 .br
+.dv h2 .sp 1 ## $1 .br
+.dv h3 .sp 1 ### $1 .br
+
+.dv ex_start .sp .5 .ll -4 .in .5i .sp 2 .fo off
+.dv ex_end .fo on .in 0i .ll +4 .sp 2
diff --git a/doc/src/txt.im b/doc/src/txt.im
new file mode 100644
index 0000000..bf57bf4
--- /dev/null
+++ b/doc/src/txt.im
@@ -0,0 +1,89 @@
+.if false
+==================================================================================
+	Copyright (c) 2019 Nokia
+	Copyright (c) 2018-2019 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+.fi
+
+.if false
+	Mnemonic:	txt.im
+	Abstract:	To generate raw ASCII we just need to 'disable' the macros which
+				are defined to support things like troff, markdown and rts.
+				For each of those macros, we just map to real {X}fm commandd
+				which do the right thing when generating real .txt output.
+
+	Author:		E. Scott Daniels
+	Date:		29 July 2019
+
+.fi
+
+
+.cd 1 6.5i i=0
+.in .25i
+
+.** paragraph headers
+.dv h1 .h1 $1
+.dv h2 .h2 $1
+.dv h3 .h3 $1
+.dv h4 .h4 $1
+
+.dh 1 s=2,1 i=.25i
+.dh 2 s=1,1 i=.25i
+.dh 3 s=1,0 i=.25i
+.hn off
+
+.dv fig .fi t=figure
+.dv set_font_cw
+
+.dv nf  .sp 1 ^:^: .br .ll -2 .in +2
+.dv fo  .in -2 .ll +2 .sp 1
+
+.dv indent .ll -.25i .in +.25i
+.dv uindent .in -.25i .ll +.25i
+
+.dv lic1 *
+.dv lic2 +
+.dv lic3 -
+
+.dv line_len .ll $1
+.dv space .sp 1
+.dv half_space .sp 1
+.dv beg_list .sp 1 .dv lic $1 ^:
+.dv end_list .sp 1
+
+.dv beg_dlist .sp 1 .bd $1
+.dv end_dlist .ed
+
+.** for now we allow only a single layer of defitems
+.dv di .di $1 ^:
+.dv diitem  .di $1 ^:
+.dv item .li
+
+.dv ex_start .sp 1 .ll -2 .in +2 .nf
+.dv ex_end .fo on .in -2 .ll +2 .sp 1
+
+.** fonts and font macros
+.dv ital $1
+.dv bold $1
+.dv cw $1
+.dv set_font_prop
+
+.dv table .sp 1 ^[table not supported in plain txt output]  .if false
+.dv tab_cell
+.dv tab_row
+.dv end_table .fi
+
+.ju on
+