[BACK]Return to mdoc.3 CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/mdoc.3 between version 1.39 and 1.47

version 1.39, 2010/05/25 21:46:48 version 1.47, 2010/07/04 22:04:04
Line 1 
Line 1 
 .\"     $Id$  .\"     $Id$
 .\"  .\"
 .\" Copyright (c) 2009-2010 Kristaps Dzonsons <kristaps@bsd.lv>  .\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
   .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
 .\"  .\"
 .\" Permission to use, copy, modify, and distribute this software for any  .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above  .\" purpose with or without fee is hereby granted, provided that the above
Line 29 
Line 30 
 .Nd mdoc macro compiler library  .Nd mdoc macro compiler library
 .Sh SYNOPSIS  .Sh SYNOPSIS
 .In mandoc.h  .In mandoc.h
   .In regs.h
 .In mdoc.h  .In mdoc.h
 .Vt extern const char * const * mdoc_macronames;  .Vt extern const char * const * mdoc_macronames;
 .Vt extern const char * const * mdoc_argnames;  .Vt extern const char * const * mdoc_argnames;
 .Ft "struct mdoc *"  .Ft "struct mdoc *"
 .Fn mdoc_alloc "void *data" "int pflags" "mandocmsg msgs"  .Fo mdoc_alloc
   .Fa "struct regset *regs"
   .Fa "void *data"
   .Fa "int pflags"
   .Fa "mandocmsg msgs"
   .Fc
 .Ft int  .Ft int
 .Fn mdoc_endparse "struct mdoc *mdoc"  .Fn mdoc_endparse "struct mdoc *mdoc"
 .Ft void  .Ft void
Line 43 
Line 50 
 .Ft "const struct mdoc_node *"  .Ft "const struct mdoc_node *"
 .Fn mdoc_node "const struct mdoc *mdoc"  .Fn mdoc_node "const struct mdoc *mdoc"
 .Ft int  .Ft int
 .Fn mdoc_parseln "struct mdoc *mdoc" "int line" "char *buf"  .Fo mdoc_parseln
   .Fa "struct mdoc *mdoc"
   .Fa "int line"
   .Fa "char *buf"
   .Fc
 .Ft int  .Ft int
 .Fn mdoc_reset "struct mdoc *mdoc"  .Fn mdoc_reset "struct mdoc *mdoc"
 .Sh DESCRIPTION  .Sh DESCRIPTION
Line 112  Function descriptions follow:
Line 123  Function descriptions follow:
 Allocates a parsing structure.  Allocates a parsing structure.
 The  The
 .Fa data  .Fa data
 pointer is passed to callbacks in  pointer is passed to
 .Fa cb ,  .Fa msgs .
 which are documented further in the header file.  
 The  The
 .Fa pflags  .Fa pflags
 arguments are defined in  arguments are defined in
Line 208  and
Line 218  and
 fields), its position in the tree (the  fields), its position in the tree (the
 .Va parent ,  .Va parent ,
 .Va child ,  .Va child ,
   .Va nchild ,
 .Va next  .Va next
 and  and
 .Va prev  .Va prev
 fields) and some type-specific data.  fields) and some type-specific data, in particular, for nodes generated
   from macros, the generating macro in the
   .Va tok
   field.
 .Pp  .Pp
 The tree itself is arranged according to the following normal form,  The tree itself is arranged according to the following normal form,
 where capitalised non-terminals represent nodes.  where capitalised non-terminals represent nodes.
Line 222  where capitalised non-terminals represent nodes.
Line 236  where capitalised non-terminals represent nodes.
 .It mnode  .It mnode
 \(<- BLOCK | ELEMENT | TEXT  \(<- BLOCK | ELEMENT | TEXT
 .It BLOCK  .It BLOCK
 \(<- (HEAD [TEXT])+ [BODY [TEXT]] [TAIL [TEXT]]  \(<- HEAD [TEXT] (BODY [TEXT])+ [TAIL [TEXT]]
 .It BLOCK  
 \(<- BODY [TEXT] [TAIL [TEXT]]  
 .It ELEMENT  .It ELEMENT
 \(<- TEXT*  \(<- TEXT*
 .It HEAD  .It HEAD
 \(<- mnode+  \(<- mnode*
 .It BODY  .It BODY
 \(<- mnode+  \(<- mnode* [ENDBODY mnode*]
 .It TAIL  .It TAIL
 \(<- mnode+  \(<- mnode*
 .It TEXT  .It TEXT
 \(<- [[:printable:],0x1e]*  \(<- [[:printable:],0x1e]*
 .El  .El
 .Pp  .Pp
 Of note are the TEXT nodes following the HEAD, BODY and TAIL nodes of  Of note are the TEXT nodes following the HEAD, BODY and TAIL nodes of
 the BLOCK production.  the BLOCK production: these refer to punctuation marks.
 These refer to punctuation marks.  
 Furthermore, although a TEXT node will generally have a non-zero-length  Furthermore, although a TEXT node will generally have a non-zero-length
 string, in the specific case of  string, in the specific case of
 .Sq \&.Bd \-literal ,  .Sq \&.Bd \-literal ,
 an empty line will produce a zero-length string.  an empty line will produce a zero-length string.
   Multiple body parts are only found in invocations of
   .Sq \&Bl \-column ,
   where a new body introduces a new phrase.
   .Ss Badly-nested Blocks
   The ENDBODY node is available to end the formatting associated
   with a given block before the physical end of that block.
   It has a non-null
   .Va end
   field, is of the BODY
   .Va type ,
   has the same
   .Va tok
   as the BLOCK it is ending, and has a
   .Va pending
   field pointing to that BLOCK's BODY node.
   It is an indirect child of that BODY node
   and has no children of its own.
   .Pp
   An ENDBODY node is generated when a block ends while one of its child
   blocks is still open, like in the following example:
   .Bd -literal -offset indent
   \&.Ao ao
   \&.Bo bo ac
   \&.Ac bc
   \&.Bc end
   .Ed
   .Pp
   This example results in the following block structure:
   .Bd -literal -offset indent
   BLOCK Ao
           HEAD Ao
           BODY Ao
                   TEXT ao
                   BLOCK Bo, pending -> Ao
                           HEAD Bo
                           BODY Bo
                                   TEXT bo
                                   TEXT ac
                                   ENDBODY Ao, pending -> Ao
                                   TEXT bc
   TEXT end
   .Ed
   .Pp
   Here, the formatting of the
   .Sq \&Ao
   block extends from TEXT ao to TEXT ac,
   while the formatting of the
   .Sq \&Bo
   block extends from TEXT bo to TEXT bc.
   It renders as follows in
   .Fl T Ns Cm ascii
   mode:
   .Pp
   .Dl <ao [bo ac> bc] end
   .Pp
   Support for badly-nested blocks is only provided for backward
   compatibility with some older
   .Xr mdoc 7
   implementations.
   Using badly-nested blocks is
   .Em strongly discouraged :
   the
   .Fl T Ns Cm html
   and
   .Fl T Ns Cm xhtml
   front-ends are unable to render them in any meaningful way.
   Furthermore, behaviour when encountering badly-nested blocks is not
   consistent across troff implementations, especially when using  multiple
   levels of badly-nested blocks.
 .Sh EXAMPLES  .Sh EXAMPLES
 The following example reads lines from stdin and parses them, operating  The following example reads lines from stdin and parses them, operating
 on the finished parse tree with  on the finished parse tree with
 .Fn parsed .  .Fn parsed .
 This example does not error-check nor free memory upon failure.  This example does not error-check nor free memory upon failure.
 .Bd -literal -offset indent  .Bd -literal -offset indent
   struct regset regs;
 struct mdoc *mdoc;  struct mdoc *mdoc;
 const struct mdoc_node *node;  const struct mdoc_node *node;
 char *buf;  char *buf;
 size_t len;  size_t len;
 int line;  int line;
   
   bzero(&regs, sizeof(struct regset));
 line = 1;  line = 1;
 mdoc = mdoc_alloc(NULL, 0, NULL);  mdoc = mdoc_alloc(&regs, NULL, 0, NULL);
 buf = NULL;  buf = NULL;
 alloc_len = 0;  alloc_len = 0;
   

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.47

CVSweb