WP Scholar provides a clutter-free, direct and fast typing experience for the heavy-duty writers who type a lot every day (technical writers, engineers, analysts, journalists, researchers, scientists, etc.) and are stuck with WordPress as a CMS. It supports equations, footnotes, table of contents, code highlighting, charts drawing, interactive plots and Jupyter notebooks includes, through a direct access to the Markdown and LaTeX code. Then, it refines the typography by converting arrows, quotes and fractions to proper HTML entities, and inserts unbreakable and thin spaces where they belong.
If you are a technical writer, you may feel WordPress Gutenberg editor is going backwards, in an MS Office direction : giving an overwhelming set of formatting options while making actual typing and content production really hard. Those blocks ask you to think about the layout even before having typed the content, and make you travel constantly between mouse and keyboard. More than a hassle, they put pain on your wrists and elbows.
The truth is, WordPress is turning into a better place for marketers, but is becoming a nightmare for anyone who produces content rather than cute formatting. While most technical writers have now turned toward static content generators (Hugo, Jekyll, etc.), and researchers keep writing fixed-width PDF papers (2021 much…), WP Scholar tries to make WordPress great again for you, writer.
While WordPress Gutenberg editor allows you to write Markdown, it will process it on-the-fly and save the post content as processed HTML. If you want to edit it again in the future, you will have to read HTML.
WP Scholar parses posts saved in Markdown syntax, meaning future edits will be done on Markdown as well. The limitation is you need to never open those Mardown posts in Gutenberg or TinyMCE visual editor. Alternatively, WP Scholar allows you to include plain .md
text files
Description
Features
- Newbie features :
- adds support for extended Github-flavored Markdown formatting in posts, pages and comments,
- adds support for footnotes and inline hover cards for their content,
- adds table of contents in posts and in sidebars with a widget,
- adds internal anchors and backlinks to headers, for quick intra-page navigation and permanent linking to inner sections,
- enforces correct typographic rules for the current language, such as unbreakable and thin spaces where they belong, fractions, quotes, etc.
- Intermediate features :
- adds support for Mermaid graphs, allowing to quickly plot charts from simplified code,
- removes WordPress markup filtering in posts and pages, allowing scripts and advanced HTML,
- removes media library uploads limitations, allowing SVG, HTML and JSON uploads to media library, provides a shortcode to include them in posts and pages,
- adds support for Plotly and Bokeh interactive and self-hosted graphs, for beautiful data visualisations and analytics.
- Expert features :
- adds support for LaTeX equations in posts, comments and pages, with environments, references and equations numbering,
- adds syntax highlighting on code blocks declared with a programming language (245 languages supported),
- imports Jupyter notebooks and include them in pages (you can even write full posts with graphs and code in Jupyter then include them).
Compatibility
- Supports Typora Markdown editor output and 90 % of its features, so you can type your posts off-line in Typora editor, and copy-paste the Markdown code,
- Supports TinyMCE (classic WordPress editor) and Gutenberg in their code editor versions, plus Gutenberg HTML block. The visual editors are not fully supported (see why),
- Supports Jetpack LaTeX syntax as well as
[latex]
shortcodes, - Supports
[toc]
shortcode that is also used by many table of content plugins (however, they cannot be enabled at the same time), - Supports all shortcodes from WordPress and other plugins,
- Saves posts as true Markdown code, so they can be edited again as Markdown (most editors convert Markdown to HTML in browser and save HTML).
Performance
- WP Scholar only loads a minified 1.6 kB CSS file on every page of the website.
- The ressources to load (CSS and JS) are lazy-loaded on a page-wise basis, so only the necessary ones are loaded and your home page doesn’t get bloated with useless resources.
- Javascript files (Mathjax, Prism, Mermaid, Plotly, Bokeh, etc.) are loaded from
cdnjs.cloudflare.com
. This ensures fast loading and proper caching for any user. - WP Scholar is compatible with caching plugins and tested with WP Rocket (see the configuration help).
- Most scripts are loaded in footer and can be loaded asynchronously for better loading time.
- Since WP Scholar parses Markdown at page-rendering time, this can prove heavy and slow. A caching plugin is strongly recommended.
How it works
The whole thing is designed to be as lightweight and simple as possible. There is no configuration page, just enable and start writing Markdown or LaTeX. Everything is detected automatically, and options are defined in the text editor through HTML comments tags.
Philosophy
No obstruction. When you put your ideas into text, you want nothing to sit between you and the text, you just want the text to flow. Think about writing in your notebook… Unfortunately, Microsoft Word and WordPress Gutenberg force you to think about the layout even before starting to actually type, because they take the problem the wrong way : you need to start creating layout blocks first, then only later fill them with content. Form doesn’t adapt to content anymore, it is the other way around.
To do so, they heavily rely on mouse actions to define and edit content blocks and their properties, while actual typing happens on keyboard. So they make you travel constantly between mouse and keyboard, which makes you lose time and put your wrist and elbow at risk of musculoskeletal and nervous strain, if you repeat it daily and for long periods of time.
The best-flowing typing experience is one where you don’t have to care about layout, while typing if at all, don’t have to put your hands off the keyboard and don’t need right-click monkey business. Which means typing text as formatted code with some markup (LaTeX, HTML, XML and the likes). But markup may be a huge overhead because it is hard to read, cumbersome to type, and slow to learn.
For this reason, Markdown was invented in 2004 to deal with formatting in the less-cumbersome way as possible. It is fast to learn, fast to use, and gets later interpreted as HTML, which allows systematic styling through templates and style-sheet. It can also be used in conjunction with HTML for cases where advanced layouts are required.
So WP Scholar takes all the benefits of Markdown, extends them with LaTeX for equations, but also adds the usual WordPress shortcodes on top, for the more advanced features like media galleries. You get all the benefits of WordPress with a simple text editor and most of the bloat out of your sight.
#Suggested workflow↑
#Companion editor↑
This plugin is designed to be compatible with Typora , a cross-platform and distraction-free Markdown editor that lets you type maths, graphs, text and tables in a very efficient way, then export to all the usual formats, on Linux, Mac OS and Windows. Type in Typora, copy-paste the Markdown code to a WordPress post or import the .md
file to WordPress media library and include it, and be done with it. WP Scholar will be able to translate Typora’s Markdown, equations and graphs to HTML. Typora is, so far, the best implementation of a non-obstructive typing workflow.
This workflow has several advantages :
- Typora provides a no-distraction WYSIWYG interface, supporting even tables, maths and diagrams rendering,
- you keep a local copy of your articles for safety and for later export to LaTeX, PDF, ePub, HTML, etc.
- you can work offline, while commuting, travelling, or simply to cut internet distractions, with no fear of losing your work,
- WordPress fancy content editors tend to be more and more bloated, heavy and slow as time goes by, inducing lags and CPU overuse. A local lightweight editor is all you need.
WP Scholar supports 95 % of Typora’s features, like its extended Markdown syntax, maths rendering and Mermaid graphs. Flowcharts and Sequence charts are not supported because they duplicate Mermaid’s features for little benefit.
#Dynamic workflow↑
You can type your posts in Markdown straight from WordPress post editor, using the code editor. Be careful, however, because both TinyMCE (classic editor) or Gutenberg (new editor) used in WYSIWYG mode convert Markdown syntax directly to HTML at typing time, in your browser. So they don’t save real Markdown. Similarly, when you switch back from their code editor to their WYSIWYG mode, they might encode important characters things into HTML and break the Markdown syntax.
In a nutshell, while TinyMCE and Gutenberg let you type some Markdown (just the simple stuff like bold, headings and italics), when you edit those posts later, what you will edit will be HTML. So you get 2 options to retain Markdown untouched :
- with TinyMCE, always use the code editor and never go back to the visual one, especially if you use maths equations.
- with Gutenberg, either use the code editor or an HTML block.
Notice if you edit posts first in TinyMCE code editor and later import them in Gutenberg, some characters may by converted to HTML entities in the process, which may break syntax of LaTeX and Mermaid code. For this reason, it is better to keep editing older posts in the same editor they were primarily created, or force your posts to be converted to pure HTML using HTML blocks.
#Static workflow↑
You can type your posts in any Markdown editor you like, online or offline, then import the Markdown file to your media library and include it in your post (see how to include external Markdown in posts).
To edit those posts later, you can connect from your computer to your web server, through FTP, mount the remote server as a local storage, and keep editing the .md
files from within your local editor. You absolutely need to name the file with a .md
extension so the Markdown syntax is parsed (otherwise, any other file type is not parsed).
Notice this will not store the content of your post in WordPress database, which will disable the following WordPress features :
- internal search in posts and pages content,
- automatic excerpt generation,
- SEO analyse of content from third-party plugins,
- any further content extraction/analyse.
#Warnings↑
#Security↑
This plugin enables uploading SVG, HTML, JSON, Markdown (.md) and Jupyter notebook files (.ipynb) to WordPress media library and disables the uploaded checks on such files. These files can be used to embed malicious, unfiltered, scripts, which is the reason WordPress disallows them in the first place. Unfortunately, we don’t have a choice if we want to include local Plotly/Bokeh graphs and Jupyter notebooks as pre-rendered HTML files. A security hardening plugin, like Sucuri, Wordfence, or SecuPress, is strongly advised, with double-factor authentication and malware scanners.
This plugin also disables the default WordPress XSS detection and markup removal/sanitization in posts and pages (they are still applied on comments), because it conflicts with Markdown syntax and prevent us from using legitimate scripts in-page. It means any author on your blog can add Javascript and unfiltered markup in posts, that is possibly malicious code in posts. This is a double-edged sword : more power and more responsibilities. You need to trust your blog authors, editors, and administrators to use this plugin.
#Performance↑
WP Scholar keeps your posts saved as Markdown in the posts database, which means they need to be parsed and interpreted before the front-end page is rendered and served to an user. To avoid re-rendering them every time a new reader comes on your page, it is advised to use caching plugins such as W3 Total Cache, Super Cache or WP Rocket (there are plenty).
WP Scholar loads only one CSS file (1.6 kB) and one JS file (2.3 kB) per page. Both are minified already. All other CSS and JS are loaded on-demand, only on the pages where they are needed. The internal javascript of WP Scholar uses plain javascript (no jQuery or other version-tied library dependency) and will work with any web browser that is not Internet Explorer 8 and more recent than 2012 or so.
Maths equations, Mermaid charts, Plotly and Bokeh interactive graphs are rendered client-side, in the visitor’s browser, by javascript libraries which produce SVG images. This guarantees that fonts and lines are properly scaled to the viewport width and are free from aliasing or blurring, since they use the real screen resolution. However, this puts a computational cost on the visitor’s device and might take some time to render on older devices. Also, SVG is supported only by fairly recent web browsers (newer than 2014).
#Caveats↑
#Special symbols↑
WP Scholar expects dollar symbols $
to enclose maths equations, like $x + y = z$
or $ x + y = z $
. If you use $
as a price monetary unit only once in a paragraph, you are going to be fine. But if you have at least 2 dollar signs in the same paragraph, WP Scholar will interprete it as an equation enclosing and try to format it as maths. To prevent that, you need to escape the dollar sign with a backslash, like \$
.
#Custom post types↑
To avoid conflicts and performance penalty with custom post types and special pages like cart/checkout pages of web shop plugins, Markdown is parsed only on regular WordPress posts and pages, comments, posts archives, home page and excerpts.
To force Markdown parsing on any post type that uses the_content
hook , put somewhere in the page <!-- force-markdown -->
.
#Newbie Documentation↑
#Markdown syntax↑
The overall logic of Markdown is to replace HTML markup by special characters (brackets, backticks, stars, etc.), spaces and line breaks. Therefore, spaces and line breaks become parts of the syntax and bad spacing (too many or too few) will result in bad parsing.
The Markdown parser is the library PHP Markdown 1.9.0 that has been extended for our needs and for Github Flavored syntax. Here is the complete list of features as part of the Markdown extended syntax : (bold : standard Markdown, italic : extended Markdown, bold italic : WP Scholar addenda)
- page elements :
- footnotes,
- table of content,
- abbreviations,
- block elements :
- paragraphs and line breaks,
- *headers (with anchors, see below),
- blockquotes,
- lists and nested lists,
- code blocks (with syntax highlighting, see below),
- horizontal rules,
- equation blocks (see “Maths” below),
- tables,
- ordered lists,
- definition lists
- id and class attributes
- span elements :
- bold,
- italics,
- links and auto links from url,
- images,
- code span,
- striked text,
- exponents,
- indices
Documentations :
- Original Markdown syntax by John Gruber ,
- Extended Markdown by Michel Fortin ,
- Addenda brought by WP Scholar :
renders as :
- Striked
- 2 nd
- H2 O
WP Scholar also changes inline images parsing a bit, by automatically linking images to themselves, with a rel="lightbox"
attribute. This allows most themes and plugins that use a Javascript lightbox to open images full-screen. So, ![alt text](https://mysite.com/image.jpeg "title text")
becomes :
#Footnotes↑
The footnotes are part of the Markdown Extra syntax, extending Markdown, but WP Scholar gives them a hover card. Input [^1]
in the text where you want the footnote marker to appear, like here[1], then later in the text (where it is convenient), define the footnote text like [^1]: The text
with exactly one space after :
and with only one definition by line. Footnotes definitions are added at the end of the text.
The footnotes numbers don’t have to follow in increasing order in the text, but only have to be unique and be linked to the same number among definitions. The parser will reorder them and sort them in increasing order, as they appear in the text. Footnotes can be called several times, but have to be defined only once.
Hover cards appear when the mouse goes over the footnote link and display the content of the footnote without having to scroll to the footnotes.
#Internal linking and TOC↑
#Headings links↑
Your headings need to be properly defined, in decreasing order (for example, don’t start your content with a ###
or <h3>
title and later input a ##
on </h3><h2>
title). Notice </h2><h1>
or #
should be reserved for the page title, so your first section title should always be a </h1><h2>
or ##
.
WP Scholar will create an unique ID selector if the heading doesn’t have one (even for external HTML files included in posts), and will display a #
link left of each heading containing the permalink of the section (current page URL + section anchor), when the mouse hovers the heading (try it on this page’s headings). When clicking the #
, the full permalink of the section is copied to the clipboard so you can quickly share the sections on the Internet.
Notice the auto-generated ID use the current content of the heading. If you change it later, the permalink will change too. To set an heading ID manually and prevent them from changing in future post editions, you can use :
Similarly, if a TOC is present in the page, each heading gets a ↑
link right of it, going straight to the TOC, to facilitate intra-page navigation.
#Table of contents↑
Add a [toc depth=3 title="Contents"]
shortcode in the text to make a table of content appear at this place. By default, a TOC shows all levels of heading and doesn’t add a title. The TOC are included in a <details>
HTML5 markup which should notify search engines properly about its content.
Optional arguments :
depth
How many levels of headings should go in the TOC list, starting from the first heading in the page.
title
The title to set for the TOC box.
Notice TOCs should work also for external HTML embedded in post pages. A widget is provided to display the TOC in a sidebar, in place or in addition of the post TOC. The options are the same.
#Mixing HTML, Markdown and WorPress shortcodes↑
Pages can contain a mix of HTML and Markdown syntax, however no Markdown will be parsed inside block-level HTML elements by default. This can be used to deal with corner cases, for example with code blocks (in case the inside of Markdown code blocks is still parsed). If you really need to use HTML divisions and want Markdown to be parsed inside, for example to apply CSS classes and styling, you can change that behavior by adding a markdown=1
property :
WP Scholar keeps the content of posts as originally written (Markdown + PHP) in the database. This ensures they can be later edited as Markdown again.
However, many Markdown plugins (Jetpack) and editors (TinyMCE and Gutenberg) support Markdown for typing, but convert to HTML at some point (possibly with their own CSS selectors which will mess-up styling for us) and save posts as HTML in the database. This will make it impossible to edit posts as Markdown again.
WordPress usual shortcodes are rendered after the Markdown parsing is performed, so you can combine shortcodes and Markdown with no fear of clashes. The Markdown parser will treat WordPress shortcodes as standard text, so mind your paragraphs breaks between shortcodes and content (best policy is generaly to avoid empty lines between shortcodes and content to avoid breaking them apart in different paragraphs in the Markdown parsing).
How WP Scholar processes your posts
#Typography↑
Good typography really makes a great difference in the life of people who have to read a lot. Also, properly composed text is just more pleasing. Computer typewriting has been responsible for enforcing bad typographic habits over traditional and professional typography, making things like thin space fall into disgrace simply because they have no place to sit on your keyboard anymore (seriously, do you even know what they are for ?).
Thin space has the width of a coma and used to be recommended before colon (:), semi-colon (;), question and exclamation marks ( !?) in both English and French. Their use has simply disappeared with typewriters and computers, and while the French have replaced them with usual space in all these cases, which helps legibility, the English have simply ditched them at all, which is very disagreeable to read. Punctuation simply has to stand out of words, not to get nested in them.
WP Scholar performs automatically these typographic changes to posts, comments and pages :
- insert a mandatory unbreakable thin space :
- before : ; ! ?
- after ¡
- inside French guillemets « »
- between numbers and their units (as recommended by the SI Unit style ), like 21 kg.
- between every thousand in numbers if the WordPress locale (language) is set to French,
- insert a mandatory breakable en space :
- after : ; ? ! . ,
- before and after inline
code
elements
- convert :
- quotes :
- straight single and double quotes
'...'
and"..."
to curly typographic quotes ’…’ and “…” in non-French languages, - straight double quotes
"..."
and double chevron<<...>>
into guillemets « … » for French languages, - two single quotes
''...''
into proper double quotes ”…”
- straight single and double quotes
- punctuation :
- 3 dots
...
into ellipsis … - approximative dashes
---
and--
to proper em and en dashes — and –
- 3 dots
- arrows :
- approximative single and double arrows
<-
,->
,<—>
,<=
,=>
,<>
to ←, →, ↔, ⇐, ⇒, <> - approximative tailed arrows
>->
,<-<
,|->
,<-|
to ↣, ↢, ↦, ↤
- approximative single and double arrows
- maths :
~=
and\=
to ≃ and ≠- star multiplication
5*8
to 5×8 - plus or minus
+/-
to ± - fractions
1/2
,1/3
,99/100
to ½, ⅓, 99⁄100 (but let dates like 20/09/2019 alone).
- quotes :
#Intermediate documentation↑
#Mermaid charts↑
The Mermaid library allows to render graphs as SVG from a couple of Mardown-like commands. The syntactic overhead makes it very efficient to render simple graphs with text properly scaled at display size and DPI, like Gant charts, flow charts, pie diagrams, sequence charts, etc. Simply write a code block with mermaid
as the language and type your graphs specifications (more info on the syntax ) :
#mermaid-1675339842360 {font-family:sans-serif;font-size:14px;fill:#000000;}#mermaid-1675339842360 .error-icon{fill:#552222;}#mermaid-1675339842360 .error-text{fill:#552222;stroke:#552222;}#mermaid-1675339842360 .edge-thickness-normal{stroke-width:2px;}#mermaid-1675339842360 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1675339842360 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1675339842360 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1675339842360 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1675339842360 .marker{fill:#666;stroke:#666;}#mermaid-1675339842360 .marker.cross{stroke:#666;}#mermaid-1675339842360 svg{font-family:sans-serif;font-size:14px;}#mermaid-1675339842360 .label{font-family:sans-serif;color:#000000;}#mermaid-1675339842360 .cluster-label text{fill:#333;}#mermaid-1675339842360 .cluster-label span{color:#333;}#mermaid-1675339842360 .label text,#mermaid-1675339842360 span{fill:#000000;color:#000000;}#mermaid-1675339842360 .node rect,#mermaid-1675339842360 .node circle,#mermaid-1675339842360 .node ellipse,#mermaid-1675339842360 .node polygon,#mermaid-1675339842360 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-1675339842360 .node .label{text-align:center;}#mermaid-1675339842360 .node.clickable{cursor:pointer;}#mermaid-1675339842360 .arrowheadPath{fill:#333333;}#mermaid-1675339842360 .edgePath .path{stroke:#666;stroke-width:2.0px;}#mermaid-1675339842360 .flowchart-link{stroke:#666;fill:none;}#mermaid-1675339842360 .edgeLabel{background-color:white;text-align:center;}#mermaid-1675339842360 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-1675339842360 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-1675339842360 .cluster text{fill:#333;}#mermaid-1675339842360 .cluster span{color:#333;}#mermaid-1675339842360 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:sans-serif;font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-1675339842360 :root{–mermaid-font-family:sans-serif;–mermaid-font-size:14px;}#mermaid-1675339842360 :root{–mermaid-font-family:“trebuchet ms”,verdana,arial,sans-serif;}
Client
Raw $\LaTeX$ code
Code blocks
Raw charts code
Raw JSON graphs
HTML elements
Incoming HTML page
Mathjax.js
Prism.js
Mermaid.js
Plotly.js
Rendered maths
Highlighted code
Rendered charts
Rendered graphs
Final rendered page
https://
cdnjs.cloudflare.com
load/cache