.\" .\" Copyright (c) 2009 - 2016 Natacha Porté .\" .\" 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 AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. .\" .Dd March 29, 2016 .Dt SOLDOUT 3 .Os .Sh NAME .Nm soldout .Nd markdown parser library .Sh DESCRIPTION The .Nm 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 .Vt "struct mkd_renderer" along with some renderer-related data. .Pp Basic usage will be: .Bl -enum .It Create output, input buffers by .Fn bufnew function. .It Fill input buffer by .Fn bufput function. .It Create .Vt "struct mkd_renderer" or use provided renderer. .It Call .Fn markdown function. .It Process output buffer. .It Call .Fn bufrelease function to clean up buffers. .El .Sh EXAMPLES Simple example that uses first argument as a markdown string, converts it to an HTML and outputs it to stdout. .Bd -literal #include #include #include #include #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; } .Ed .Sh SEE ALSO .Xr soldout_array 3 , .Xr soldout_buffer 3 , .Xr soldout_markdown 3 , .Xr soldout_renderers 3 , .Lk http://daringfireball.net/projects/markdown/ John Gruber's markdown format .Sh AUTHORS .An -nosplit The .Nm library was written by .An Natasha Qo Kerensikova Qc Porte Aq Mt natacha@instinctive.eu . Manual page was originally written by .An Massimo Manghi Aq Mt mxmanghi@apache.org , and rewritten to mdoc format by .An Svyatoslav Mishyn Aq Mt juef@openmailbox.org .