Print this page
9718 update mandoc to 1.14.4
   1 /*      $Id: mdoc_markdown.c,v 1.23 2017/06/14 01:31:26 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
   4  *
   5  * Permission to use, copy, modify, and distribute this software for any
   6  * purpose with or without fee is hereby granted, provided that the above
   7  * copyright notice and this permission notice appear in all copies.
   8  *
   9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16  */
  17 #include <sys/types.h>
  18 
  19 #include <assert.h>
  20 #include <ctype.h>
  21 #include <stdio.h>


 277         md_word("-");
 278         md_word(mdoc->meta.date);
 279         putchar('\n');
 280 }
 281 
 282 static void
 283 md_nodelist(struct roff_node *n)
 284 {
 285         while (n != NULL) {
 286                 md_node(n);
 287                 n = n->next;
 288         }
 289 }
 290 
 291 static void
 292 md_node(struct roff_node *n)
 293 {
 294         const struct md_act     *act;
 295         int                      cond, process_children;
 296 
 297         if (n->flags & NODE_NOPRT)
 298                 return;
 299 
 300         if (outflags & MD_nonl)
 301                 outflags &= ~(MD_nl | MD_sp);
 302         else if (outflags & MD_spc && n->flags & NODE_LINE)
 303                 outflags |= MD_nl;
 304 
 305         act = NULL;
 306         cond = 0;
 307         process_children = 1;
 308         n->flags &= ~NODE_ENDED;
 309 
 310         if (n->type == ROFFT_TEXT) {
 311                 if (n->flags & NODE_DELIMC)
 312                         outflags &= ~(MD_spc | MD_spc_force);
 313                 else if (outflags & MD_Sm)
 314                         outflags |= MD_spc_force;
 315                 md_word(n->string);
 316                 if (n->flags & NODE_DELIMO)
 317                         outflags &= ~(MD_spc | MD_spc_force);


   1 /*      $Id: mdoc_markdown.c,v 1.24 2018/04/11 17:11:13 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
   4  *
   5  * Permission to use, copy, modify, and distribute this software for any
   6  * purpose with or without fee is hereby granted, provided that the above
   7  * copyright notice and this permission notice appear in all copies.
   8  *
   9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16  */
  17 #include <sys/types.h>
  18 
  19 #include <assert.h>
  20 #include <ctype.h>
  21 #include <stdio.h>


 277         md_word("-");
 278         md_word(mdoc->meta.date);
 279         putchar('\n');
 280 }
 281 
 282 static void
 283 md_nodelist(struct roff_node *n)
 284 {
 285         while (n != NULL) {
 286                 md_node(n);
 287                 n = n->next;
 288         }
 289 }
 290 
 291 static void
 292 md_node(struct roff_node *n)
 293 {
 294         const struct md_act     *act;
 295         int                      cond, process_children;
 296 
 297         if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
 298                 return;
 299 
 300         if (outflags & MD_nonl)
 301                 outflags &= ~(MD_nl | MD_sp);
 302         else if (outflags & MD_spc && n->flags & NODE_LINE)
 303                 outflags |= MD_nl;
 304 
 305         act = NULL;
 306         cond = 0;
 307         process_children = 1;
 308         n->flags &= ~NODE_ENDED;
 309 
 310         if (n->type == ROFFT_TEXT) {
 311                 if (n->flags & NODE_DELIMC)
 312                         outflags &= ~(MD_spc | MD_spc_force);
 313                 else if (outflags & MD_Sm)
 314                         outflags |= MD_spc_force;
 315                 md_word(n->string);
 316                 if (n->flags & NODE_DELIMO)
 317                         outflags &= ~(MD_spc | MD_spc_force);