In Anqi CMS, ensuring that Markdown content, mathematical formulas, and flowcharts display well on mobile devices is a key factor in improving user experience and website professionalism.As an expert in the operation of AnQiCMS, I know that high-quality content not only needs to be carefully crafted but also needs to be seamlessly presented on various terminals. AnQiCMS with its flexible template system and the high performance of Go language, provides the foundation for us to achieve this goal.
Optimize the display of content in the mobile version of AnQiCMS
Enable Markdown editor and content rendering basis
AnQiCMS provides a Markdown editor, greatly facilitating content creators.Ensure that Markdown, formulas, and flowcharts are displayed well on mobile devices, and first need to enable this feature in the background.Log in to the AnQiCMS backend's "Global Settings" -> "Content Settings", enable Markdown editor.After enabling, the system will handle Markdown syntax, but some additional frontend integration work is still needed to display these complex elements correctly and beautifully on the front-end page.
AnQiCMS supports various website modes, including adaptive, code adaptation, and PC+mobile independent site modes.No matter which mode is adopted, we can customize it in the flexible template system to meet the display needs of mobile devices.The template file is usually located/templatethe directory, wherebase.htmlIt is the global skeleton file, the ideal place to introduce universal CSS and JavaScript libraries.
Ensure the adaptive display of Markdown content.
Markdown content, especially when it includes tables or code blocks, may encounter width overflow issues on mobile devices. AnQiCMS integratesgithub-markdown-cssA library that can provide a set of beautiful and relatively responsive default styles for Markdown rendering. We can addbase.htmlthis style sheet to the head of the file:
<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" />
However, for especially wide tables or code blocks, basic styles may not be enough.At this time, you can enhance its mobility adaptability through custom CSS.A common and effective practice is to include a container for Markdown content, such as adiv)to addoverflow-x: auto;Property. This way, when the content width exceeds the screen, the user can swipe horizontally to view the full content instead of causing the overall layout of the page to be chaotic.At the same time, make sure that all images are set tomax-width: 100%; height: auto;To prevent image overflow.
Elegant display of mathematical formulas on mobile devices
For Markdown content containing mathematical formulas, AnQiCMS combines the MathJax library to correctly render it on the web.MathJax is a powerful JavaScript rendering engine that can convert LaTeX, MathML, or AsciiMath markup into high-quality mathematical symbols.To enable this feature, you also need tobase.htmlIntroduce the CDN script of MathJax in the header of the file:
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
MathJax itself has good support for responsive design, it can automatically adjust the layout and scaling of formulas according to the screen size.On mobile devices, MathJax usually optimizes the display by default, for example, providing horizontal scrolling or collapsing features when there is not enough space.Content creators should also avoid overly long or complex single-line formulas when writing equations, and consider displaying them in segments to improve readability.
Clear presentation of flowcharts on mobile devices
The flowcharts in Markdown are usually implemented through Mermaid syntax.AnQiCMS uses the Mermaid library to convert text-defined flowcharts into SVG graphics.In order to display these flowcharts on mobile devices, we need tobase.htmlModule script for introducing Mermaid in the file:
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
Similar to mathematical formulas, the SVG graphics generated by Mermaid have good scalability.However, complex flowcharts may still appear cluttered on small screens.To optimize the mobile experience, you can apply the same width as the wide Markdown content to the container of the Mermaid diagram.overflow-x: auto;CSS rules, allow users to scroll horizontally as needed to view the entire chart.In addition, when creating content, it should be simplified as much as possible, avoiding overly complex structures that require too much scrolling to understand on mobile devices.
Collaboration in template customization and content creation
AnQiCMS's template system allows us to deeply customize. If the default responsive strategy does not meet specific needs, such as providing a completely different layout or specialized interaction for mobile devices, we can make use of AnQiCMS's 'PC+Mobile independent site mode' or 'mobile template directory'mobile/Function. This allows us to design a separate template and style for mobile devices, thus achieving more precise control.
Finally, the good presentation of mobile content depends not only on technical configuration, but also on the efforts of content creators.When creating Markdown, formulas, or flowcharts, always keep the reading habits and device limitations of mobile users in mind.Avoid creating overly large, information-dense single elements; appropriately splitting and simplifying them will greatly enhance the reading experience on mobile devices.By combining AnQiCMS's powerful content management and flexible template system with these frontend optimization strategies, we can ensure that your website content is presented in **status** on any device, attracting and retaining valuable readers.
Frequently Asked Questions (FAQ)
Q1: Why am I unable to display formulas or flowcharts even though I have enabled the Markdown editor and followed the instructions to introduce the CDN file in the AnQiCMS backend?
A1: Please first check the console in the browser developer tools (F12) for any error messages, as this usually points to the problem.Ensure that the CDN link is correct and accessible. Additionally, check yourbase.htmlThe file is saved and deployed correctly. After modifying AnQiCMS templates, it may be necessary to clear the system cache. Try updating the cache feature in the background.Finally, confirm that the Markdown syntax itself is correct, for example, MathJax formulas are used$$...$$or$...$,Mermaid flowchart usagemermaid ....
Q2: When my Markdown table is displayed on mobile phones, it will overflow the screen. What are some common CSS methods to solve this problem?
A2: Yes, a general solution is to add CSS styles to the parent container that contains Markdown content. You can give the area where Markdown is rendered (for example<article>Label or specificdivAdd to containeroverflow-x: auto;This way, when the width of the table or code block exceeds the screen, the browser will automatically display a horizontal scrollbar for the container, allowing users to scroll to view the full content without disrupting the overall page layout.At the same time, make sure the image is set tomax-width: 100%; height: auto;.
Q3: If I do not want to use CDN resources, does AnQiCMS support deploying MathJax or Mermaid libraries to a local server?
A3: AnQiCMS itself does not built-in these third-party libraries, but its flexible template system allows you to do so. You can download the release version files from the official websites of MathJax and Mermaid, and then upload them to AnQiCMS's/public/static/Custom path under the directory. Then, modifybase.htmlofscriptandlinklabel'ssrcorhrefThe property should point to the path of your local deployment. Please note that manually deploying and maintaining these libraries may require more work, and ensure that updates are synchronized in a timely manner.