From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Append .html suffix to temporary files enabling browsers to
Date: Tue, 30 Mar 2021 12:17:25 -0500 (EST) [thread overview]
Message-ID: <c2a897991c36e067@mandoc.bsd.lv> (raw)
Log Message:
-----------
Append .html suffix to temporary files enabling browsers to recognise it.
Occasionally one might read a manual page in a webbrowser, e.g.
"MANPAGER=firefox man -T html jq", however temporary files created for
pagers lack file extensions and most web browsers are unable to detect a
file's content without it.
Special case mandoc(1)'s HTML output format by appending the ".html" suffix
to file names such that browsers will actually render HTML as such instead
of showing it as plain text.
Idea and patch from kn@, with minor help from me.
Modified Files:
--------------
mandoc:
main.c
term_tag.c
term_tag.h
Revision Data
-------------
Index: term_tag.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term_tag.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lterm_tag.h -Lterm_tag.h -u -p -r1.3 -r1.4
--- term_tag.h
+++ term_tag.h
@@ -28,7 +28,7 @@ struct tag_files {
};
-struct tag_files *term_tag_init(const char *, const char *);
+struct tag_files *term_tag_init(const char *, const char *, const char *);
void term_tag_write(struct roff_node *, size_t);
int term_tag_close(void);
void term_tag_unlink(void);
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.353
retrieving revision 1.354
diff -Lmain.c -Lmain.c -u -p -r1.353 -r1.354
--- main.c
+++ main.c
@@ -846,6 +846,7 @@ process_onefile(struct mparse *mp, struc
if (outst->use_pager) {
outst->use_pager = 0;
outst->tag_files = term_tag_init(conf->output.outfilename,
+ outst->outtype == OUTT_HTML ? ".html" : "",
conf->output.tagfilename);
#if HAVE_PLEDGE
if ((conf->output.outfilename != NULL ||
Index: term_tag.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term_tag.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lterm_tag.c -Lterm_tag.c -u -p -r1.5 -r1.6
--- term_tag.c
+++ term_tag.c
@@ -47,7 +47,8 @@ static struct tag_files tag_files;
* but for simplicity, create it anyway.
*/
struct tag_files *
-term_tag_init(const char *outfilename, const char *tagfilename)
+term_tag_init(const char *outfilename, const char *suffix,
+ const char *tagfilename)
{
struct sigaction sa;
int ofd; /* In /tmp/, dup(2)ed to stdout. */
@@ -85,9 +86,9 @@ term_tag_init(const char *outfilename, c
/* Create both temporary output files. */
if (outfilename == NULL) {
- (void)strlcpy(tag_files.ofn, "/tmp/man.XXXXXXXXXX",
- sizeof(tag_files.ofn));
- if ((ofd = mkstemp(tag_files.ofn)) == -1) {
+ (void)snprintf(tag_files.ofn, sizeof(tag_files.ofn),
+ "/tmp/man.XXXXXXXXXX%s", suffix);
+ if ((ofd = mkstemps(tag_files.ofn, strlen(suffix))) == -1) {
mandoc_msg(MANDOCERR_MKSTEMP, 0, 0,
"%s: %s", tag_files.ofn, strerror(errno));
goto fail;
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2021-03-30 17:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2a897991c36e067@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).