How does AnQiCMS support Markdown content editing and correctly render mathematical formulas and flowcharts on the front end?

Calendar 👁️ 55

AnQiCMS deeply understands the desire of content creators for efficient and flexible editing tools.The new version introduces the Markdown editor, greatly enhancing the convenience of content publishing.What is even more surprising is that AnQiCMS not only supports basic Markdown syntax, but also allows complex mathematical formulas and flowcharts to be elegantly presented on the front end of your website through simple configuration.This is undoubtedly a powerful boost for websites that need to display professional knowledge, technical documentation, or educational content.

Enable Markdown editing feature

Firstly, you need to make sure that the Markdown editor is enabled in the AnQiCMS backend.Log in to the admin management interface, navigate to the "Content Settings" option under "Global Settings".Here, you will find an option to enable the Markdown editor, check it and save the settings.After completing this step, when you create or edit a document, the content editor will automatically switch to Markdown mode, allowing you to create content using concise and efficient Markdown syntax.

Write Markdown content

In the Markdown editor, you can use it as usual#Indicates the title,*or-Represent a list, enclosed in backticks`Represent inline code, enclosed in triple backticks"`Represent code blocks, etc.

For mathematical formulas, you can use LaTeX syntax, which is a widely adopted formula typesetting language in academic and scientific fields. For example, inline formulas can be written using a single$Enclosed, such as$E=mc^2$;Block formulas are enclosed with double$$symbols to display them independently and centered, such as$$ \int_a^b f(x)dx $$.

For flowcharts, Mermaid syntax is a commonly used choice, which allows you to generate charts using text descriptions. For example, a simple flowchart can be created using the following syntax:

```mermaid
graph TD;
    A[开始] --> B(处理);
    B --> C{判断?};
    C -- 是 --> D[结果1];
    C -- 否 --> E[结果2];
    D --> F(结束);
    E --> F;
```

After entering this content in the editor and saving the document, you need to configure the front-end to correctly render these special contents.

The key to front-end rendering: introduce external support libraries

Although AnQiCMS's Markdown editor accepts and saves these special syntaxes, the browser itself does not directly support their rendering.Therefore, we need to introduce some front-end JavaScript libraries and CSS style sheets to 'translate' these syntaxes and convert them into user-friendly visual content.These operations are usually introduced in your website template'sbase.htmlthe file<head>Completed within the tag.

  1. Optimize Markdown style:In order to make the rendered Markdown content more beautiful and professionally formatted on the front end, you can introducegithub-markdown-css。Just addbase.htmlof<head>in<link>Tags:

    <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 concise reading experience for your Markdown content, similar to GitHub, and enhance the overall visual effect of the content.

  2. Elegant display of mathematical formulasIn order to display LaTeX-written mathematical formulas correctly and have a professional typesetting effect, we need the MathJax library. Inbase.htmlof<head>add the following<script>Tags:

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

    MathJax will asynchronously identify and render LaTeX formulas on the page during loading, converting them into a readable layout style. Whether it is complex calculus or simple algebraic expressions, they can be clearly displayed.

  3. Dynamic presentation of flowcharts: The Mermaid library is responsible for parsing Mermaid syntax into interactive flowcharts or various charts. Inbase.htmlof<head>add the following<script>code:

    <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 that this code uses ES module imports. After Mermaid is initialized, it will intelligently search for Mermaid syntax blocks on the page and convert them into SVG graphics, making your flowcharts dynamic and easy to understand.

Actual effect and content value

With these configurations, when your users visit pages containing Markdown text, mathematical formulas, or flowcharts, they will see professionally formatted content with clear formulas and dynamically displayed flowcharts.This not only greatly enhances the professionalism and readability of the content, but also liberates content creators, allowing them to focus on content creation and the transmission of knowledge, without worrying about complex layout work.This is a leap forward in content presentation for technical blogs, educational websites, product documentation, or any website that needs to convey complex information, and it can attract and retain readers more effectively.

Cautionary notes and **practice

  • These external CDN resources require the user's browser to be able to access them normally.If your target user group has a special network environment or security requirements, you may need to consider downloading these JavaScript libraries and CSS files to your server locally for deployment to achieve more fine-grained control and optimization.
  • After enabling the Markdown editor, the functionality and display method of the original rich text editor will change.Make sure your content team is familiar with Markdown syntax.
  • If you have inserted custom content that needs to be rendered as HTML in Markdown (for example, certain special HTML fragments), and you want AnQiCMS to automatically convert it to HTML instead of displaying it as raw Markdown, you can pay attention to the AnQiCMS template tags inContentfield'srenderParameter, use appropriately|safefilter.
  • The versions of the Mermaid and MathJax libraries will continue to be updated. It is recommended to consult their official documentation when introducing them to understand the latest versions and potential compatibility issues.

Frequently Asked Questions (FAQ)

  1. Q: Why did I enable the Markdown editor and add a formula, but the front end still displays the original LaTeX code?A: This is usually because the MathJax library has not been loaded or initialized correctly on the front-end page. Please check if you have correctly included the MathJax library inbase.htmlthe file.<script>tags and make sureMathJax-scriptofasyncattributes andsrcThe path is not incorrect. Additionally, confirm that the syntax of the LaTeX formula you have written in Markdown is correct, for example, whether the inline formula uses single$Wrap, whether the block-level formula uses double$$.

  2. Q: The flow chart does not display or displays the original Mermaid code instead of the graphic?A: In this case, you need to checkbase.htmlwhether the Mermaid inclusion code is complete and error-free, especiallytype="module"andmermaid.initialize({ startOnLoad: true });These are the key parts. Ensure that your template environment supports ES module imports.Next, please carefully check whether the Mermaid syntax you have written in Markdown is in accordance with the specifications, any minor syntax error can lead to rendering failure.It is a good practice to consult the official Mermaid documentation to ensure syntax compatibility.

  3. **Q: CDN resources introduced will affect the website loading speed

Related articles

How to build and display the navigation path of the current page in the website using the `breadcrumb` tag?

In website construction and operation, user experience (UX) is always at the core.When visitors delve deeper into your website, a clear navigation path can effectively prevent them from getting lost and quickly understand their current location.This is the value of the 'Breadcrumb Navigation'.It not only enhances user experience, but is also an important part of Search Engine Optimization (SEO), helping search engines understand the hierarchy of your website structure.AnQi CMS knows this and therefore provides a convenient and easy-to-use `breadcrumb` tag

2025-11-08

How to retrieve and display the global configuration and SEO information of the website using `system`, `contact`, and `tdk` tags?

In the daily operation of AnQiCMS (AnQiCMS), accurately displaying global configuration information, contact information, and carefully optimized SEO elements on the website front end is the key to improving user experience and search engine visibility.Fortunately, AnQiCMS provides several intuitive and powerful template tags that allow users to easily access this important data.This article will delve into the three core tags `system`, `contact`, and `tdk`, helping you seamlessly integrate the background configuration into various pages of the website.Get the global configuration of the website

2025-11-08

How to format a timestamp with the `stampToDate` tag to display the date and time in a user-friendly manner?

In the daily content operation of Anqi CMS, we often need to present the original timestamp data such as publish time and update time in a way that is more accustomed to and easier to read for users.The original timestamp, such as `1609470335` such a pure number sequence, has no meaning to ordinary users.To solve this problem, AnQi CMS provides a very practical template tag——`stampToDate`, which can help us convert these numeric timestamps into a clear and user-friendly date and time display.###

2025-11-08

How to implement conditional display and loop display of dynamic content in AnQiCMS template using `if` and `for` tags?

In the Anqi CMS template world, `if` and `for` tags are the foundation for building dynamic and flexible pages.They give the template the ability to display content based on different data conditions, as well as the ability to efficiently loop through data sets, making your website content生动地呈现给visitors vividly.AnQi CMS adopts a template engine syntax similar to Django, making it easy for you, who is familiar with web development, to get started quickly, obtaining data through double curly braces `{{variable}}`, and using `{% tags %}` syntax for conditional judgment and loop control.### Use `if`

2025-11-08

In AnQiCMS content settings, how to finely control the display of images (such as WebP, automatic compression, thumbnails)?

In website operation, images are important elements to attract users and convey information.However, unoptimized images may also be the culprit behind slow website loading, which can then affect user experience and search engine rankings.AnQi CMS knows the importance of image optimization and therefore provides a variety of fine-grained image control features to help you achieve a perfect balance between website performance and visual effects.### One, WebP: The intelligent choice for lightweight and fast image acceleration WebP, as a modern image format, typically has a file size 25-34% smaller than JPEG at the same visual quality

2025-11-08

How does AnQiCMS handle the display of external links in documents, does it automatically add the `nofollow` attribute?

In website operation, the management of external links is an important task, which not only relates to user experience, but also has a direct impact on search engine optimization (SEO).The use of the `nofollow` attribute can help website managers control the transmission of link weight more accurately, avoiding unnecessary risks.For users of AnQiCMS, understanding how the system handles external links in documents and whether it automatically adds the `nofollow` attribute is crucial for efficient website operation.AnQiCMS provides a clear and flexible strategy for handling external links

2025-11-08

How does AnQiCMS support multi-level menus and custom navigation categories to optimize the display of the website structure?

In website operations, a clear and effective navigation system is the key to user experience and search engine optimization.It not only guides visitors to find the information they need quickly, but also shows the structure and relevance of the website's content to search engines.AnQiCMS (AnQiCMS) has fully considered the actual needs of operators in website navigation settings, providing flexible multi-level menus and customizable navigation category functions to help users easily build a well-organized website structure.### Core Advantage: Flexibility and Structure The navigation feature of Anqi CMS aims to provide high customization and convenient management

2025-11-08

How to flexibly set the display name, subtitle, and description of navigation links to enrich the navigation display of the website?

The website's navigation system is like the table of contents of a book, guiding readers to the chapters they are interested in and subtly shaping their overall perception of the website's content.A well-designed, informative navigation that can significantly improve user experience, help visitors quickly find the information they need, and also bring a positive impact on search engine optimization (SEO).The Anqi CMS provides detailed and powerful navigation management features, allowing you to go beyond simple link text and create more expressive and practical website menus.Why is navigation not just links? In the digital age

2025-11-08