How to display mathematical formulas and flowcharts on AnQiCMS web pages?

Calendar 👁️ 73

Today, with the rich content of digitalization, it is often not enough to rely solely on plain text to convey complex information.Especially in fields such as science, technology, and education, mathematical formulas and flowcharts are crucial for expressing rigorous logic and clear steps. 幸运的是,AnQiCMS provides a simple and powerful way for you to easily integrate and display these professional contents on your website. This article will give a detailed introduction on how to use Markdown editor and third-party libraries to perfectly present mathematical formulas and flowcharts on your AnQiCMS website.

Open a new dimension of content display: Enable Markdown editor

The basis for displaying mathematical formulas and flowcharts in AnQiCMS is to enable its powerful Markdown editor.Markdown not only makes your content structure clearer and writing more convenient, but also provides the possibility to integrate these advanced functions later.

To enable the Markdown editor, you need to go to the AnQiCMS backend management interface, find "Global Settings" under "Content Settings".On this page, you will see an option specifically used to switch the editor mode.Select the Markdown editor to enable and save your changes.This step ensures that you can use Markdown syntax to insert formulas and flowcharts when writing articles.

The elegant presentation of mathematical formulas on web pages

Mathematical formulas are an indispensable part of many academic or technical articles.AnQiCMS integrates the widely popular JavaScript display engine MathJax, allowing complex mathematical expressions to be presented clearly and beautifully on your web page.

In order for your website's frontend to 'understand' and 'render' these Markdown-formatted mathematical formulas, we need to include them in the public template file (usuallybase.htmlIn it introduces the CDN resource of MathJax.base.htmlThe file is usually located in the theme directory you are currently using, it carries the general structure of the website, such as header, footer, etc.

Please editbase.htmlFile, in<head>At the closing tag (i.e.),</head>Insert the following code before:

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

The purpose of this code is to asynchronously load the MathJax library. Once loaded, it will automatically scan mathematical formulas on the page and render them into beautiful layouts.

Now, you can write mathematical formulas in the Markdown editor. MathJax supports LaTeX syntax, and you can use the following two methods:

  • Inline formula: Use a single dollar sign$Enclosed, for example$E=mc^2$, it will display as(E=mc^2).
  • Block formula: Use double dollar signs$$Enclosed, for example$$\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$, it will be displayed independently on one line and centered: $The integral of e^(-x^2) from 0 to infinity is equal to sqrt(pi)/2$

Make the process logic clear at a glance: display the process diagram

In addition to mathematical formulas, flowcharts are also a powerful tool for expressing complex logic and operational steps.AnQiCMS integrates the Mermaid JavaScript library, allowing you to draw various flowcharts with simple text syntax and display them dynamically on the web.

Similar to MathJax, Mermaid also requires you tobase.htmlinclude its CDN resources in the file. In<head>The closing tag, paste the following code snippet:

<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 the Mermaid library in ES module form and throughmermaid.initialize({ startOnLoad: true });Make sure the page is loaded and automatically initialize and render the Mermaid chart.

Now, you can use Mermaid syntax to create flowcharts in the Markdown editor. For example, a simple flowchart can be written as follows:

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

它在页面上会渲染成:
```mermaid
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

Mermaid supports various chart types, including timeline charts, Gantt charts, and more. You can refer to the official Mermaid documentation to explore more possibilities.

Optimize the display style of Markdown content

To make your Markdown content look more professional and unified on the web page, you can also consider introducing GitHub-style Markdown stylesheets.This will give your code blocks, quotes, lists, and other elements a better visual experience.

Similarly, inbase.htmlthe file<head>Within the tags, you can add the following CDN links:

<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, your Markdown rendering content will obtain a set of clean and readable default styles.

Summary

By following these simple steps, your AnQiCMS website will be able to support the display of mathematical formulas and flowcharts, greatly enriching the form of content expression.From enabling the Markdown editor, to introducing the necessary CDN libraries, and mastering the basic Markdown and chart syntax, the openness and flexibility of AnQiCMS makes these seemingly complex features accessible.Now, you can freely use these tools in technical blogs, tutorial articles, or any page that requires precise expression to enhance the professionalism and readability of the content.


Frequently Asked Questions (FAQ)

1. After following the steps, if the mathematical formula or flowchart still does not display, how should the problem be investigated?

First, make sure you have successfully enabled the Markdown editor in the "Global Settings" -> "Content Settings" of AnQiCMS. Secondly, check carefully.base.htmlIs the CDN code for MathJax and Mermaid correctly and completely pasted in the file<head>Inside the tag.Network issues may also cause CDN resource loading failures. You can try accessing the CDN link directly in the browser, or check the browser console (open with F12) for any related network request errors or JavaScript errors.Finally, please confirm that the Markdown syntax you use in the article is correct, and you can refer to the official documentation of MathJax and Mermaid for verification.

2. Can the style of MathJax rendered mathematical formulas or the color of Mermaid flowcharts be customized?

Of course you can.MathJax and Mermaid both provide rich configuration options, allowing you to customize during initialization.<script>Add a configuration object to label to adjust font, color, etc. For Mermaid,mermaid.initialize()The function can accept a configuration object, such as setting the theme (theme), line color (lineColor), and so on.Moreover, since these libraries ultimately render formulas or charts as HTML and SVG elements, you can also further beautify them by writing custom CSS styles.

3. Does AnQiCMS support integrating other JavaScript libraries for rendering special content in addition to MathJax and Mermaid?

AnQiCMS's Markdown editor is highly flexible in itself, it is responsible for converting Markdown text to HTML. As long as the JavaScript library you want to integrate can recognize specific Markdown extension syntaxes (such as Mermaid's `mermaidBlock) or it can scan and process specific HTML structures on the page using JavaScript, and if the CDN resources of this library can be imported into your website template, then theoretically AnQiCMS can support it.This means you can try to integrate other similar chart libraries (such as ECharts), code highlighting libraries, or any other front-end rendering tools, AnQiCMS's open architecture provides you with a lot of freedom.

Related articles

How to correctly render Markdown editor content on the frontend page in HTML?

## AQS CMS Markdown content: How to perfectly present on the front-end page?In content creation, Markdown, with its concise and efficient syntax, has been favored by a wide range of content creators.AnQi CMS knows this and therefore provides strong Markdown editor support.But how can you ensure that the Markdown content you edit in the background is rendered correctly and beautifully on the website's frontend page?Behind this involve several key links, understanding them can help you manage the website content more skillfully.

2025-11-08

How can you reference common header, footer, or sidebar content in a template?

In the daily operation and maintenance of the website, we often encounter such situations: each page needs to include a unified header, a standard footer, or a fixed sidebar.If every page were to rewrite this content, it would not only be inefficient but also a huge amount of work to modify once.AnQiCMS (AnQiCMS) understands this pain point and therefore provides a flexible and powerful template reference mechanism to help us efficiently manage these common contents, ensuring the unity and maintainability of the website.### Overview of AnQi CMS Template Mechanism In AnQi CMS

2025-11-08

What template file types and directory structures does AnQi CMS support to organize displayed content?

AnQi CMS provides high flexibility and strong organizational capabilities in content display, which is mainly reflected in its support for template file types and directory structures.Understanding these conventions and mechanisms can help you customize the appearance and content layout of the website more efficiently. ### The core structure and conventions of template files Firstly, AnQi CMS will统一存放 all template files used for front-end display in the root directory of the site under the `/template` folder.Each independent website theme or template set should have its own folder in this directory

2025-11-08

How to set up independent template files for specific pages or content types?

In website operation, we often encounter situations where we need to design a unique display style for certain pages or content types.Perhaps the product detail page needs a more attractive layout, or some special topic article needs to break the conventional style to highlight its importance, or a single-page 'About Us' needs to showcase the brand characteristics.AnQi CMS deeply understands this personalized need, providing flexible and powerful template customization capabilities, allowing you to easily set up exclusive template files for different content, thereby achieving more refined content presentation and brand image management.--- ###

2025-11-08

How to display the document title, publish time, and view count on the document detail page?

Manage website content in AnQi CMS and ensure its accurate and beautiful display on the front-end page, which is the core of daily operation work.For each document detail page, clearly presenting the title, publication time, and views of the document can not only effectively improve user experience, but is also an important link in the transmission of content information.The AnQi CMS provides powerful and flexible template tags, allowing us to easily meet these requirements. ### Locate the document detail page template To modify the display content of the document detail page, we first need to find the corresponding template file.In AnQi CMS template structure

2025-11-08

How to call and display the cover image, thumbnail, or group image of a specified document?

It is crucial to have visually appealing content when building and operating a website.AnQiCMS provides a flexible way to manage and display the images of documents (including articles, products, etc.), whether as an eye-catching cover, a clever thumbnail, or a colorful group photo.Understand how to correctly call these images, which can help you better design and optimize the user experience of the website.AnQiCMS provides several main image fields for different content types, which have clear uses in the template: * **Cover logo (Logo)**

2025-11-08

How to implement lazy loading of images in document content to optimize display performance?

## Optimize Website Display Performance: Practical Guide to Implementing Lazy Loading of Images in AnQi CMS In today's internet era, the loading speed of a website is crucial for user experience and search engine rankings.Large image files are often one of the main culprits slowing down website loading speeds. 幸运的是,image lazy loading (Lazy Loading) technology can effectively solve this problem.

2025-11-08

How to get and display the name and link of the category to which the current document belongs?

On the content detail page of a website, we often hope to clearly display the classification information of the current document, such as the name of the classification and the link to that classification.This not only helps visitors better understand the content structure, but also improves the website's navigation and user experience.Safe CMS provides us with a variety of flexible ways to meet this requirement. We will discuss several methods for obtaining and displaying the category name and link of the current document in the AnQiCMS template, and you can choose the most suitable solution according to your actual template design and requirements.### Method One

2025-11-08