How to enable Markdown editor and correctly render mathematical formulas and flowcharts in AnQiCMS?

Calendar 👁️ 67

Enable the complete guide to Markdown, rendering mathematical formulas and flowcharts in AnQiCMS

AnQiCMS as an efficient and flexible content management system has always been striving to provide content creators with more convenient and powerful content editing and display capabilities.For those who often need to write technical documents, academic papers, or descriptions containing complex logical processes, the original rich text editor sometimes seems inadequate.Luckyly, the new version of AnQiCMS has integrated support for Markdown editors and can render mathematical formulas and flowcharts well, greatly enhancing the efficiency and expressiveness of content creation.

Next, we will explore together how to enable these powerful features in AnQiCMS, bringing new vitality to your website content.

Enable Markdown Editor

To start using Markdown to create your content, you first need to make a simple setting in the AnQiCMS backend.

You just need to log in to the backend, find the "Global Settings" in the left menu, and then click to enter the "Content Settings" page.On this page, you will see an option, usually about the type of content editor.Find and check the Enable Markdown Editor, then save your changes.After completing this step, when you create or edit a document again, the rich text editor will automatically switch to the Markdown editor.

The correct rendering of Markdown content

After enabling the Markdown editor, the content you write in the background will be stored in Markdown syntax.However, merely using Markdown syntax in the background is not enough to make them perfectly presented on the front-end page.In order to give Markdown text a clear and consistent visual style on your website, we need to introduce a style file.

We recommend usinggithub-markdown-cssIt can provide elegant styles similar to GitHub for your Markdown content. You can use it in website templates.base.htmlThe file (usually the header file for all pages) of<head>Add the following line inside the tag:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />

This way, your Markdown content (such as headings, lists, code blocks, etc.) will have a unified and beautiful style on the front end.

Display of mathematical formulas

For users who need to display mathematical formulas, Markdown editors combined with the MathJax library can easily achieve professional-level formula rendering.MathJax can convert mathematical expressions in LaTeX, AsciiMath, and other formats into high-quality typesetting, whether in-line formulas or independent block-level formulas, they can be presented perfectly.

To enable math formula rendering, you also need to add MathJax's CDN script in the website template'sbase.htmlin the file<head>tag.

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

After adding, you can use LaTeX syntax to write formulas in Markdown content. For example:

Inline formula:$E=mc^2$It will be rendered as:(E=mc^2).

Block-level formula:

$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

It will be rendered as: $\(\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}\)$

Drawing and rendering of flowcharts

Markdown can handle text and formulas and can also draw various flowcharts, sequence diagrams, etc. by integrating the Mermaid.js library.Mermaid.js allows you to describe chart structures with concise text syntax and then automatically render them into beautiful graphics.This is very helpful for explaining complex processes or system architectures.

To make your website support flowchart rendering, pleasebase.htmlthe file<head>Inside the tag, add the Mermaid.js CDN script. Please note that this istype="module"a type of script.

<script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
    mermaid.initialize({ startOnLoad: true });
</script>

Once introduced successfully, you can use Mermaid syntax to create flowcharts in Markdown content. For example:

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

It will be rendered as:

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

Content Publishing and Advanced Rendering

When you add the above mathematical formula or flowchart content in the Markdown editor in the background, save and publish the document, they will be rendered in the expected way on the front page.

It should be noted that AnQiCMS is used on the document detail pagearchiveDetailits tag to retrieve contentContentThe field defaults to detecting and rendering Markdown syntax as HTML. If you are placing Markdown content in a custom field or have some special requirements and want to manually control the rendering process, you can userenderFilter. For example, if you have a custom field namedcustom_markdown_fieldThe custom field contains Markdown content, you can call it in the template like this to ensure it is rendered correctly:

{{ archiveDetail customMarkdownField with name="custom_markdown_field" | render | safe }}

Here|renderEnsure Markdown is converted to HTML,|safethen inform the template engine that this is safe HTML content, no further escaping is needed.

By using these settings, you can fully utilize the powerful features of Markdown on the AnQiCMS website to create more expressive and easy-to-read professional content.


Frequently Asked Questions (FAQ)

1. Why did I enable the Markdown editor but the content on the front end still does not have style and is just displayed as plain text?

This is usually because you have not included on the website'sbase.htmlfile inclusiongithub-markdown-cssThe stylesheet. Although the backend editor allows you to use Markdown syntax, the browser itself does not know how to beautify these Markdown elements.After introducing this CSS file, your Markdown headings, lists, code blocks, and other content will have a unified and beautiful default style.

2. I have already followed the steps to introduce the CDN scripts for MathJax and Mermaid.js, but after entering formula or flowchart code in the article, they are still displayed as raw code and not rendered. Why is that?

First, please carefully check what you havebase.htmlwhether the included script is complete, and whether the location is correct (usually in<head>Within tags). For Mermaid.js, it also needs to ensuremermaid.initialize({ startOnLoad: true });This line of code is executed correctly, it is responsible for starting Mermaid rendering.In addition, the Markdown syntax for formulas and flowcharts is very strict, any minor spelling errors or formatting issues can cause rendering to fail.Please refer to the official documentation of MathJax and Mermaid.js to check if your code block conforms to the standard format (for example, inline formulas in MathJax use$..$or\(..\), use block-level formulas$$..$$or\[..\]; The chart content of Mermaid.js must be wrapped inmermaid` 和` code blocks).

3. If my article content is in pure HTML format and not Markdown, will it be affected if I enable the Markdown editor?

AnQiCMS's Markdown editor usually has a toggle mode, or it automatically recognizes when you paste pure HTML content. If you paste or write pure HTML code directly in the Markdown editor, and the content field is eventually|safeorrender|safeFilter processing (or the default rendering logic within AnQiCMS allows), then this HTML code is usually parsed and displayed normally by the browser and is not treated as plain text.However, to avoid potential style conflicts or unnecessary parsing issues, if you are sure that the content is pure HTML, it is best to use a traditional rich text editor to edit it, or ensure that your Markdown rendering configuration does not negatively affect pure HTML.

Related articles

How to display related article lists in AnQiCMS to enhance user browsing?

In content operations, guiding users to continuously explore within the site, extending their stay time, is one of the key strategies to improve user experience and website conversion rates.The list of relevant articles is an efficient tool to achieve this goal.AnQiCMS as a high-performance, flexible content management system provides various ways to cleverly display related articles, thereby deeply tapping into the browsing potential of users.Why is the related article list so important?

2025-11-08

How to display links to the previous and next articles on the AnQiCMS article detail page?

When visitors browse articles on a website, they often hope to be able to jump to related content conveniently, especially the previous or next one.This design not only improves the user experience, but also has a positive impact on the internal link structure of the website and search engine optimization.AnQiCMS fully considered such user needs, built in simple and efficient template tags, helping us easily implement the previous and next article link function on the article detail page.

2025-11-08

How to display website logo and copyright information in AnQiCMS template?

When building and operating a website, the website's logo and copyright information are an important component of brand image, building user trust, and fulfilling legal statements.For AnQiCMS users, managing and displaying this information is very intuitive and flexible. ### In AnQiCMS backend, set the website logo and copyright information AnQiCMS centralizes the global configuration of the website, allowing you to easily set various basic information.To set the website logo and copyright, you need to go to the 'Global Function Settings' page in the backend.1.

2025-11-08

How to set the TDK (Title, Description, Keywords) of the AnQiCMS homepage to affect search results display?

In website operation, making your website stand out in search engines is a key step to gain traffic.While the "front door" of a website - the homepage, its display effect in search results is often determined by TDK (Title, Description, Keywords).AnQiCMS is a system focused on enterprise-level content management, which provides intuitive and powerful settings to easily control the homepage's image in the eyes of search engines.--- ### What is TDK and why is it so important

2025-11-08

How does AnQiCMS control the display of content in different areas through the 'Flag' attribute (such as recommended, headline)?

## AnQiCMS: How to make good use of the "Flag" attribute to accurately control the layout of website content In content operation, it is not enough to just publish articles.How to make important content stand out, how to intelligently display specific content in different areas of the website, is the key to improving user experience and operational efficiency.AnQiCMS is well-versed in this field and has provided us with a powerful and flexible tool - the 'Flag' attribute, to巧妙ly achieve this goal.What is the content "Flag" attribute?In short

2025-11-08

How to display the publication time of articles in the AnQiCMS template and customize the format?

In website content operation, the publication time of the article is a seemingly simple but crucial detail.It not only affects users' judgment of the timeliness of content, but is also an important reference factor for search engines to evaluate the freshness of content and for ranking.For AnQiCMS users, flexibly displaying and customizing the publication time of articles in templates is a basic operation to improve website user experience and SEO performance.

2025-11-08

How to retrieve and display single-page content in AnQiCMS, such as "About Us"?

In website operation, pages like "About Us" and "Contact Information" are indispensable components. They usually carry relatively fixed and important content such as corporate culture, contact information, and service introduction.For users of AnQiCMS, obtaining and displaying these single-page contents is not only simple and efficient but also highly flexible and customizable.This type of independent page, with content that does not change often, is classified as "single page" by Anqi CMS, and a dedicated management module is provided in the background for easy creation, editing, and publishing by users.

2025-11-08

How to manage and display the list of friend links in AnQiCMS?

Friend links are an important part of website optimization and user experience, they can not only help your website rank better in search engines, but also provide visitors with more valuable resources, and also serve as a bridge to establish contact with industry partners.In AnQiCMS, managing and displaying friend links is a straightforward and flexible operation, allowing you to easily configure these important external connections for your website. ### Back-end Management Friend Links List To start managing friend links, you need to log in to the AnQiCMS back-end.All auxiliary functions are concentrated under the 'Function Management' menu

2025-11-08