KaTeX with VSCode, Jekyll, and WordPress Markdown

I use KaTeX in VSCode extension Markdown All in One for notes and homework. It's by far the easiest and most flexible way.

Markdown is such a markup language (see the paradox? lol) without a widely-accepted, strong official organization regularizing its syntax and grammar. Typical standards includes:

Implementation of Javascript libraries into Markdown, such as KaTeX, is done independently by Markdown processors, thus creating even more variants of syntax and grammar.

In an attempt to use the same syntax and grammar throughout my Markdown documents, i.e KaTeX with VSCode, Jekyll, and WordPress Markdown, and considering the possible transplantation to LaTeX, I adopt the following configuration for most consistent experience.

WordPress PHP short code to parse markdown

Requirements to include a markdown file from elsewhere emerged when I decide to auto update my blog with github readme page.

Since markdown itself cannot include another markdown file, I come up with a work around to parse the github raw on the air.

The following example requires wp-githuber-md - since I am already using it anyway. Any equivalent will do.

/*====== parse_md shortcode ======*/
function parse_md($atts = [])
{
    $src = $atts['src'];
    $md = file_get_contents($src);

    if ($md === false)
    {
        $html = "Could not load $src";
    }
    else
    {
        require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/plugins/wp-githuber-md/src/Modules/MarkdownParser.php";
        $markdownParser = new Githuber\Module\MarkdownParser;
        $html = $markdownParser->transform($md);
    }

    return $html;
}
add_shortcode( 'parse_md', 'parse_md' );

Usage

[parse_md src="<url>]

Compact Archives compact.php modify

In order to display the compact archives as a table, I modified part of the compact.php as below, pay attention to the li part.

foreach ( $dates as $year => $months ) {
    $result .= $before . '<li class="theyear"><a href="' . get_year_link( $year ) . '">' . $year . '</a></li>';
    for ( $month = 1; $month <= 12; $month += 1 ) {
        $month_has_posts = ( isset( $months[$month] ) );
        $dummydate = strtotime( "$month/01/2001" );
        // get the month name; strftime() localizes
        $month_name = strftime( "%B", $dummydate );
        switch ( $style ) {
        case 'initial':
            $month_abbrev = $month_name[0]; // the inital of the month
            break;
        case 'block':
            $month_abbrev = strftime( "%b", $dummydate ); // get the short month name; strftime() localizes
            break;
        case 'numeric':
            $month_abbrev = strftime( "%m", $dummydate ); // get the month number, e.g., '04'
            break;
        default:
            $month_abbrev = $month_name[0]; // the inital of the month
        }
        if ( $month_has_posts ) {
            $result .= '<li><a class="amonth" href="' . get_month_link( $year, $month ) . '" title="' . $month_name . ' ' . $year . '">' . $month_abbrev . '</a></li> ';
        } else {
            $result .= '<li><span class="emptymonth">' . $month_abbrev . '</span></li> ';
        }
    }
    $result .= $after."\n";
}