How to embed and display mathematical formulas or flowcharts from the Markdown editor in the content?

Calendar 👁️ 75

In modern content operation, the professionalism and readability of content are equally important.It is often the key to improving user experience when our website involves fields such as technology, education, and engineering, how to clearly and beautifully display complex mathematical formulas or logically rigorous flowcharts in articles.AnQi CMS understands this need, integrating a powerful Markdown editor and combining it with simple frontend configuration, allowing your website to easily present these professional contents.

Step 1: Enable Markdown editor

To start using mathematical formulas and flowcharts on your Anqi CMS website, you first need to make sure that the Markdown editor is enabled.This is like adding a new skill to your content creation toolbox.It is very simple to operate:

  1. Log in to the AnQi CMS background.
  2. Navigate to the left menu's 'Background Settings', click 'Content Settings'.
  3. On this page, you will find an option for 'Enable Markdown Editor'. Be sure to check or enable it.

After enabling the Markdown editor, when you create or edit content in "Publish document" or "Page management", you can choose to create using Markdown mode.Markdown with its concise syntax, can help us organize content more efficiently, focusing on the text and logic itself, rather than complex formatting details.

Step two: Insert mathematical formulas and flowcharts in the content

The Markdown editor supports inserting mathematical formulas and flowcharts using specific syntax.

Insert mathematical formula:

The AnQi CMS Markdown editor supports LaTeX syntax for writing mathematical formulas. You can choose inline or block-level formulas as needed:

  • Inline formula:Use a single dollar sign$Enclose the formula. For example, if you want to insert a famous physical formula into a paragraph of text, you can write it like this: $E=mc^2$.
  • Block-level formula:Use double dollar signs$$Enclose the formula, which will display the formula as a separate line and default to centered. For example, the formula for finding the roots of a quadratic equation can be written like this:
    
    $$
    x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
    $$
    

Insert a flowchart:

The flowchart is defined through Mermaid syntax. Mermaid provides a concise text-based way to draw various charts, including flowcharts, sequence diagrams, and so on.A basic flowchart example is shown below:

graph TD
    A[Start] --> B{Condition};
    B -- Yes --> C[Perform Action A];
    B -- No --> D[Perform Action B];
    C --> E[End];
    D --> E;

You need to paste the above code directly into the content area of the Markdown editor.

Step 3: Configure the website frontend to display correctly.

Although you have inserted these special syntaxes in the background, the browser itself cannot directly recognize and render LaTeX formulas or Mermaid charts.In order for them to be displayed correctly and beautifully on your website's frontend, we need to introduce some additional JavaScript libraries to act as 'translators' and 'rendering engines'.

These configurations are usually completed in thebase.htmlthe file<head>tags to ensure that these scripts can work when the page is loaded.

  1. To introduce a unified and beautiful style for Markdown content (optional but recommended)To make the entire Markdown content present a more professional and consistent visual effect on the front end, you can introducegithub-markdown-cssThis not only beautifies the text around mathematical formulas and flow charts, but also improves the overall reading experience. Inbase.htmlthe file<head>Add within 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" />
    
  2. Introducing MathJax support for rendering mathematical formulasMathJax is a widely used open-source JavaScript display engine, specifically designed to render high-quality mathematical formulas in web browsers.With it, your LaTeX formula can be correctly interpreted and rendered by the browser. Inbase.htmlthe file<head>Add the following script inside the tag:

    <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    
  3. Introduce Mermaid support for flowchart renderingThe Mermaid library is the core for parsing and rendering Mermaid syntax.By introducing it, you can convert the flowchart you write in Markdown into a visual graphic. Inbase.htmlthe file<head>Add the following script inside the tag:

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

    Please note,mermaid.initialize({ startOnLoad: true });This line of code is crucial, it indicates that Mermaid will automatically scan and render all Mermaid charts after the page is loaded.

Actual application and tips

After completing the above front-end configuration, the mathematical formulas and flowcharts you insert in the AnQi CMS backend Markdown editor will display normally on the front-end page.After publishing or updating the content, it is recommended that you immediately view it on the front-end page, and pay attention to any error messages in the browser console (open with F12), which will help you locate and solve any potential problems.Sometimes, you may also need to clear the browser cache (Ctrl+F5 force refresh) to ensure that the latest front-end configuration and content are loaded.

The combination of AnQi CMS's Markdown editor with these powerful front-end rendering libraries brings unprecedented expressiveness to your website content.Whether it is complex theoretical derivation or clear display of business processes, it can be easily realized through this concise and efficient way, greatly enhancing the professionalism and user experience of the website.


Frequently Asked Questions (FAQ)

  1. Why did I configure according to the steps, but the mathematical formula or flowchart still does not display?First, please confirm that you have enabled the Markdown editor in the "Global Settings" -> "Content Settings" of the Anqi CMS backend. Second, check carefully that the MathJax and Mermaid inclusion code is accurately placed in your website templatebase.htmlthe file<head>Within the tag. Especially whether the CDN link is correct and not blocked by a firewall or security plugin.In addition, try clearing the browser cache or accessing the page in incognito mode to exclude cache interference.If the problem still exists, please open the browser developer tools (usually press F12), check the "Console" or "Network" tab to see if there are any failed resources or JavaScript error messages, which can help you further diagnose the problem.

  2. Where can I use the Markdown editor for content types?Once the Markdown editor is enabled in the background, it is usually applied to all areas that support rich text editing, including the content text in "publish documents" (such as articles, products, etc.) and the main content in "page management". As long as you have the option to switch to Markdown mode below the content input box while editing content,

Related articles

How to display system-level configurations such as the website logo, filing number, copyright information, etc.

The brand identity, legal statements, and core contact information, such as Logo, filing number, and copyright information, are an indispensable part of the professional image of a website.They not only convey trust and standardization to visitors, but are also important aspects of search engine optimization and legal compliance.In Anqi CMS, managing and displaying these system-level configurations becomes extremely intuitive and efficient. ### Backend Settings: The "Control Center" of Website Information AnQi CMS concentrates these core website information in the "Global Settings" of the backend, making management clear at a glance.

2025-11-08

How to build and display a custom field comment form on the front-end page?

When you want website visitors to be able to interact with you, such as submitting questions, providing feedback, or making appointments, a well-functioning contact form is essential.AnQiCMS provides a very flexible and powerful message management function, the core of which is to support custom message fields, allowing you to build personalized forms according to your actual business needs.This article will guide you on how to build and display these comment forms with custom fields on the front-end page.Why do you need a custom message form?

2025-11-08

How to display the list of user comments on articles in AnQi CMS?

In AnQi CMS, allowing users to comment on articles and clearly displaying these comments is an important aspect of enhancing the interactivity and user engagement of the website.AnQiCMS's powerful template engine and built-in features make this process flexible and efficient.This article will introduce in detail how to integrate the comment list and its related functions on the article detail page.

2025-11-08

How does Anqi CMS display and manage website friend links?

In website operation, friendship links play an important role. They not only help to improve the website's search engine ranking (SEO), but also bring valuable traffic, and are also a manifestation of cooperation and mutual trust between websites.Anqi CMS is well-versed in this, providing website operators with a直观 and efficient buddy link management and display solution, allowing you to easily master this feature.Next, we will delve into how to manage friend links in the background, to how to flexibly display them on the website frontend, and provide you with a detailed explanation of the friend links feature of Anqi CMS.

2025-11-08

How does Anqi CMS handle images in content to optimize loading speed and display quality (WebP, compression)?

In the content of the website, images play a crucial role, they can enrich the visual effects and convey complex information.However, unoptimized images are often the culprit for slow website loading and poor user experience.As content operators, we fully understand the value of image optimization in improving website performance and user retention.AnQiCMS provides a series of powerful and intelligent functions in image processing, aiming to help us easily achieve a balance between image loading speed and display quality.

2025-11-08

How to retrieve and display custom parameters of content models such as articles, products, etc. in a template?

In Anqi CMS, when managing website content, we often encounter the need to display specific information in addition to standard fields such as title and text.For example, when operating an e-commerce website, in addition to the name and description of the product, it may also be necessary to display 'material', 'origin', 'warranty period', and so on;Or you may be running an information blog, where articles may need to display 'author source', 'publisher' and other information.The flexible content model design of AnQi CMS is to meet this diverse content display requirement.Today, let's delve deeper into the topic

2025-11-08

How to dynamically display the name, description, and link of content categories in a template?

In website operation, clearly displaying content categories not only helps users quickly find the information they need, but is also a key link to improve website usability and search engine optimization (SEO).AnQiCMS (AnQiCMS) with its flexible template engine allows us to easily dynamically call and display the names, descriptions, and links of various content categories in website templates.Today, let's delve deeper into how to achieve this goal in templates, making your website content more vivid and efficient.### Understanding Content Classification in AnQi CMS In the AnQi CMS backend management system

2025-11-08

How does AnQi CMS display detailed content of a single page (such as About Us, Contact Information)?

In website operation, pages such as "About Us", "Contact Information", and "Privacy Policy" play a crucial role. They are the basis for visitors to show corporate information and establish trust.AnQiCMS as an efficient content management system provides a very flexible and intuitive way to create and display the detailed content of these single pages.

2025-11-08