[BACK]Return to macro.h CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / docbook2mdoc

File: [cvsweb.bsd.lv] / docbook2mdoc / macro.h (download)

Revision 1.2, Thu Mar 28 20:41:33 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.1: +4 -1 lines

Implement a formatter for <author> elements,
handling <contrib>, <personname>, <firstname>, <othername>, <surname>,
as well as arbitrary children properly.

This required minor work on the formatting infrastructure:
Improve macro_addnode() such that it also handles text nodes.
Add a companion function print_textnode().
Let print_text() optionally work without ARG_SPACE.

Triggered by a report from Stephen Gregoratto <dev at sgregoratto
dot me> that and how GTK documentation uses <contrib>.

/* $Id: macro.h,v 1.2 2019/03/28 20:41:33 schwarze Exp $ */
/*
 * Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * The interface of the macro line formatter,
 * a part of the mdoc(7) formatter.
 */

enum	linestate {
	LINE_NEW = 0,	/* At the beginning of a new line. */
	LINE_TEXT,	/* In the middle of a text line. */
	LINE_MACRO	/* In the middle of a macro line. */
};

struct	format {
	int		 level;      /* Header level, starting at 1. */
	enum linestate	 linestate;
};

#define	ARG_SPACE	1  /* Insert whitespace before this argument. */
#define	ARG_SINGLE	2  /* Quote argument if it contains whitespace. */
#define	ARG_QUOTED	4  /* We are already in a quoted argument. */
#define	ARG_UPPER	8  /* Covert argument to upper case. */


void	 macro_open(struct format *, const char *);
void	 macro_close(struct format *);
void	 macro_line(struct format *, const char *);
void	 macro_closepunct(struct format *, struct pnode *);

void	 macro_addarg(struct format *, const char *, int);
void	 macro_argline(struct format *, const char *, const char *);
void	 macro_addnode(struct format *, struct pnode *, int);
void	 macro_nodeline(struct format *, const char *, struct pnode *, int);

void	 print_text(struct format *, const char *, int);
void	 print_textnode(struct format *, struct pnode *);