Introduction: Markdown to HTML Conversion Functions

A set of functions is employed to convert Markdown text into HTML format. The output can either be a string containing HTML code or a file saved on disk.

Setup

To make these functions work, you need to specify a destination HTML directory where the HTML documents will be stored. This directory serves as the root directory for the website hosting the HTML files. It's crucial to ensure that this directory contains the "Themes" folder that comes with the plugin. Simply copy the "Themes" folder into your designated HTML directory to set it up.

The command set_markdown_html_root is used to define this directory before initiating the conversion process.

Additional CSS: You have the option to specify an additional CSS file that will be included in the generated HTML code. This CSS file allows you to customize or modify the styling of the resulting documents as needed.

The command set_markdown_CSS is used to specify this additional CSS file (optional).

Styling: The "Themes" folder within the plugin contains named themes and code styles for use, particularly in pre-code boxes. The second parameter of the markdown2html function call, named "style," accepts a comma-separated list of style and code style names.

Example:

package myTestPackage "This is a small test to convert Markdown";

function ConvertMarkdown ()
        string root = select_directory("Select the root directory for HTML");
        set_markdown_html_root ( root ) ;
        string sf = select_file ("Select a Markdown File?");
        if (sf != "") then
            string df = save_file_dialogue ("Save file as?", "test.html", root);
            if (df != "") then
                string res = markdown2html (sf, "solarized-dark,monokai", df);
                print res;
            end if
        end if
        return "OK";
end

Compile the script using the "ACF_CompileText" plugin function provided by the ACF_Functions plugin. If there are no compilation errors, the product is already loaded and can be executed.

In a FileMaker Script step, use the following:

Set Variable ( $x; ACF_run ( "ConvertMarkdown")  )

References: