to the first word, or the first few words if they are short.
man_html.o: man_html.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h html.h main.h
man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
man_term.o: man_term.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h term.h term_tag.h main.h
-man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h tag.h man.h libmandoc.h roff_int.h libman.h
+man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h tag.h
mandoc.o: mandoc.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h roff_int.h
mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h
mandoc_msg.o: mandoc_msg.c config.h mandoc.h
mdoc_markdown.o: mdoc_markdown.c mandoc_aux.h mandoc.h roff.h mdoc.h main.h
mdoc_state.o: mdoc_state.c mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
mdoc_term.o: mdoc_term.c config.h mandoc_aux.h roff.h mdoc.h out.h term.h term_tag.h main.h
-mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h tag.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h tag.h
msec.o: msec.c config.h mandoc.h libmandoc.h msec.in
out.o: out.c config.h mandoc_aux.h tbl.h out.h
preconv.o: preconv.c config.h mandoc.h roff.h mandoc_parse.h libmandoc.h
-read.o: read.c config.h mandoc_aux.h mandoc.h roff.h tag.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h
+read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h tag.h
roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in
roff_html.o: roff_html.c mandoc.h roff.h out.h html.h
roff_term.o: roff_term.c mandoc.h roff.h out.h term.h
roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h
soelim.o: soelim.c config.h compat_stringlist.h
st.o: st.c config.h mandoc.h roff.h libmdoc.h
-tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h mdoc.h tag.h
+tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h mdoc.h roff_int.h tag.h
tbl.o: tbl.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_parse.h tbl_int.h
tbl_data.o: tbl_data.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h
tbl_html.o: tbl_html.c config.h mandoc.h roff.h tbl.h out.h html.h
term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h manconf.h main.h
term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h manconf.h main.h
term_tab.o: term_tab.c mandoc_aux.h out.h term.h
-term_tag.o: term_tag.c config.h mandoc.h roff.h tag.h term_tag.h
+term_tag.o: term_tag.c config.h mandoc.h roff.h roff_int.h tag.h term_tag.h
tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h tbl.h eqn.h main.h
-/* $Id: html.c,v 1.267 2020/04/08 11:56:03 schwarze Exp $ */
+/* $Id: html.c,v 1.268 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
void
print_text(struct html *h, const char *word)
{
+ print_tagged_text(h, word, NULL);
+}
+
+void
+print_tagged_text(struct html *h, const char *word, struct roff_node *n)
+{
+ struct tag *t;
+ char *href;
+
/*
* Always wrap text in a paragraph unless already contained in
* some flow container; never put it directly into a section.
}
/*
- * Print the text, optionally surrounded by HTML whitespace,
- * optionally manually switching fonts before and after.
+ * Optionally switch fonts, optionally write a permalink, then
+ * print the text, optionally surrounded by HTML whitespace.
*/
assert(h->metaf == NULL);
print_metaf(h);
print_indent(h);
+
+ if (n != NULL && (href = html_make_id(n, 0)) != NULL) {
+ t = print_otag(h, TAG_A, "chR", "permalink", href);
+ free(href);
+ } else
+ t = NULL;
+
if ( ! print_encode(h, word, NULL, 0)) {
if ( ! (h->flags & HTML_NONOSPACE))
h->flags &= ~HTML_NOSPACE;
if (h->metaf != NULL) {
print_tagq(h, h->metaf);
h->metaf = NULL;
- }
+ } else if (t != NULL)
+ print_tagq(h, t);
h->flags &= ~HTML_IGNDELIM;
}
-/* $Id: html.h,v 1.107 2020/03/13 15:32:28 schwarze Exp $ */
+/* $Id: html.h,v 1.108 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
struct roff_node *);
void print_tagq(struct html *, const struct tag *);
void print_stagq(struct html *, const struct tag *);
+void print_tagged_text(struct html *, const char *,
+ struct roff_node *);
void print_text(struct html *, const char *);
void print_tblclose(struct html *);
void print_tbl(struct html *, const struct tbl_span *);
-/* $Id: man_validate.c,v 1.152 2020/04/04 20:33:33 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.153 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
#include "mandoc_aux.h"
#include "mandoc.h"
#include "roff.h"
-#include "tag.h"
#include "man.h"
#include "libmandoc.h"
#include "roff_int.h"
#include "libman.h"
+#include "tag.h"
#define CHKARGS struct roff_man *man, struct roff_node *n
-/* $Id: mdoc_html.c,v 1.338 2020/04/06 10:16:17 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.339 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
}
t = h->tag;
t->refcnt++;
- if (NODE_DELIMC & n->flags)
+ if (n->flags & NODE_DELIMC)
h->flags |= HTML_NOSPACE;
- print_text(h, n->string);
- if (NODE_DELIMO & n->flags)
+ if (n->flags & NODE_HREF)
+ print_tagged_text(h, n->string, n);
+ else
+ print_text(h, n->string);
+ if (n->flags & NODE_DELIMO)
h->flags |= HTML_NOSPACE;
break;
case ROFFT_EQN:
-/* $Id: mdoc_validate.c,v 1.384 2020/04/08 11:56:03 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.385 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
#include "mandoc.h"
#include "mandoc_xr.h"
#include "roff.h"
-#include "tag.h"
#include "mdoc.h"
#include "libmandoc.h"
#include "roff_int.h"
#include "libmdoc.h"
+#include "tag.h"
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
-/* $Id: read.c,v 1.217 2020/04/07 22:56:02 schwarze Exp $ */
+/* $Id: read.c,v 1.218 2020/04/18 20:40:10 schwarze Exp $ */
/*
- * Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org>
*
#include "mandoc_aux.h"
#include "mandoc.h"
#include "roff.h"
-#include "tag.h"
#include "mdoc.h"
#include "man.h"
#include "mandoc_parse.h"
#include "libmandoc.h"
#include "roff_int.h"
+#include "tag.h"
#define REPARSE_LIMIT 1000
mdoc_validate(curp->man);
else
man_validate(curp->man);
- tag_postprocess(curp->man->meta.first);
+ tag_postprocess(curp->man, curp->man->meta.first);
}
return &curp->man->meta;
}
-<p class="Pp" id="npara">normal paragraph</p>
+<p class="Pp" id="npara"><a class="permalink" href="#npara">normal</a>
+ paragraph</p>
<div class="Bd Pp" id="filled">filled display
-<p class="Pp" id="fpara">paragraph in display</p>
+<p class="Pp" id="fpara"><a class="permalink" href="#fpara">paragraph</a> in
+ display</p>
</div>
back to normal
<p class="Pp">another paragraph</p>
unfilled
display
<mark id="upara"></mark>
-unfilled
+<a class="permalink" href="#upara">unfilled</a>
paragraph
</pre>
</div>
-# $OpenBSD: Makefile,v 1.7 2020/04/06 09:55:50 schwarze Exp $
+# $OpenBSD: Makefile,v 1.8 2020/04/18 20:28:46 schwarze Exp $
REGRESS_TARGETS = arg
TAG_TARGETS = arg
LINT_TARGETS = arg
+HTML_TARGETS = arg
.include <bsd.regress.mk>
-.\" $OpenBSD: arg.in,v 1.5 2020/04/06 09:55:50 schwarze Exp $
-.Dd $Mdocdate: April 6 2020 $
+.\" $OpenBSD: arg.in,v 1.6 2020/04/18 20:28:46 schwarze Exp $
+.Dd $Mdocdate: April 18 2020 $
.Dt PP-ARG 1
.Os
.Sh NAME
.Nm Pp-arg
.Nd paragraph macro with arguments
.Sh DESCRIPTION
+BEGINTEST
+.Pp
line 1
.Tg first
.Pp drop this
.Tg last
.Pp
final text
+.Pp
+ENDTEST
P\bPp\bp-\b-a\bar\brg\bg - paragraph macro with arguments
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ BEGINTEST
+
line 1
line 2
final text
-OpenBSD April 6, 2020 OpenBSD
+ ENDTEST
+
+OpenBSD April 18, 2020 OpenBSD
--- /dev/null
+<p class="Pp">line 1</p>
+<p class="Pp" id="first"><a class="permalink" href="#first">line 2</a>
+ <br/>
+ line 3</p>
+<p class="Pp">line 4</p>
+<p class="Pp" id="last"><a class="permalink" href="#last">final</a> text</p>
-mandoc: arg.in:13:5: ERROR: skipping all arguments: br drop this
-mandoc: arg.in:15:8: ERROR: skipping excess arguments: sp ... drop this
-mandoc: arg.in:11:2: ERROR: skipping all arguments: Pp drop
+mandoc: arg.in:15:5: ERROR: skipping all arguments: br drop this
+mandoc: arg.in:17:8: ERROR: skipping excess arguments: sp ... drop this
+mandoc: arg.in:13:2: ERROR: skipping all arguments: Pp drop
# DESCRIPTION
+BEGINTEST
+
line 1
line 2
line 4
-final text
+final
+text
+
+ENDTEST
-OpenBSD - April 6, 2020
+OpenBSD - April 18, 2020
NAME 3
DESCRIPTION 6
-first 9
-last 14
+first 11
+last 16
sp Pp:
-Double sp:
+Double
+sp:
br blank:
-/* $Id: tag.c,v 1.34 2020/04/08 11:56:04 schwarze Exp $ */
+/* $Id: tag.c,v 1.35 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze <schwarze@openbsd.org>
*
#include "mandoc_ohash.h"
#include "roff.h"
#include "mdoc.h"
+#include "roff_int.h"
#include "tag.h"
struct tag_entry {
* to the beginning of the respective paragraphs.
*/
void
-tag_postprocess(struct roff_node *n)
+tag_postprocess(struct roff_man *man, struct roff_node *n)
{
+ struct roff_node *nn;
+ char *cp;
+
if (n->flags & NODE_ID) {
switch (n->tok) {
+ case MDOC_Pp:
+ nn = n->next;
+ if (nn == NULL || nn->type != ROFFT_TEXT ||
+ *nn->string == '\0' || *nn->string == ' ')
+ break;
+ /* Use the first few letters for the permalink. */
+ cp = nn->string;
+ while (cp != NULL && cp - nn->string < 5)
+ cp = strchr(cp + 1, ' ');
+ if (cp != NULL && cp[1] != '\0') {
+ /* Split a longer text node. */
+ man->last = nn;
+ man->next = ROFF_NEXT_SIBLING;
+ roff_word_alloc(man, nn->line,
+ nn->pos + (cp - nn->string), cp + 1);
+ man->last->flags = nn->flags;
+ *cp = '\0';
+ }
+ assert(nn->tag == NULL);
+ nn->tag = mandoc_strdup(n->tag);
+ nn->flags |= NODE_HREF;
+ break;
case MDOC_Bd:
case MDOC_Bl:
- case MDOC_Pp:
/* XXX No permalink for now. */
break;
default:
}
}
for (n = n->child; n != NULL; n = n->next)
- tag_postprocess(n);
+ tag_postprocess(man, n);
}
-/* $Id: tag.h,v 1.13 2020/04/07 22:56:02 schwarze Exp $ */
+/* $Id: tag.h,v 1.14 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2015, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org>
*
void tag_alloc(void);
int tag_exists(const char *);
void tag_put(const char *, int, struct roff_node *);
-void tag_postprocess(struct roff_node *);
+void tag_postprocess(struct roff_man *, struct roff_node *);
void tag_free(void);
-/* $Id: term_tag.c,v 1.3 2020/04/08 11:56:04 schwarze Exp $ */
+/* $Id: term_tag.c,v 1.4 2020/04/18 20:40:10 schwarze Exp $ */
/*
* Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze <schwarze@openbsd.org>
*
#include "mandoc.h"
#include "roff.h"
+#include "roff_int.h"
#include "tag.h"
#include "term_tag.h"