How to correctly display mathematical formulas and flowcharts in AnQiCMS templates?

Calendar 👁️ 64

Properly display mathematical formulas and flowcharts in AnQiCMS template

As a website administrator focused on content operation, I fully understand the importance of high-quality content for attracting and retaining users.In some fields, such as education, technology, or scientific research, content often includes complex mathematical formulas or clear flowcharts.AnQiCMS as a flexible content management system, through the integration of Markdown editor, provides us with the possibility of elegantly presenting these complex elements on the web.Although AnQiCMS itself does not directly render these special contents, it allows us to easily introduce industry-standard third-party libraries to achieve this function.

This article will give a detailed introduction on how to configure and use these tools in the AnQiCMS template, ensuring that your mathematical formulas and flowcharts are displayed correctly.

Enable AnQiCMS Markdown Editor

To start embedding mathematical formulas and flowcharts in your content, first make sure that the AnQiCMS Markdown editor is enabled.This is the premise of parsing content in Markdown format, as well as the basis for subsequent rendering of formulas and flowcharts.

Please log in to the AnQiCMS backend management interface and navigate to the "Content Settings" option under "Global Settings".On this page, you will find the option to enable or disable the Markdown editor.Please make sure to check or set to enabled and then save the changes.After enabling, you can use Markdown syntax to create content when creating or editing documents.

Configure MathJax to display mathematical formulas

The rendering of mathematical formulas usually requires specialized JavaScript libraries to handle LaTeX or AsciiMath syntax.In AnQiCMS, we recommend using MathJax, which is a powerful and widely used formula rendering engine.

To integrate MathJax on your website, you need to edit the core files in the AnQiCMS template folder, usuallybase.htmlThis file will be inherited by most pages of the website.base.htmlthe file<head>Add the following JavaScript reference line inside the tag.This will load the MathJax library from the jsdelivr CDN, enabling it to parse and render mathematical expressions on the page.

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

After configuration, you can use LaTeX syntax to write mathematical formulas in Markdown content. For example, use$to enclose inline formulas (such as$E=mc^2$), or use$$Enclose block-level formulas as shown below:

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

Configure Mermaid to display flowcharts

For flowcharts, sequence diagrams, Gantt charts, and other charts, Mermaid provides a concise text syntax and can render them into beautiful graphics.To enable AnQiCMS to support Mermaid, you also need to include its JavaScript library in the template file.

Like MathJax, you should add the reference to Mermaid'sbase.htmlthe file<head>Inside the tag. Please add the following JavaScript code:

    <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 load the Mermaid library in module form and thenmermaid.initialize({ startOnLoad: true });Make sure the Mermaid chart is scanned and rendered automatically after the page is fully loaded.

In Markdown content, you can use special code blocks to define Mermaid charts. For example, a simple flowchart can be written like this:

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

Optimize the display style of Markdown content

In order to make your Markdown content, including formulas and flowcharts, visually more coordinated and professional, it is recommended to apply a set of beautiful styles to them.GitHub provides a set of excellent Markdown CSS styles, which we can easily include via CDN.

Inbase.htmlthe file<head>Add the following CSS reference immediately after other style sheets in 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" />

After introducing this style, your Markdown content will have better formatting and readability on the web.

Content creation and publication

After completing the above configuration, you can now create documents containing mathematical formulas and flowcharts in the AnQiCMS content management backend using the Markdown editor.When editing, just follow the syntax rules of MathJax (LaTeX) and Mermaid.After the document is published, these formulas and charts will be rendered correctly on the front-end page.

Please note that these features rely on external CDN resources, make sure your server or user's network environment can access these CDNs normally to ensure successful rendering.At the same time, when editing content, it is recommended that you preview the page to check whether formulas and charts are displayed as expected.


Frequently Asked Questions (FAQ)

Question: I have added the script according to the steps, but the mathematical formulas and flowcharts still do not display. Why is that?Answer: First, make sure you have enabled the Markdown editor in the "Global Settings" -> "Content Settings" of the AnQiCMS backend.Secondly, check whether the MathJax (LaTeX) and Mermaid syntax you use in the content is correct and error-free, any syntax error may cause rendering failure.Finally, confirm that the CDN links for MathJax and Mermaid are correct and accessible. Sometimes network issues or CDN service anomalies can also affect loading.

Ask: Can I host the MathJax and Mermaid files on my own server instead of using a CDN?Of course you can. You can download the release version files from the official website of MathJax and Mermaid, and then upload these files to the AnQiCMS template directory./public/static/Or other custom static resource paths. After that, you just need to modifybase.htmlcorresponding<script>label'ssrcThe property should point to the file path hosted locally. This can improve the stability and speed of loading, but you need to manage file updates yourself.

How can I customize the style of my mathematical formulas and flowcharts?Answer: For MathJax, it itself provides rich configuration options, you can configure it through JavaScript code after the MathJax script is loaded, such as changing the font, color, or rendering method of the formula. For Mermaid, it supports different themes (theme) settings can bemermaid.initialize()specified, for examplemermaid.initialize({ startOnLoad: true, theme: 'dark' });. In addition, you can also override the default rendering effects through custom CSS styles to meet specific design requirements.

Related articles

How to correctly render Markdown formatted content in AnQiCMS templates?

In AnQiCMS templates, correctly rendering Markdown content is a key factor for website operators to enhance content presentation and editing efficiency.Markdown is a lightweight markup language that is favored by content creators for its simplicity, readability, and ease of writing.The AnQiCMS system not only supports the creation of Markdown content but also provides a flexible template rendering mechanism to ensure that this content is presented in the expected way on the front-end page, and can even integrate third-party libraries to display mathematical formulas and flow charts.###

2025-11-06

How to ensure the security of AnQiCMS deployed websites and prevent common security issues?

As a website operator who has dealt with AnQiCMS for many years, I know the importance of website security for content operation.A secure website not only protects user data and maintains the reputation of the enterprise, but is also the foundation for the stable release and dissemination of content.AnQiCMS was designed with security in mind from the outset, and provides a variety of built-in features and practical suggestions to help us build and maintain a secure and stable content platform.AnQi CMS is developed using Go language, which lays a solid foundation for the system's running efficiency and stability

2025-11-06

How to deploy AnQiCMS multi-site in Docker environment and configure reverse proxy?

As an experienced CMS website operation person, I fully understand the importance of an efficient and flexible content management system for enterprises and self-media in the increasingly complex network environment.AnQi CMS, with its high-performance architecture based on the Go language, rich feature set, and SEO-friendliness, has become the ideal choice for many users.Especially in multi-site management, AnQiCMS provides a simple and efficient solution.

2025-11-06

How to get the detailed content and images of a single page (such as "About Us")?

Managing and displaying a single page like "About Us" and its content and images in Anqi CMS is an efficient and flexible process.As an experienced website operator, I will explain in detail how to create from the backend to the frontend display, and fully master this feature.--- **To get the detailed content and images of a single page (such as "About Us") in AnQiCMS** AnQiCMS (AnQiCMS) provides a dedicated management module called "Single Page" for independent pages such as "About Us" and "Contact Us"

2025-11-06

How to achieve unified management of multiple sites in AnQi CMS and improve operational efficiency?

As a website operator who is well-versed in AnQi CMS, I am well aware that in today's complex digital environment, efficiently managing multiple websites has become an urgent need for many enterprises and content operation teams.The traditional single-site management model often struggles when facing scenarios of multi-brand, multi-region, or multi-content branches, leading to low operational efficiency and redundant resource investment.However, AnQi CMS, with its unique design concept and powerful feature set, provides a practical solution for unified management of multiple sites, significantly improving operational efficiency.

2025-11-06

How can enterprises use the Anqi CMS to customize content models to meet diverse business needs?

AnQi CMS is an enterprise-level content management system, one of its core advantages lies in providing highly flexible content model customization capabilities.For website operators, this means that we are no longer limited to the traditional 'article' or 'product' single content structure, but can create exclusive content types based on the ever-changing business needs of the enterprise, thereby achieving more accurate content management and presentation.

2025-11-06

Can the multilingual support feature of AnQi CMS help a website expand into the international market quickly?

As an experienced CMS website operation personnel, I am well aware of the key role of the content management system in expanding the international market.The AnQi CMS indeed provides a solid foundation and an efficient solution for rapid expansion into international markets in terms of multilingual support.AnQi CMS takes multilingual support as one of its core features, explicitly aiming to help enterprises meet the needs of global content promotion, thereby effectively expanding the international market.This means that the system was designed from the outset to consider the access experience and content management efficiency of users in different languages.

2025-11-06

What specific help does the pseudo-static and 301 redirect function of AnQi CMS provide for SEO optimization?

As a website operator who is well-versed in AnQiCMS, I know that high-quality content and excellent search engine optimization (SEO) strategies are the foundation of website success in the increasingly fierce internet environment.AnQi CMS not only provides flexible and powerful tools for content creators, but also provides fine-grained management capabilities in the SEO level, among which the static URL and 301 redirect functions are two major tools to optimize the website's performance in search engines.### Optimize URL structure, improve search engine friendliness

2025-11-06