### Javascript Console Log Source: https://github.com/zerodevx/zero-md/blob/main/src/fixtures/feat.html A basic Javascript snippet that prints 'hello world!' to the console. This is a fundamental example for demonstrating Javascript execution. ```javascript console.log('hello world!') ``` -------------------------------- ### Install zero-md with npm and Use in JavaScript Source: https://github.com/zerodevx/zero-md/blob/main/docs/getting-started.md This JavaScript snippet demonstrates how to install zero-md using npm and integrate it into a web project. It shows importing the `ZeroMd` class, registering it as a custom element, and then using the `` tag within an application's rendering logic. ```javascript // Import element definition import ZeroMd from 'zero-md' // Register custom element customElements.define('zero-md', ZeroMd) // Render anywhere app.render(``) ``` -------------------------------- ### Install zero-md via CDN and Register Manually Source: https://github.com/zerodevx/zero-md/blob/main/docs/getting-started.md This HTML snippet illustrates an alternative CDN installation method for zero-md. It imports the element definition and then manually registers the custom element 'zero-md' using `customElements.define()`, providing more control over the registration process. ```html ... ``` -------------------------------- ### Install and use zero-md in web projects (npm/yarn) Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/installation.md This section covers installing zero-md using npm or yarn, followed by importing and registering the custom element in JavaScript. It also shows how to render the component programmatically. This method is suitable for projects managed with Node.js. ```bash $ npm install --save zero-md ``` ```javascript // Import the element definition import ZeroMd from 'zero-md' // Register the custom element customElements.define('zero-md', ZeroMd) // Render anywhere app.render(``, target) ``` ```html ... ``` -------------------------------- ### Basic zero-md Usage Examples Source: https://github.com/zerodevx/zero-md/blob/main/README.md This section provides examples of how to use the zero-md web component. It covers displaying an external markdown file using the `src` attribute, rendering markdown directly within a ` ``` -------------------------------- ### Install zero-md via npm and Use in JavaScript Source: https://github.com/zerodevx/zero-md/blob/main/README.md This code demonstrates how to install zero-md using npm and then import and register the custom element in a JavaScript project. It shows the programmatic way to integrate zero-md into a web application, allowing for dynamic rendering. ```bash $ npm i zero-md ``` ```javascript // Import the element definition import ZeroMd from 'zero-md' // Register the custom element customElements.define('zero-md', ZeroMd) // Render anywhere app.render(``, target) ``` -------------------------------- ### Zero-MD with Default Stylesheet Template Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/basic-usage.md This example demonstrates the semantic equivalent of the basic usage, explicitly showing the default template that loads Github-markdown CSS and PrismJS highlighting styles. ```html ``` -------------------------------- ### Run zero-md Dev Server (Shell) Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/contributing.md Starts the development server for zero-md. This command is typically run from the project's root directory. After execution, navigate to http://localhost:8000 in your browser to view the test suite. ```shell $ npm run dev ``` -------------------------------- ### MathJax/KaTeX Math Expressions Source: https://github.com/zerodevx/zero-md/blob/main/src/fixtures/feat.html Examples of inline and block-level mathematical expressions rendered using MathJax or KaTeX. Supports various mathematical notations including square roots and summations. ```katex I = \pm\sqrt{a^2 + b^2} ``` ```katex B = \pm\sqrt{a^2 + b^2} ``` ```math \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) ``` -------------------------------- ### Support MathJax with zero-md Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/recipes.md This recipe explains how to render mathematical equations using MathJax within zero-md. It requires loading the MathJax library and configuring its settings for inline math delimiters. An event listener is set up to trigger MathJax's typesetting after zero-md has rendered its content. The example includes a sample Markdown file with inline math and the corresponding HTML setup. ```html ``` -------------------------------- ### Mermaid Flowchart and Sequence Diagram Source: https://github.com/zerodevx/zero-md/blob/main/src/fixtures/feat.html Code snippets for generating visual diagrams using Mermaid. Includes a flowchart for deployment processes and a sequence diagram illustrating communication between entities. ```mermaid flowchart TD A[Deploy to production] --> B{Is it Friday?}; B --> |Yes| C[Do not deploy!]; B --> |No| D[Run deploy.sh to deploy!]; C --> E[Enjoy your weekend!]; D --> E[Enjoy your weekend!]; ``` ```mermaid sequenceDiagram Pumbaa->>Timon:I ate like a pig. Timon->>Pumbaa:Pumbaa, you ARE a pig. ``` -------------------------------- ### Render Inline Math Equations with LaTeX Source: https://github.com/zerodevx/zero-md/blob/main/docs/getting-started.md This showcases the inline math rendering capability of zero-md using LaTeX syntax enclosed in single dollar signs (`$`). It provides an example of a mathematical expression that will be rendered by the KaTeX library. ```text $\sqrt{3x-1}+(1+x)^2$ ``` -------------------------------- ### Render Block-Level Math Equations with LaTeX Source: https://github.com/zerodevx/zero-md/blob/main/docs/getting-started.md This example demonstrates how to render block-level mathematical equations using LaTeX syntax enclosed in double dollar signs (`$$`). The rendered output will be displayed as a distinct block, suitable for more complex equations. ```text $$\sqrt{3x-1}+(1+x)^2$$ ``` -------------------------------- ### Load Marked and Prism Scripts Before Zero-MD Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/migration-guide.md The `marked-url` and `prism-url` attributes are removed in zero-md V2. To use custom URLs for these libraries, load their respective script tags in the `` before importing `zero-md`. This ensures that the libraries are available when `zero-md` initializes. ```html ... ``` -------------------------------- ### Create Mermaid Diagrams in Markdown Source: https://github.com/zerodevx/zero-md/blob/main/docs/getting-started.md This example shows how to create diagrams using the Mermaid syntax within a fenced code block with the language specified as `mermaid`. Zero-md supports rendering these diagrams directly within the Markdown content. ```markdown ```mermaid sequenceDiagram Foo->>Bar:I ate like a pig. Bar->>Foo:Foo, you ARE a pig. ``` ``` -------------------------------- ### Google Analytics Configuration (JavaScript) Source: https://github.com/zerodevx/zero-md/blob/main/docs/v1/demo/index.html This snippet configures Google Analytics by initializing the dataLayer and setting the tracking configuration. It's a standard setup for integrating Google Analytics into a web page. ```javascript window.dataLayer = window.dataLayer || [] function gtag() { dataLayer.push(arguments) } gtag('js', new Date()) gtag('config', 'UA-66946548-3') ``` -------------------------------- ### Specify Custom URLs for Marked and Prism Libraries Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/advanced-usage.md This example shows how to load Marked.js and Prism.js from custom URLs instead of their default CDNs. This is useful if you host these libraries locally or use a different CDN. The custom scripts should be loaded before the script. ```html ``` -------------------------------- ### Zero-MD with Custom Stylesheets via Link Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/basic-usage.md This example shows how to load external CSS files for styling zero-md. By using `` tags within the ` ``` -------------------------------- ### Rename ZeroMd Config Object to ZeroMdConfig Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/migration-guide.md The global configuration object for zero-md has been renamed from `ZeroMd.config` (V1) to `ZeroMdConfig` (V2). This change affects how global settings like `cssUrls` are applied. Ensure you use the new `ZeroMdConfig` object when configuring zero-md globally. ```html ``` -------------------------------- ### Replace CSS URLs Attribute with Link Tag in Zero-MD Source: https://github.com/zerodevx/zero-md/blob/main/docs/v2/migration-guide.md The `css-urls` attribute in zero-md is deprecated. Use standard HTML `` tags within a `