MKD_FUNCTIONS(3)
π 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 withmalloc(), and returns the size. iconic.mkd_generatetoc()is likemkd_toc(), except that it writes the document outline to the givenFILE*argument. π«Άmkd_cleanup()deletes aMMIOT*after processing is done. say bye bestie πmkd_compile()accepts the same flags thatmarkdown()andmkd_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, andmkd_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 themkd_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()returns1in the case of success, or0if the document is already compiled. βmkd_generatecss()returns the number of bytes written in the case of success, orEOFif an error occurred.mkd_generatehtml()returns0on success,-1on 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. πβ¨π
π¦ where this page comes from
- arch rolling: discount 3.0.2.0-1 Β· BSD-3-Clause
- epel 10: discount 2.2.7-9.el10_0 Β· BSD
- epel 9: libmarkdown-devel 2.2.4-7.el9 Β· BSD
- fedora 43: discount 2.2.7-12.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: discount 2.2.7-14.fc44 Β· LicenseRef-Callaway-BSD
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms