How to use Markdown editor to display mathematical formulas and flowcharts in AnQi CMS?

Calendar 👁️ 85

In website operations, we often need to display some content that includes mathematical formulas or complex flowcharts, which not only makes information delivery more accurate, but also greatly enhances the professionalism and readability of the article.AnQi CMS understands this need, for this reason it has built-in support for Markdown editors, and combined with external libraries, allows us to easily present these professional contents in articles.

Enable Markdown editor

To write content using the Markdown editor, first make sure that the Markdown editor is enabled in the AnQiCMS backend.This is usually found in the 'Content Settings' under 'Global Settings'.After enabling it, you can choose the Markdown mode when editing article content, and enjoy its concise and efficient writing experience.

Write formulas and flowcharts in Markdown

After enabling the Markdown editor, we can directly insert mathematical formulas and flowcharts into the article content.

For mathematical formulas, we usually use LaTeX syntax to write them and enclose them with specific symbols. For example, in-line formulas can be used$ E=mc^2 $This style will be displayed side by side with other content in the text. For complex formulas, if you want them to be displayed independently and centered in a separate paragraph, you can place them on an independent line and enclose them with double dollar signs, like this:

$$
\sum_{i=1}^{n} (x_i - \bar{x})^2
$$

This will tell the system that this is a block-level formula that needs to be rendered separately.

The flowchart can be implemented using Mermaid syntax.Mermaid is a simple and easy-to-learn text to chart conversion tool that allows us to define the structure of flowcharts with code.In Markdown, we just need to mark the code block asmermaidJust like that. For example, a simple flowchart might look like this:

```mermaid
graph TD
    A[开始] --> B{判断};
    B -- 是 --> C[执行操作];
    C --> D[结束];
    B -- 否 --> D[结束];
```

In this way, we can clearly express complex logic and steps in a plain text environment.

Let them display correctly on the web: integrate third-party libraries

Although we have written mathematical formulas and flowcharts correctly in Markdown, the browser itself cannot directly recognize and beautifully render these special Markdown syntaxes.In order for them to be correctly parsed and displayed on the web page, we need to use some powerful third-party JavaScript libraries and include them in the public template file of our website.In AnQiCMS, this public template file is usuallybase.htmlBecause it includes the website's header, footer, and other common elements, ensuring that the imported libraries can take effect on all pages.

  1. Default Markdown styleTo make the rendered content of Markdown have better visual effects, you can introduce the GitHub style Markdown stylesheet. Add the following code tobase.htmlthe file<head>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 will provide a clean, easy-to-read typography for Markdown content.

  2. Display of mathematical formulasTo make a web page able to parse and display LaTeX-formatted mathematical formulas, we can use the MathJax library. Add this JavaScript code tobase.htmlthe file<head>Tag within, best placed before other scripts, or immediately after Markdown style:

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

    This script will asynchronously load MathJax and automatically scan and render mathematical formulas after the page is fully loaded.

  3. The display of flowchartsMermaid flowchart rendering requires the introduction of the Mermaid library itself and its initialization. Similarly, add the following code beforebase.htmlthe file<head>tags or<body>the tag ends:

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

    This code will import Mermaid in module way and callinitializemethod, wherestartOnLoad: trueindicating that Mermaid will automatically find and render all marked after the page loadsmermaidThe code block.

Complete workflow overview

In summary, the steps to display mathematical formulas and flowcharts in AnQiCMS can be summarized as:

  1. In the AnQiCMS backend's 'Global Settings' -> 'Content Settings'.Enable Markdown editor.
  2. When editing an article, select Markdown mode and use.Writing mathematical formulas in LaTeX syntax(inline)$, block level$$), andWriting flowcharts in Mermaid syntax(`mermaidCode block).
  3. Edit the website'sPublic template filebase.html, in<head>Inside or (or<body>Before ending, introduce GitHub Markdown style, MathJax script, and Mermaid script as well as initialization code.

After completing these steps, the mathematical formulas and flowcharts in the content you publish will be beautifully displayed on the website, which will greatly enhance the expressiveness and professionalism of your website content.


Frequently Asked Questions (FAQ)

  1. Ask: I have written formulas and flowcharts in Markdown and also enabled the Markdown editor, but why is it still displayed as plain text code on the page?Answer: This is very likely because you forgot tobase.htmlThe external JavaScript libraries for MathJax and Mermaid are introduced in the public template file.The browser cannot understand these special syntaxes directly; it needs these libraries to parse and render them.Please follow the method provided in the article to ensure that the relevant script has been correctly added to your template file.

  2. Question: Can these JavaScript libraries be downloaded to the local server instead of using CDN?Of course you can. The CDN link provided in the article is for convenience and speed.If you are considering performance optimization, security, or want to work offline as well, you can completely download these libraries to the static resource directory of your website and thenbase.htmlcorrespondingsrcandhrefModify the path to the local resource path. Please note that the Mermaid library may require ESM module import methods, and the path must be correct during localization.

  3. Ask: I only want to display mathematical formulas, not flowcharts, is that okay?Answer: No problem at all. You can selectively import the required libraries according to your needs. For example, if you only need to display mathematical formulas, then onlybase.htmlYou can include the MathJax script without including the related script for Mermaid.Similarly, if you do not need GitHub Markdown style, you can also omit that line of CSS inclusion code.

Related articles

What impact does the document recycling station function have on users viewing content on the front end?

In daily website operations, operations such as adding, deleting, modifying, and querying content are very common.However, the action of 'deleting' is often accompanied by a hint of hesitation and risk.Our CMS is well-versed in this, providing users with a document recycle bin feature, which is not just a simple 'trash can', but also an important guarantee for your content security and front-end display effect.When you perform a deletion operation on a document, a product detail, or any other entry under any content model in the Anqi CMS backend management system, the most direct impact is that it will immediately disappear from your website's front end.

2025-11-07

How can you filter and display documents of specific content models in the document list?

In website operation, efficiently managing and displaying different types of content is the key to improving user experience and work efficiency.AnQiCMS (AnQiCMS) with its flexible content model design allows you to easily handle various content formats, whether it is articles, product details, or event announcements, and can be managed and displayed in a fine-grained manner. Today, let's delve deeper into how to efficiently filter and display documents of specific content models in AnQiCMS.This can not only help you quickly locate the content you need in the background, but also make the front-end content of your website more accurate and dynamic.

2025-11-07

How do custom fields in the Anqi CMS content model affect the display of document detail pages?

In AnQiCMS, the content model and custom fields are the core functions to enhance the flexibility and diversity of website content management.They make the website no longer confined to the traditional 'title + text' mode, but able to display more personalized and structured information according to different business needs.How do these carefully configured custom fields in the background affect the display of our website's document detail page?

2025-11-07

How to set up independent Banner images or thumbnails for document categories to be displayed on the front page?

In AnQiCMS, setting up an independent Banner image or thumbnail for document categories can greatly enhance the visual appeal and user experience of the website, making each category have a unique brand identity.In fact, AnQiCMS provides very intuitive and flexible functions in this aspect, you can easily set up a few steps to make these custom images beautifully appear on the front page. ### One, configure exclusive visual elements for categories in the background Firstly, we need to upload and set these unique images for your document categories in the AnQiCMS background.

2025-11-07

How to customize the URL structure of static page rules to enhance user experience and search engine friendliness?

AnQiCMS is a powerful content management system that plays a core role in website operations.Wherein, the flexible configuration of pseudo-static rules is a key factor in improving user experience and search engine friendliness.A clear, concise, and semantically rich URL structure not only makes it easier for visitors to understand the page content but also helps search engines better crawl and index the website, thereby bringing higher visibility and traffic.### The Importance of Understanding URL Structure Before delving into AnQiCMS's pseudo-static rules before

2025-11-07

How do website logo, filing number, copyright information and other global settings affect the display of the website footer and header?

Build a professional and trustworthy website often requires those seemingly trivial but crucial global settings.This information is like the "business card" and "background" of the website, silently conveying the brand's image, credibility, and compliance at the first time of user access.AnQiCMS (AnQiCMS) took this into consideration from the beginning of its design, allowing website Logo, filing number, copyright information, and other core global settings to be conveniently and efficiently managed and displayed in the header and footer of the website, thereby shaping your unique website image.At the Anqi CMS backend

2025-11-07

How does mobile end address configuration affect mobile users' access and display of website content?

With the popularity of smartphones, mobile devices have become the mainstream way for users to access websites.The performance of the website on mobile directly affects user experience and search engine rankings.In Anqi CMS, the configuration of the mobile end address is the key link to ensure that the website can provide mobile users with a **good access experience.Flexible and diverse options are provided by Anqi CMS for mobile adaptation, mainly including adaptive, code adaptation, and PC+mobile independent site modes.When we choose the adaptive or code adaptation mode, the website will share a set of URL addresses on both PC and mobile ends

2025-11-07

How to manage image resources and control their display in content (such as Webp, automatic compression, thumbnails)?

In website operation, images are indispensable elements that attract users and convey information.However, managing and optimizing these image resources is often a headache, as it directly affects the website's loading speed, user experience, and even the search engine optimization (SEO) effect.Fortunately, AnQiCMS provides a series of powerful and flexible features for image management, allowing you to easily cope with these challenges.Why is image management so important? Imagine a user opening your website and being unable to see the full content due to slow image loading

2025-11-07