aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--TODO8
-rw-r--r--html.c22
-rw-r--r--html.h5
-rw-r--r--mandoc.110
-rw-r--r--mdoc_html.c4
5 files changed, 32 insertions, 17 deletions
diff --git a/TODO b/TODO
index 25f8f10f..14289756 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.271 2018/10/02 12:18:33 schwarze Exp $
+* $Id: TODO,v 1.272 2018/10/02 12:33:36 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -395,12 +395,6 @@ are mere guesses, and some may be wrong.
only if the new option -O toc is given
suggested by Adam Kalisz during EuroBSDCon 2018
-- support -O man with two arguments, typically using the first for
- a local tree (like the release pages on mandoc.bsd.lv) and the
- second for a remote tree (e.g. man.openbsd.org).
- Probable syntax: -O man=first;second
- Suggested by kristaps@ during EuroBSDCon 2018.
-
- wrap Sh and Ss content into <div>
Laura Morales <lauretas at mail dot com> 21 Apr 2018 18:10:48 +0200
(Evaluate whether this is really useful and has no adverse
diff --git a/html.c b/html.c
index b97f3577..5078864f 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.239 2018/08/16 13:54:06 schwarze Exp $ */
+/* $Id: html.c,v 1.240 2018/10/02 12:33:37 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -18,6 +18,7 @@
#include "config.h"
#include <sys/types.h>
+#include <sys/stat.h>
#include <assert.h>
#include <ctype.h>
@@ -128,7 +129,10 @@ html_alloc(const struct manoutput *outopts)
h->tag = NULL;
h->style = outopts->style;
- h->base_man = outopts->man;
+ if ((h->base_man1 = outopts->man) == NULL)
+ h->base_man2 = NULL;
+ else if ((h->base_man2 = strchr(h->base_man1, ';')) != NULL)
+ *h->base_man2++ = '\0';
h->base_includes = outopts->includes;
if (outopts->fragment)
h->oflags |= HTML_FRAGMENT;
@@ -467,9 +471,21 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
static void
print_href(struct html *h, const char *name, const char *sec, int man)
{
+ struct stat sb;
const char *p, *pp;
+ char *filename;
+
+ if (man) {
+ pp = h->base_man1;
+ if (h->base_man2 != NULL) {
+ mandoc_asprintf(&filename, "%s.%s", name, sec);
+ if (stat(filename, &sb) == -1)
+ pp = h->base_man2;
+ free(filename);
+ }
+ } else
+ pp = h->base_includes;
- pp = man ? h->base_man : h->base_includes;
while ((p = strchr(pp, '%')) != NULL) {
print_encode(h, pp, p, 1);
if (man && p[1] == 'S') {
diff --git a/html.h b/html.h
index 6d44a473..606dd76d 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.92 2018/06/25 16:54:59 schwarze Exp $ */
+/* $Id: html.h,v 1.93 2018/10/02 12:33:37 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -101,7 +101,8 @@ struct html {
struct tag *tag; /* last open tag */
struct rofftbl tbl; /* current table */
struct tag *tblt; /* current open table scope */
- char *base_man; /* base for manpage href */
+ char *base_man1; /* bases for manpage href */
+ char *base_man2;
char *base_includes; /* base for include href */
char *style; /* style-sheet URI */
struct tag *metaf; /* current open font scope */
diff --git a/mandoc.1 b/mandoc.1
index 59350d9f..c35ef73a 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.228 2018/08/25 16:53:38 schwarze Exp $
+.\" $Id: mandoc.1,v 1.229 2018/10/02 12:33:37 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 25 2018 $
+.Dd $Mdocdate: October 2 2018 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -345,7 +345,7 @@ Instances of
are replaced with the include filename.
The default is not to present a
hyperlink.
-.It Cm man Ns = Ns Ar fmt
+.It Cm man Ns = Ns Ar fmt Ns Op ; Ns Ar fmt
The string
.Ar fmt ,
for example,
@@ -361,6 +361,10 @@ are replaced with the linked manual's name and section, respectively.
If no section is included, section 1 is assumed.
The default is not to
present a hyperlink.
+If two formats are given and a file
+.Ar %N.%S
+exists in the current directory, the first format is used;
+otherwise, the second format is used.
.It Cm style Ns = Ns Ar style.css
The file
.Ar style.css
diff --git a/mdoc_html.c b/mdoc_html.c
index 238fc799..fd181b60 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.311 2018/08/17 20:33:37 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.312 2018/10/02 12:33:37 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -611,7 +611,7 @@ mdoc_xr_pre(MDOC_ARGS)
if (NULL == n->child)
return 0;
- if (h->base_man)
+ if (h->base_man1)
print_otag(h, TAG_A, "cThM", "Xr",
n->child->string, n->child->next == NULL ?
NULL : n->child->next->string);