Unveiling AnQi CMS: How Markdown content is beautifully presented on your website?

Calendar 👁️ 60

AnQi CMS as an efficient content management system, deeply understands the pursuit of convenience by content creators.Markdown is a lightweight markup language that is favored by content editors for its simplicity, ease of learning, and clear formatting.How can we ensure that the excellent content you write in Markdown is perfectly converted into browser-readable HTML and displayed beautifully on the front-end page in AnQi CMS?

This is not a complex technical problem, Anqi CMS has fully considered this from the beginning of its design, through a series of intelligent processing and flexible configuration, enabling Markdown content to have a 'native' performance on your website.


I. Basic Markdown content auto-rendering: Enable the editor's magic

The AnQi CMS is built-in with a powerful Markdown editor support, its core idea is to make the input and output of content as automated and seamless as possible.After you enable the Markdown editor in the background "Global Settings" -> "Content Settings", the system will intelligently recognize and process your Markdown content.

For the article (archive)、Category(category) and single page (page)'s default 'content' (ContentThe field, when you enter or import content using the Markdown editor in the background, Anqi CMS will parse its syntax and convert it to standard HTML structure. This means that you do not need any additional configuration, just call the corresponding in the template.Contentfield, for example:

{# 在文章详情页中调用文章内容 #}
<div>
  {%- archiveDetail articleContent with name="Content" %}
  {{articleContent|safe}}
</div>

or category details, single page details ofContentField:

{# 在分类详情页中调用分类内容 #}
<div>
  {%- categoryDetail categoryContent with name="Content" %}
  {{categoryContent|safe}}
</div>

{# 在单页面详情页中调用单页面内容 #}
<div>
  {%- pageDetail pageContent with name="Content" %}
  {{pageContent|safe}}
</div>

Here|safeThe filter is crucial, it tells the template engine that this content is safe HTML and does not need to be escaped again.Otherwise, you might see the original HTML tags instead of the rendered effect.

It is worth mentioning thatIf some Markdown content does not want to be automatically rendered, or you want to manually control the rendering process,archiveDetail/categoryDetail/pageDetailsuch as tags,Contentthe field also supportsrender=falsethe parameters. For example,{% archiveDetail archiveContent with name="Content" render=false %}This content will be output as raw Markdown text. Otherwise,render=trueit explicitly indicates rendering, which can provide finer control in some special cases.


Second, flexible rendering of custom field Markdown content:renderThe wonder of filters

Not all Markdown content is displayed through these predefined "Content" fields.Sometimes, you may create custom fields in the content model and want these fields to also support Markdown syntax.产品特点Custom field, and describe it with Markdown.

In this case, Anqi CMS provides powerfulrenderFilter.This filter is specifically used to explicitly convert Markdown text in variables to HTML.|renderand it is done:

{# 假设有一个自定义字段名为 'product_features' #}
{% archiveDetail productFeatures with name="product_features" %}
  <div class="product-features-section">
    {{ productFeatures|render|safe }}
  </div>

By|renderEven custom fields containing Markdown content can be correctly parsed and presented as beautiful HTML on the front end. Similarly,|safeIt is also indispensable to avoid HTML tags from being treated as plain text when escaping output.


3. Advanced Markdown Elements: Displaying Mathematical Formulas and Flowcharts

For content in Markdown that includes mathematical formulas (such as LaTeX syntax) or flowcharts (such as Mermaid syntax), AnQi CMS also provides support, but these usually require the use of some front-end JavaScript libraries to complete client-side dynamic rendering.The Anqi CMS itself is only responsible for passing these special syntaxes as text to the front-end, while the actual rendering work is performed by the third-party libraries loaded by the browser.

Make sure these advanced elements are displayed correctly, you need tothe skeleton template (usuallybase.htmlor the main layout file of your website)of<head>Inside the tag, include the corresponding CSS styles and JavaScript libraries:

  1. Provide default styles for Markdown content (optional but recommended):Although Markdown content is converted to HTML, the default browser styles may be too plain. Introducedgithub-markdown-cssThis CSS library can make your Markdown content have a more professional GitHub style appearance.

    <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. Render mathematical formulas (MathJax supported):If you use LaTeX-style mathematical formulas in Markdown, the MathJax library is indispensable.It will parse and beautifully present these formulas in the browser.

    <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    
  3. Render flowchart (Mermaid supported):For Mermaid flowcharts, you need to include the Mermaid library and initialize it.

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

Add these code snippets tobase.htmlof<head>After the area, when the page loads Markdown content containing mathematical formulas or Mermaid flowcharts, these JavaScript libraries will automatically intervene to render them into readable graphics or formulas.


Four, Summary and **Practice

Secure CMS through its intelligent Markdown editor, flexible,renderFilter and compatibility with third-party rendering libraries, providing comprehensive Markdown support for content creators.Whether it is the layout of daily articles or the display of complex mathematical formulas and flow charts, they can be presented accurately and beautifully on the front page.

In actual operation, remember the following points:

  • Enable editor:Make sure the Markdown editor is enabled in the background "Global Settings" -> "Content Settings."
  • |safeEssential:Any Markdown rendered to HTML content should be added in the template output|safefilter.
  • Advanced features need to be introduced:Advanced Markdown elements such as mathematical formulas and flow charts, additional CSS and JS libraries need to be introduced to your template.
  • Testing is crucial:After each adjustment, be sure to test on the front-end page to ensure that the content is rendered as expected.

With these features, you can focus on content creation, allowing Anqi CMS to take care of the presentation details for you, thereby providing your website visitors with a better reading experience.


Frequently Asked Questions (FAQ)

Q1: Why does the front-end page display the original Markdown text I wrote in the background instead of the rendered HTML?

A1: This usually has several reasons. First, please check if you have enabled the Markdown editor in "Background->Global Settings->Content Settings".If the editor is not enabled, the system will not automatically parse Markdown.Secondly, if you are entering Markdown content in a custom field, make sure to use the field when calling the template.|render|safeFilter, for example{{ custom_field_value|render|safe }}Finally, confirm that your template file does not accidentally remove|safeFilter removal, which will cause HTML tags to be escaped instead of rendered.

Q2: My article contains mathematical formulas and Mermaid flowcharts, why are they not rendered?

A2: Math formulas and Mermaid flowcharts require a client-side JavaScript library to be dynamically rendered.The default configuration of AnQi CMS does not include these libraries because not all websites need them.base.html)的<head>Manually add MathJax and Mermaid JavaScript references, as well as optional Markdown style CSS in the tag.Please refer to the description of the "Advanced Markdown Elements" section in this article.

Q3: Using in the template|safeDoes the filter pose a security risk?

A3: |safeThe filter tells the template engine that the content you are outputting is trusted HTML and does not need to be escaped.If your Markdown content source is uncontrolled (for example, allowing users to input directly) and not properly filtered for security, malicious users may harm your website by injecting JavaScript code (XSS attack).

Related articles

How to call custom document fields (such as author, price) and display them in AnQi CMS?

AnQi CMS offers powerful content management capabilities with its excellent flexibility and customizability to website operators.In the daily operation of websites, we often encounter situations where standard fields (such as titles, content, and publication time) cannot fully meet the needs of specific content display.At this moment, custom document fields have become our powerful assistants, for example, adding "author" information to an article, or supplementing "price" attributes to a product, and so on.How can we flexibly call these custom fields and display them on the website page in Anqi CMS today?

2025-11-06

How to obtain all the details of the category owned by the document details page?

How to retrieve all detailed information of the category owned by the document detail page of Anqi CMS?In website content operations, the document detail page is not just for displaying articles or products, it often needs to establish a connection with a broader content system, such as displaying detailed information about its category.This not only enhances the user experience, guides users to discover more related content, but also helps improve the internal link structure and SEO performance of the website.As an experienced website operation expert, I deeply understand the strength and flexibility of AnQiCMS (AnQiCMS) in dealing with such needs.

2025-11-06

How to format the display of the release and update time of AnQiCMS documents?

As an experienced website operations expert, I am well aware that the accuracy and readability of time in content display are crucial for user experience and Search Engine Optimization (SEO).AnQiCMS as an efficient and flexible content management system provides a very convenient way to control the display format of the publication and update time of articles.This article will focus on how AnQiCMS formats and displays the publication and update times of documents, and will explain the secrets and practical skills in detail.

2025-11-06

How to display multiple cover group images in a document detail page?

As an expert who deeply understands website operation, I know that high-quality, visually appealing content is the key to retaining users and enhancing the value of the website.AnQiCMS (AnQiCMS) is a powerful content management system that provides great flexibility in content presentation.Today, let's delve into a common need: how to cleverly loop multiple cover group images on the document detail page to make the content more expressive. --- ## Secure CMS: Delicate Presentation!A guide to displaying multiple cover group images in document detail pages In the era of content is king

2025-11-06

How to get the list of articles under a specified category in AnQiCMS?

## Easily retrieve the list of articles under a specified category in AnQiCMS As an experienced website operations expert, I fully understand the core value of a content management system (CMS) lies in its ability to organize and present content.Among many features, how to efficiently extract and display articles from a specific category is an indispensable part of the daily work of website operators.Today, let's delve deep into how AnQiCMS can help you achieve this goal, making technical details intuitive and easy to understand.

2025-11-06

How to implement pagination and page number display for article lists in AnQi CMS?

As an experienced website operations expert, I am well aware of the crucial role of a powerful and easy-to-use content management system for the success of a website.AnQiCMS (AnQiCMS) boasts a high-performance architecture based on the Go language and flexible template mechanism, providing an excellent experience in content publishing and management.Among them, efficiently displaying a large amount of content, especially implementing the pagination function of the article list, is an indispensable factor in improving user experience and website SEO performance.Today, let's delve deeply into how AnQi CMS cleverly implements this feature and demonstrates friendly page navigation.--- ##

2025-11-06

How to filter and display the document list based on recommended properties (Flag)?

As an experienced website operations expert, I know that the powerful function of the Content Management System (CMS) lies in its flexibility and ease of use.In AnQiCMS (AnQiCMS), the 'recommended attribute' (Flag) of the document is such a seemingly simple feature, which can actually greatly improve the efficiency of content operation and the diversity of website display.Today, let's delve into how to cleverly use recommendation attributes to achieve precise filtering and display of document lists.

2025-11-06

How to sort the document list by publication time or views?

In the world of website operation, the organization and presentation of content directly affects the user experience and the efficiency of information transmission.AnQiCMS (AnQiCMS) as an efficient content management system, fully understands the importance of this requirement, and therefore provides powerful and flexible options for sorting document lists, allowing you to easily control the display priority of content according to different operation goals.Today, let's delve into how to sort document lists in Anqi CMS using publication time or views.

2025-11-06