stouf / libghfmd

This C library uses the GitHub API v3 in order to generates HTML content from Markdown formated text contents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libghfmd

This C library uses the GitHub API v3 in order to generates HTML content from Markdown formated text contents.

Use

Simply use it as follow:

#include "ghfmd.h"

/**
 * Returns a HTML version of a given markdown formated text content
 *
 * @param markdown_text     The markdown formated text content
 *
 * @return                  Either a char pointer on the string that contains
                            the exepcted html version, either NULL if a problem
                            has occured
 */
char* your_function(char* markdown_text) {
    return get_html_from_markdown(markdown_text);
}

The current main.c file reads a given file (supposed to be a markdown file) in order to parse it and returns its HTML version to the stdout. You can use it as follow:

$ make MD_FILE="/path/to/md/file"

It's also possible to compile the program with debug flags. Example:

$ make DBG_FLAG="-g" build_main

And finally, run the program with a debugger. Example:

make DBG_FLAG="-g" DBG_CMD="gcc" MD_FILE="test.md"

And then???

And then, you've got an HTML file, which is the body of your final HTML page. So, you can add whatever you wanna add to this body.

But, there're something you should add to the received body in order to get the expected syntax highlighting: the CSS files!

Those are available here ;-)

  • documentation.css is for the document itself
  • pygments.css is for the syntax highlighting

Feel free to add the one you need, or even both, of course :) ;)

Also, images and js files should be included in your final HTML page, in order to be as close as possible to the GitHub Flavored Markdown rendering!

GitHub API v3 references

GitHub Flavored Markdown references

Dependencies

  • The libcurl is required for this project.
    • A great tutorial about how to use curl

About

This C library uses the GitHub API v3 in order to generates HTML content from Markdown formated text contents


Languages

Language:C 98.6%Language:Shell 1.4%