# -ms-specific stuff for tc2html

# this helps to map -ms macros onto tc2hmtl concepts

# When a name is redefined below, it's first removed.  This is because groff
# aliases many of the macros to an error macro until .TL is seen.  Unless
# a given name is removed before being redefined, redefining it would also
# redefine all the other names that are aliases for it!

# define an internal-use-only request to reset the paragraph state

req reset*para*params eol \
		break font R fill adjust b \
		point-size 10 spacing 12 line-spacing 1

imm remove-name n TL
req TL parse-macro-args eol \
		push-string ".reset*para*params\n" \
		adjust c \
		push-string ".H*title\n" font "R"

imm remove-name n AU
req AU parse-macro-args eol \
		push-string ".reset*para*params\n" \
		adjust c nofill \
		push-string ".H*para\n" font "I"

imm remove-name n AI
req AI parse-macro-args eol \
		push-string ".reset*para*params\n" \
		adjust c nofill \
		push-string ".H*para\n" font "R"

imm remove-name n AB
req AB parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".if !'$1'no' \\{\\\n.H*para\n.ce\n\\fIABSTRACT\\fR\n.sp\n.\\}\n" \
		push-string ".H*bq" font "R"

imm remove-name n AE
req AE parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".H*bq*end" font "R"

imm remove-name n LP
req LP parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".H*para\n" font "R"

# write indented paragraphs as a definition list
imm remove-name n IP
req IP parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".H*dterm\n" font "R" \
		push-string "$1\n" \
		push-string ".H*ddesc\n"

imm remove-name n DS
req DS parse-macro-args eol \
		push-string ".reset*para*params\n" \
		nofill \
		push-string ".H*disp*indent 3" \
		push-string ".H*disp" font "R"

imm remove-name n DE
req DE parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".H*disp*end" font "R"

imm remove-name n RS
req RS parse-macro-args eol \
		break \
		push-string ".H*shift*right\n"

imm remove-name n RE
req RE parse-macro-args eol \
		break \
		push-string ".H*shift*left\n"

imm remove-name n SH
req SH parse-macro-args eol \
		push-string ".reset*para*params\n" \
		push-string ".H*atoc 1\n" \
		push-string ".H*header 2\n" \
		input-trap 1 H*header*capture

# if the argument is missing, use "1".  Then generate, for argument
# N, a level-N TOC entry and a level-(N+1) header using the line
# following the .NH request.  Note that this doesn't handle the
# optional second argument to .NH, and thus botches it if that argument
# is present...
imm remove-name n NH
req NH parse-num x eol \
		push-string ".reset*para*params\n" \
		push-string ".if '$1'' .nr H*NH*level 1 1\n" \
		push-string ".if !'$1'' .nr H*NH*level $1 1\n" \
		push-string ".H*atoc \\n[H*NH*level]\n" \
		push-string ".H*header \\n+[H*NH*level]\n" \
		input-trap 1 H*header*capture

# have to define H*header*capture this way because the input-trap macro
# must really be a macro, not a troffcvt request.
imm push-string ".de H*header*capture\n.H*header*end\n.H*aend\n..\n"

# Footnote support.  All these versions of .FS/.FE do is bracket the
# footnote text with "[[footnote:" and "]]" so that at least the
# footnote can be recognized for what it is.

imm remove-name n FS
req FS eol push-string "[[footnote:\n"

imm remove-name n FE
req FE eol push-string "]]\n"
