GithubHelp home page GithubHelp logo

dheia / xmd-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mossadal/xmd-plugin

0.0 0.0 0.0 30 KB

OctoberCMS plugin allowing user-defined extensions to the Markdown syntax. Also provides a way to protect certain constructions from the built-in Markdown interpreter. This is useful for example to allow Markdown and MathJax input to play nice with each other.

PHP 67.74% HTML 32.26%

xmd-plugin's Introduction

ExtendMarkdown Plugin

A simple extension of the Rainlab.Blog plugin for October CMS allowing for user defined extensions to Markdown input, as well as a way to protect certain constructions from October's built-in Markdown interpreter, thus allowing for example MathJax and Markdown to play nice with each other.

Background

The excellent Rainlab.Blog plugin uses Markdown formatting of posts. Unfortunately the built-in Markdown interpreter Parsedown interferes with the standard MathJax library for typesetting matematical formulas using LaTeX syntax. While Parsedown seems to handle some MathJax constructions properly, the parser often produces output that causes MathJax rendering to fail.

For example: in a blog post containing text like

    The equation $x_{n+2} - 5x_{n+1} + 6x_{n} = 0$.

Parsedown sees the _ as italic markers, and produces the following HTML code

    <p>The equation $x<em>{n+2} - 5x</em>{n+1} + 6x_{n} = 0$.</p>

The incorrectly inserted <em> tags destroys the LaTeX markup and thus MathJax fails to typeset the formulas properly.

Solution

The ExtendMarkdown plugin provides a simple, reasonable clean solution allowing the user to create a number of replacement "rules", protecting certain input from the Parsedown interpreter. These rules will be applied everytime a blog post is saved.

Also, the plugin can be used to add extra shortcuts for commonly used markup.

By default, the plugin comes with the following rules

Rules protecting input from the Parsedown interpreter:

Input start tag Input close tag Output start tag Output close tag
$ $ $ $
$$ $$ $$ $$
\begin{equation} \end{equation} \begin{equation} \end{equation}
\begin{align} \end{align} \begin{align} \end{align}

Additional markup shortcuts

Input start tag Input close tag Output start tag Output close tag
@@ @@ <strong class="text-primary"> </strong>

The plugin provides a backend interface for modifying and adding additional rules as needed.

Live MathJax updates when previewing a blog post in the backend

If you write a lot of MathJax heavy blog posts, you probably want to render the MathJax markup, also in the backend preview.

To do this, install the Mossadal.MathJax plugin.

xmd-plugin's People

Contributors

mossadal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.