Syntax Guide¶
As a content publisher for our MkDocs-based Knowledge Base, it's important to leverage all available formatting options to create engaging and informative content. This guide now includes advanced Material for MkDocs formatting options to further enhance your articles.
1. Metadata and Frontmatter¶
Every article should begin with frontmatter. This is enclosed in triple dashes and contains important metadata:
---
title: Your Article Title
date: 2024-06-29
description: A brief description of your article (under 160 characters)
tags:
- tag1
- tag2
---
2. Headings and Table of Contents¶
Use headings to structure your content. The table of contents will be automatically generated:
3. Code Blocks and Syntax Highlighting¶
For code snippets, use triple backticks with the language specified:
In addition to the existing syntax, you can now add line numbers and highlight specific lines:
- This line will be highlighted
4. Admonitions¶
Recommended HTML Admonition Format¶
Admonitions are highlighted blocks used to emphasize important information. Due to reliability issues with Markdown-style admonitions, we strongly recommend using HTML-style admonitions as the default approach:
<div class="admonition type">
<p class="admonition-title">Title</p>
<p>Content of the admonition.</p>
</div>
Replace type with one of the supported types (note, info, warning, etc.).
Example:
<div class="admonition warning">
<p class="admonition-title">Security Notice</p>
<p>Never share your credentials with unauthorized personnel.</p>
</div>
This renders as:
Security Notice
Never share your credentials with unauthorized personnel.
HTML Admonition Types¶
All of these admonition types are available using the HTML format by changing the class name:
note- Blue information blocksabstract- Summary blocksinfo- Information blockstip- Helpful tip blockssuccess- Success message blocksquestion- FAQ blockswarning- Caution/warning blocksfailure- Failure message blocksdanger- Critical alert blocksbug- Known issue blocksexample- Example blocksquote- Quote blocks
Alternative Markdown-style Admonitions (Less Reliable)¶
While HTML admonitions are preferred for reliability, you can also use Markdown-style admonitions. However, these are extremely sensitive to formatting and may not render correctly in all environments:
For Markdown-style admonitions to render correctly, you MUST follow these rules:
- Start with three exclamation marks (
!!!) followed by the type and optional title - Add a blank line after the admonition declaration line
- Indent all content with exactly 4 spaces (not tabs)
- Maintain consistent indentation throughout the admonition
- Do not add extra blank lines between the declaration and content
Admonition Formatting Is Very Strict
Improperly formatted admonitions will not render at all. The most common errors are:
- Missing the blank line after the declaration
- Incorrect indentation of content (must be exactly 4 spaces)
- Adding the content on the same line as the declaration
Correct and Incorrect Examples¶
✅ Correct Formatting:¶
This renders as:
Security Notice
Never share your credentials with unauthorized personnel.
❌ Incorrect Formatting (no blank line after declaration):¶
❌ Incorrect Formatting (content on same line):¶
❌ Incorrect Formatting (wrong indentation):¶
Troubleshooting Admonition Rendering Issues¶
If your admonitions aren't rendering properly, follow these solutions in order:
-
Use HTML admonition format (recommended): Switch to the HTML admonition format as shown above, which is more reliable across different rendering environments.
-
Use HTML comments to force line breaks (for Markdown-style admonitions):
-
Check for invisible characters: Sometimes copying and pasting can introduce invisible characters that break the syntax. Try retyping the admonition from scratch.
-
Ensure consistent line endings: Mixed line endings (CRLF vs LF) can sometimes cause rendering issues. Use a text editor to normalize line endings.
-
Verify MkDocs configuration: Make sure the pymdownx.admonition extension is properly enabled in your mkdocs.yml file.
Inline blocks¶
Admonitions can also be rendered as inline blocks (e.g., for sidebars). You can place them to the left using the inline modifier, or to the right using the inline end modifier.
Left-aligned inline block¶
Here's the code for a left-aligned inline block:
!!! info inline "Lorem ipsum"
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nulla et euismod nulla.
Curabitur feugiat, tortor non consequat
finibus, justo purus auctor massa, nec
semper lorem quam in massa.
This is some text that will appear next to the inline block.
This renders as:
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
This is some text that will appear next to the inline block. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa. Sed sollicitudin ante sed turpis pulvinar, et venenatis arcu semper. Fusce non lorem at mi mattis gravida. Praesent sit amet nunc nec libero fermentum ullamcorper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa. Sed sollicitudin ante sed turpis pulvinar, et venenatis arcu semper. Fusce non lorem at mi mattis gravida. Praesent sit amet nunc nec libero fermentum ullamcorper.
Right-aligned inline block¶
Here's the code for a right-aligned inline block:
!!! info inline end "Lorem ipsum"
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nulla et euismod nulla.
Curabitur feugiat, tortor non consequat
finibus, justo purus auctor massa, nec
semper lorem quam in massa.
This is some text that will appear next to the inline end block.
This renders as:
This is some text that will appear next to the inline end block.
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
Important: Admonitions that use the inline modifiers must be declared prior to the content block you want to place them beside. If there's insufficient space to render the admonition next to the block, the admonition will stretch to the full width of the viewport, e.g., on mobile viewports.
Supported Types Examples¶
MkDocs supports several types of admonitions, each with its own style and icon. Here are examples using the recommended HTML format:
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This is a simple note admonition.</p>
</div>
Note
This is a simple note admonition.
<div class="admonition abstract">
<p class="admonition-title">Abstract</p>
<p>This is an abstract or summary.</p>
</div>
Abstract
This is an abstract or summary.
<div class="admonition info">
<p class="admonition-title">Information</p>
<p>Here's some important information.</p>
</div>
Information
Here's some important information.
<div class="admonition tip">
<p class="admonition-title">Pro Tip</p>
<p>Here's a helpful tip for our users.</p>
</div>
Pro Tip
Here's a helpful tip for our users.
<div class="admonition success">
<p class="admonition-title">Success</p>
<p>Great job! You've done it correctly.</p>
</div>
Success
Great job! You've done it correctly.
<div class="admonition question">
<p class="admonition-title">FAQ</p>
<p>Frequently asked question here.</p>
</div>
FAQ
Frequently asked question here.
<div class="admonition warning">
<p class="admonition-title">Caution</p>
<p>Be careful when using this feature.</p>
</div>
Caution
Be careful when using this feature.
<div class="admonition failure">
<p class="admonition-title">Failure</p>
<p>This action resulted in a failure.</p>
</div>
Failure
This action resulted in a failure.
<div class="admonition danger">
<p class="admonition-title">Critical</p>
<p>This action cannot be undone!</p>
</div>
Critical
This action cannot be undone!
<div class="admonition bug">
<p class="admonition-title">Known Issue</p>
<p>There's a known bug with this feature.</p>
</div>
Known Issue
There's a known bug with this feature.
<div class="admonition example">
<p class="admonition-title">Example</p>
<p>Here's an example of how to use this.</p>
</div>
Example
Here's an example of how to use this.
<div class="admonition quote">
<p class="admonition-title">Famous Quote</p>
<p>"To be or not to be, that is the question."</p>
</div>
Famous Quote
"To be or not to be, that is the question."
Admonition Formatting Specification¶
When using admonitions in MkDocs, adhere to the following specification:
- Alignment: Admonitions must be aligned with the left margin of the document.
- Indentation: Do not indent admonitions. Any indentation will prevent them from rendering correctly.
- Syntax: Start each admonition with three exclamation marks (!!!) followed by the type and optional title.
- Content: The content of the admonition should be indented by 4 spaces on the lines following the admonition declaration.
Common Error
A frequent mistake is indenting the entire admonition block when it appears within other content blocks. Even when inside a numbered list or other indented section, the !!! marker should be at the document's left margin (column 1), not indented to match the surrounding content.
5. Task Lists¶
Create interactive checklists:
Rendered output:
- Completed task
- Pending task
6. Footnotes¶
Add footnotes for additional information:
Rendered output:
Here's a sentence with a footnote.1
7. Diagrams with Mermaid¶
Create diagrams using Mermaid syntax:
```mermaid
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Keep trying]
D --> B
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Keep trying]
D --> B 8. Mathematical Equations¶
Use LaTeX syntax for equations:
Rendered output:
\(E = mc^2\)
9. Tabbed Content¶
Create tabbed sections:
Rendered output:
Content for tab 1
Content for tab 2
10. Keyboard Keys¶
Display keyboard shortcuts:
Rendered output:
Ctrl+Alt+Del
11. Text Formatting¶
In addition to highlighting, you can now use other text formatting options:
- Ctrl+Alt+Del (keys)
- This was marked (marked text)
- This was inserted (inserted text)
This was deleted(deleted text)
12. Emojis¶
Include emojis in your content:
Rendered output:
:smile: :rocket: :books:
13. Image Lightbox¶
Images will automatically use the lightbox feature. Just insert them as usual:
Rendered output:
[Note: The actual image would be displayed here. For this example, imagine a clickable image that opens in a lightbox when clicked.]
14. Tables¶
Create tables using standard Markdown syntax or CSV files (with table-reader plugin):
Rendered output:
| Column 1 | Column 2 |
|---|---|
| Cell 1 | Cell 2 |
You can now add a title to your tables:
| Method | Description |
|---|---|
GET | :material-check: Fetch resource |
PUT | :material-check-all: Update resource |
DELETE | :material-close: Delete resource |
Table: API Methods
15. Tags¶
Use tags in your frontmatter for better categorization and searchability.
Rendered output:
[Note: Tags are typically displayed at the top or bottom of the page, often as clickable elements. The exact rendering depends on the theme and configuration.]
16. Tooltips¶
You can now add tooltips to your text:
17. Buttons¶
Create clickable buttons:
18. Icons and Emojis¶
Include icons from the Material library:
:material-account-circle: – :fontawesome-regular-laugh-wink:
19. Content Tabs¶
Create content tabs for alternative content:
20. Data Tables¶
Create sortable data tables:
| Method | Description |
|---|---|
GET | :material-check: Fetch resource |
PUT | :material-check-all: Update resource |
DELETE | :material-close: Delete resource |
21. Abbreviations¶
Add explanations to abbreviations:
The HTML specification is maintained by the W3C.
*[HTML]: Hyper Text Markup Language *[W3C]: World Wide Web Consortium
22. Critic¶
Use critic markup for tracking changes:
Text can be {--deleted--} and replacement text {++added++}. This can also be combined into {one~>a single} operation. {Highlighting} is also possible {>>and comments can be added inline<<}.
{==
Formatting can also be applied to blocks by putting the opening and closing tags on separate lines and adding new lines between the tags and the content.
==}
23. Formatting¶
Combine formatting options for rich text styling:
- This is bold text
- This is italicized text
- This is bold and italicized text
This is inline codeThis is strikethrough text- This is highlighted text
24. Numbering in Headings and Sections¶
When creating content, use numbering judiciously to enhance readability and reference-ability. Here are the guidelines for using numbers in headings and sections:
Headings Without Numbers¶
If your sections contain numbered steps or lists, avoid using numbers in the headings themselves. For example:
Project Setup¶
- Initialize the project
- Install dependencies
- Configure settings
Continuous Numbering Across Sections¶
When using numbered steps or lists within sections, continue the numbering sequence throughout the entire document. This approach makes it easier for users to reference specific steps. For example:
Project Setup¶
- Initialize the project
- Install dependencies
- Configure settings
Development Process¶
- Write code
- Run tests
- Deploy to staging
Headings With Numbers¶
In documents where sections don't contain numbered steps, you can use numbers in headings for better organization:
1. Introduction¶
2. Getting Started¶
3. Advanced Features¶
Consistency is Key
Choose one numbering style for your document and stick to it throughout. This consistency helps readers navigate and reference your content more easily.
Best Practices for Engaging Content Creation¶
As a content publisher, your goal is to create documentation that's both informative and engaging. Here's how to leverage our MkDocs setup to enhance the user experience:
1. Structure for Clarity and Navigation¶
- Use descriptive titles and a logical hierarchy of headings.
- Include a table of contents for longer articles.
- Break up text with short paragraphs and bullet points.
2. Utilize Rich Formatting and Interactive Elements¶
- Emphasize key points with bold, italic, or highlighted text.
- Use admonitions to call out important information:
Pro Tip
Admonitions visually separate different types of information. Use them sparingly for maximum impact.
- Create tabbed content for organizing related information:
Basic setup instructions
Detailed configuration options
- Implement task lists for step-by-step guides:
- Plan your content
- Write your draft
- Review and revise
3. Enhance with Visual and Technical Elements¶
- Include relevant images, diagrams, or screenshots.
- Use Mermaid for flowcharts or sequence diagrams:
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2] - Add syntax-highlighted code blocks:
- Use LaTeX for mathematical equations: \(E = mc^2\)
4. Optimize for Accessibility and Searchability¶
- Use descriptive alt text for images.
- Create keyboard shortcuts for important actions: Ctrl+S
- Include relevant tags in your frontmatter:
- Cross-link related articles within your documentation.
5. Maintain Quality and Encourage Engagement¶
- Follow a consistent style guide and tone across all documentation.
- Provide real-world examples and use cases.
- Keep content up-to-date with the latest product changes.
- Include a clear process for user feedback and contributions.
Remember, the key is to balance information density with readability and visual appeal. By incorporating these practices, you'll create documentation that's not only informative but also engaging and user-friendly. Happy publishing!
KB Article Writing Prompt: Leveraging the Syntax Guide¶
As a content creator for our MkDocs-based Knowledge Base, your goal is to produce highly informative, engaging, and well-structured articles. To achieve this, refer to our comprehensive Syntax Guide and incorporate as many of its features as possible in your writing. Here's how to approach your article creation:
-
Review the Syntax Guide thoroughly before starting your article.
-
For each section of your article, consider which elements from the Syntax Guide could enhance its presentation and clarity.
-
Aim to incorporate at least one example of each major feature described in the Syntax Guide, including but not limited to: - Proper frontmatter with metadata - Structured headings - Code blocks with syntax highlighting - HTML-style admonitions (preferred over Markdown-style admonitions for reliability) - Task lists - Footnotes - Mermaid diagrams - Mathematical equations - Tabbed content - Keyboard key formatting - Text highlighting - Emojis - Images (which will use the lightbox feature) - Tables - Tags
-
Important Note on Admonitions: Always use HTML-style admonitions rather than Markdown-style ones to ensure consistent rendering. For example:
-
Use these features judiciously to enhance your content, not just for the sake of using them. Each element should serve a purpose in improving understanding or engagement.
-
Pay special attention to the "Best Practices for Engaging Content Creation" section at the end of the Syntax Guide. Apply these principles throughout your article.
-
Before finalizing your article, review it against the Syntax Guide to ensure you've made the most of the available formatting options.
-
Remember that while comprehensive formatting is encouraged, the primary goal is to create clear, informative, and user-friendly documentation.
-
Do not include conclusion sections in KB articles. The content should be self-contained and focused on providing information and guidance without unnecessary summarization at the end.
By following this approach, you'll create KB articles that not only contain valuable information but also take full advantage of our MkDocs setup to present that information in the most effective and engaging way possible.
-
This is the footnote content. ↩