Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SOLDOUT(3)		    Library Functions Manual		    SOLDOUT(3)

NAME
       soldout -- markdown parser library

DESCRIPTION
       The  soldout  library  only performs the	parsing	of markdown input, the
       construction of the output is left to a renderer, which	is  a  set  of
       callback	 functions  called  when  markdown  elements  are encountered.
       Pointers	to these functions are gathered	 into  a  struct  mkd_renderer
       along with some renderer-related	data.

       Basic usage will	be:

       1.   Create output, input buffers by bufnew() function.

       2.   Fill input buffer by bufput() function.

       3.   Create struct mkd_renderer or use provided renderer.

       4.   Call markdown() function.

       5.   Process output buffer.

       6.   Call bufrelease() function to clean	up buffers.

EXAMPLES
       Simple  example that uses first argument	as a markdown string, converts
       it to an	HTML and outputs it to stdout.

       #include	<stdio.h>

       #include	<buffer.h>
       #include	<markdown.h>
       #include	<renderers.h>

       #define INPUT_UNIT  1024
       #define OUTPUT_UNIT 64

       int
       main(int	argc, char *argv[])
       {
	 struct	buf *ib, *ob;

	 /* Make sure we have enough arguments.	*/
	 if (argc != 2)	{
	   return 1;
	 }

	 ib = bufnew(INPUT_UNIT);
	 ob = bufnew(OUTPUT_UNIT);

	 /* bufputs() is a wrapper over	bufput() for NUL-terminated string. */
	 bufputs(ib, argv[1]);

	 markdown(ob, ib, &mkd_html);

	 /* Note the resulted data is not NUL-terminated string;
	  * to make it use bufnullterm(). */
	 printf("%.*s",	(int)ob->size, ob->data);

	 bufrelease(ib);
	 bufrelease(ob);
	 return	0;
       }

SEE ALSO
       soldout_array(3),	soldout_buffer(3),	  soldout_markdown(3),
       soldout_renderers(3),	  John	    Gruber's	  markdown     format:
       http://daringfireball.net/projects/markdown/

AUTHORS
       The  soldout  library  was  written  by	Natasha	 "Kerensikova"	 Porte
       <natacha@instinctive.eu>.    Manual  page  was  originally  written  by
       Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc  format  by
       Svyatoslav Mishyn <juef@openmailbox.org>.

FreeBSD	ports 15.0		March 29, 2016			    SOLDOUT(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=soldout&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help