MKD_FUNCTIONS(3)

πŸ“¦
version 3.0.2.0 Β· 2 versions
, in arch rolling, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0

πŸ’– MKD_FUNCTIONS(3) β€” access and process Markdown documents πŸ’–

okay bestie, so this is the mkd_functions page from the Library Functions Manual, and it's literally your all-access pass to poking around inside a Markdown document like it's a group chat you're the admin of. πŸŽ€

πŸ“š LIBRARY

Markdown (libmarkdown, -lmarkdown) β€” yeah that's the vibe, link it and go.


✨ SYNOPSIS

#include <mkdio.h>

int
mkd_compile(MMIOT *document, int flags);

int
mkd_css(MMIOT *document, char **doc);

int
mkd_generatecss(MMIOT *document, FILE *output);

int
mkd_document(MMIOT *document, char **doc);

int
mkd_generatehtml(MMIOT *document, FILE *output);

int
mkd_xhtmlpage(MMIOT *document, int flags, FILE *output);

int
mkd_toc(MMIOT *document, char **doc);

void
mkd_generatetoc(MMIOT *document, FILE *output);

void
mkd_cleanup(MMIOT*);

char*
mkd_doc_title(MMIOT*);

char*
mkd_doc_author(MMIOT*);

char*
mkd_doc_date(MMIOT*);

🌸 DESCRIPTION

so the markdown format in this implementation is extra β€” it supports Pandoc-style headers and inline <style> blocks, and the plain old markdown(3) functions just don't give you access to any of that data from either extension. not them being left on read. 😭

these functions? they hand you that data, plus they let you convert Markdown docs into HTML with way finer control. it's giving main character energy fr fr.

okay so if you've got an MMIOT* that came from mkd_in() or mkd_string(), then mkd_compile() compiles the whole document into <style>, Pandoc, and html sections. 🧚

once it's compiled, the doc is basically unlocked and you can examine and write it with mkd_css(), mkd_document(), mkd_generatecss(), mkd_generatehtml(), mkd_generatetoc(), mkd_toc(), mkd_xhtmlpage(), mkd_doc_title(), mkd_doc_author(), and mkd_doc_date(). periodt. πŸ’…

here's the tea on each one:

  • mkd_css() allocates a string and populates it with any <style> sections that were provided in the document. ✨
  • mkd_generatecss() writes any <style> sections to the output.
  • mkd_document() points text to the text of the document and returns the size of the document.
  • mkd_generatehtml() writes the rest of the document to the output.
  • mkd_doc_title(), mkd_doc_author(), mkd_doc_date() are used to read the contents of a Pandoc header, if any. πŸ‘‘

and then:

  • mkd_xhtmlpage() writes a xhtml page containing the document. the regular set of flags can be passed. 🌈
  • mkd_toc() writes a document outline β€” in the form of a collection of nested lists with links to each header in the document β€” into a string allocated with malloc(), and returns the size. iconic.
  • mkd_generatetoc() is like mkd_toc(), except that it writes the document outline to the given FILE* argument. 🫢
  • mkd_cleanup() deletes a MMIOT* after processing is done. say bye bestie πŸ‘‹
  • mkd_compile() accepts the same flags that markdown() and mkd_string() do:

πŸŽ€ OPTIONS

  • MKD_NOIMAGE β€” do not process ![] and remove <img> tags from the output. no pictures in this chat πŸ™ˆ
  • MKD_NOLINKS β€” do not process [] and remove <a> tags from the output. links? blocked. πŸ’€
  • MKD_NOPANTS β€” do not do Smartypants-style mangling of quotes, dashes, or ellipses.
  • MKD_TAGTEXT β€” process the input as if you were inside a html tag. this means that no html tags will be generated, and mkd_compile() will attempt to escape anything that might terribly confuse a web browser. 😭
  • MKD_NO_EXT β€” do not process any markdown pseudo-protocols when handing [][] links.
  • MKD_NOHEADER β€” do not attempt to parse any Pandoc-style headers.
  • MKD_TOC β€” label all headers for use with the mkd_generatetoc() function. 🏷️
  • MKD_1_COMPAT β€” MarkdownTest_1.0 compatibility flag; trim trailing spaces from the first line of code blocks and disable implicit reference links.
  • MKD_NOSTRIKETHROUGH β€” disable strikethrough support. ~~rip the strike~~ πŸ’…

πŸ’« RETURN VALUES

  • mkd_compile() returns 1 in the case of success, or 0 if the document is already compiled. ⭐
  • mkd_generatecss() returns the number of bytes written in the case of success, or EOF if an error occurred.
  • mkd_generatehtml() returns 0 on success, -1 on failure. πŸ’€

πŸ”₯ SEE ALSO

markdown(1), markdown(3), mkd-line(3), markdown(7), mkd-extensions(7), mmap(2).

http://daringfireball.net/projects/markdown/syntax


πŸ™ˆ BUGS

Error handling is minimal at best. that's it. that's the whole bug report. lowkey brutal. 😭


heads up bestie: error handling is minimal at best, so don't come crying to the library when it just... doesn't tell you what went wrong. fr fr. πŸ’–

and that's the whole page, babe πŸ’œ this one came from the Mastodon source, dated January 18, 2008 β€” yes it's old enough to have a driver's license, and it still ate. πŸŽ€βœ¨πŸ’