### Embedding a GitHub File from a Start Line Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Specify only the starting line for embedding by appending '#L{start}' to the GitHub file URL. ```bash # コードの開始行のみ指定 https://github.com/octocat/Spoon-Knife/blob/main/README.md#L3 ``` -------------------------------- ### Quadratic Formula Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Example of the quadratic formula using TeX notation. ```tex x = - b ± b 2 - 4 a c 2 a . ``` -------------------------------- ### JavaScript Console Log Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Example JavaScript code for logging to the console. ```javascript const var = () => { console.log("hello") } ``` -------------------------------- ### Normal link with javascript path Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Illustrates a link that starts with '/javascript:' which is treated as a relative path, not a protocol. ```markdown [normal link](/javascript:link) ``` -------------------------------- ### Mermaid Gantt Chart Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed a Gantt chart for project timeline visualization. Supports task dependencies and status. ```mermaid gantt dateFormat YYYY-MM-DD title Adding GANTT diagram to mermaid excludes weekdays 2014-01-10 section A section Completed task :done, des1, 2014-01-06,2014-01-08 Active task :active, des2, 2014-01-09, 3d Future task : des3, after des2, 5d Future task2 : des4, after des3, 5d ``` -------------------------------- ### Mermaid Sequence Diagram (Simplified) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md A simplified sequence diagram example showing basic actor interactions. ```mermaid sequenceDiagram actor Alice actor Bob Alice->>Bob: Hi Bob Bob->>Alice: Hi Alice ``` -------------------------------- ### XSS Attempt with Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An example showing a potential XSS attempt embedded with a math expression. ```markdown `1+1=2$` ``` ```latex 1+1=2$ ``` -------------------------------- ### Inline Inequality Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An example of an inline mathematical inequality. ```markdown `$1+1<3$` ``` ```latex $1+1<3$ ``` -------------------------------- ### Mermaid Flowchart Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed a basic flowchart using the 'graph TD' syntax. This is useful for visualizing simple directed graphs. ```mermaid graph TD; A-->B; A-->C; B-->D; C-->D; ``` -------------------------------- ### Mermaid Sequence Diagram Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed a sequence diagram to illustrate interactions between participants over time. Supports loops and notes. ```mermaid sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts
prevail! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good! ``` -------------------------------- ### Headings Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Use '#' symbols to define heading levels, from 1 to 4. It is recommended to start with H2 for accessibility. ```markdown # 見出し1 ## 見出し2 ### 見出し3 #### 見出し4 ``` -------------------------------- ### Blockquotes Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Create blockquotes by starting lines with '>'. Multiple lines are treated as a single quote. ```markdown > 引用文 > 引用文 ``` -------------------------------- ### Mermaid Class Diagram Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed a class diagram to show the structure of a system, including classes, attributes, and relationships. ```mermaid classDiagram Class01 <|-- AveryLongClass : Cool Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 --> C2 : Where am i? Class09 --* C3 Class09 --|> Class07 Class07 : equals() Class07 : Object[] elementData Class01 : size() Class01 : int chimp Class01 : int gorilla Class08 <--> C2: Cool label ``` -------------------------------- ### Diff Syntax Highlighting Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Use 'diff' followed by an optional language to highlight differences. Lines starting with '+', '-', ' ', '>', or '<' are highlighted. ```diff @@ -4,6 +4,5 @@ + const foo = bar.baz([1, 2, 3]) + 1; - let foo = bar.baz([1, 2, 3]); ``` -------------------------------- ### Embedding a GitHub File with Line Range Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Specify a range of lines to display by appending '#L{start}-{end}' to the GitHub file URL. ```bash # コードの開始行と終了行を指定 https://github.com/octocat/Spoon-Knife/blob/main/README.md#L1-L3 ``` -------------------------------- ### Mermaid Journey Diagram Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed a journey diagram to visualize user experience or workflow stages. Includes activities and participants. ```mermaid journey title My working day section Go to work Make tea: 5: Me Go upstairs: 3: Me Do work: 1: Me, Cat section Go home Go downstairs: 5: Me Sit down: 5: Me ``` -------------------------------- ### Mermaid ER Diagram Example Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/303-example-embed-mermaid.md Embed an Entity-Relationship diagram to model database structures. Shows entities and their relationships. ```mermaid erDiagram CUSTOMER ||--o{ ORDER : places ORDER ||--|{ LINE-ITEM : contains CUSTOMER }|..|{ DELIVERY-ADDRESS : uses ``` -------------------------------- ### Convert Markdown to HTML Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-markdown-html/README.md Use `markdownToHtml` to convert standard Zenn Markdown to HTML. Refer to the Zenn Markdown guide for supported syntax. ```javascript import markdownToHtml from 'zenn-markdown-html'; const html = markdownToHtml(markdown); ``` -------------------------------- ### Table Creation Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Create tables using pipes '|' to define columns and hyphens '-' for the header separator. ```markdown | Head | Head | Head | | ---- | ---- | ---- | | Text | Text | Text | | Text | Text | Text | ``` -------------------------------- ### Preview Markdown Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to toggle markdown preview. Press again to return to the editor. ```bash Ctrl + P ``` -------------------------------- ### Save Content Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to save the current markdown content. ```bash Ctrl + S ``` -------------------------------- ### Multiple Inline Math Expressions Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates multiple inline math expressions on the same line. ```markdown `$x$ $y$` ``` ```latex $x$ $y$ ``` -------------------------------- ### Display Math with Align Environment Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode math expression using the \\begin{align} environment for alignment. ```latex $$ \\begin{align} J_w \\ddot{\\theta}_w &= T - \\frac{f}{r} \\ \\end{align} $$ ``` -------------------------------- ### Inline Fraction Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates an inline fraction using LaTeX syntax. ```markdown `$ rac{1}{2}$` ``` ```latex $\\frac{1}{2}$ ``` -------------------------------- ### Table Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a table with a header and rows. ```markdown | Head | Head | Head | | ---- | ---- | ---- | | Text | Text | Text | | Text | Text | Text | ``` -------------------------------- ### Correct Image Path (WebP) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md WebP images are also supported with direct paths. ```markdown ![](/images/example-images/zenn-editor.webp) ``` -------------------------------- ### Import Zenn Content CSS Source: https://github.com/zenn-dev/zenn-editor/blob/canary/README.md Import the CSS styles for Zenn content. This should be done to ensure proper rendering of Markdown previews. ```ts import 'zenn-content-css'; ``` -------------------------------- ### Bold Text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to apply bold formatting to selected text. ```bash Ctrl + B ``` -------------------------------- ### Insert List Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to insert a bulleted list. ```bash Ctrl + L ``` -------------------------------- ### Correct Image Path (PNG) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md Use direct paths for PNG images. This is the standard way to include images. ```markdown ![](/images/example-images/zenn-editor.png) ``` -------------------------------- ### Inline Exponent Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates an inline mathematical expression with an exponent. ```markdown `$a^{b}$` ``` ```latex $a^{b}$ ``` -------------------------------- ### Insert Embed Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to open the embed modal for inserting tweets, YouTube, etc. ```bash Ctrl + I ``` -------------------------------- ### Image as a Link Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Make an image clickable by wrapping the image markdown within link markdown. ```markdown [![](画像のURL)](リンクのURL) ``` -------------------------------- ### Basic Image Insertion Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Insert images using the '!' followed by the URL in parentheses. ```markdown ![](https://画像のURL) ``` -------------------------------- ### Embedding a StackBlitz Project Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed a StackBlitz project by using the 'Embed URL' provided by StackBlitz. ```markdown @[stackblitz](embed用のURL) ``` -------------------------------- ### Insert Numbered List Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to insert a numbered list. ```bash Ctrl + alt + L ``` -------------------------------- ### Link with file protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Shows a markdown link using the file:/// protocol, which is typically restricted for security reasons. ```markdown [xss link](file:///123) ``` -------------------------------- ### Unsupported Image Extension (SVG) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md SVG images are not supported and will not be rendered. ```markdown ![](/images/example-images/zenn-editor.svg) ``` -------------------------------- ### Link Card with @[card] syntax Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Use the '@[card](URL)' syntax to explicitly create a link card, especially useful when URLs contain special characters. ```markdown https://zenn.dev/__example__ ``` -------------------------------- ### Insert Text Link Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to insert a text link. ```bash Ctrl + K ``` -------------------------------- ### Text Link Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a text link. ```markdown [アンカーテキスト](リンクのURL) ``` -------------------------------- ### Inline Styles Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for inline italic, bold, strikethrough, and code. ```markdown *イタリック* **太字** ~~打ち消し線~~ インラインで`code`を挿入する ``` -------------------------------- ### Import zenn-markdown-html package Source: https://github.com/zenn-dev/zenn-editor/blob/canary/README.md Import the markdownHtml function from the zenn-markdown-html package. This function can only be executed in Node.js environments. ```tsx import markdownHtml from 'zenn-markdown-html'; ``` -------------------------------- ### Unordered Lists Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Create unordered lists using '-' or '*' for list items. Indentation creates nested lists. ```markdown - Hello! - Hola! - Bonjour! * Hi! ``` -------------------------------- ### Math Block with KaTeX Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Insert block-level mathematical equations using double dollar signs ($$). Ensure surrounding lines are empty for correct rendering. ```katex e^{i\theta} = \cos\theta + i\sin\theta ``` -------------------------------- ### Non-existent Image Path Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md Specifying a path to an image that does not exist will result in a broken image link. ```markdown ![](/images/example-images/not-exist.png) ``` -------------------------------- ### Math Block with TeX Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for a math block using TeX notation. ```markdown ```math ``` ``` -------------------------------- ### Image with Alt Text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Provide alternative text for images by placing it in square brackets before the image URL. ```markdown ![Altテキスト](https://画像のURL) ``` -------------------------------- ### Message Box Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Create styled message boxes using ':::message'. Use ':::message alert' for warning-style messages. ```markdown :::message メッセージをここに ::: ``` ```markdown :::message alert 警告メッセージをここに ::: ``` -------------------------------- ### Ordered Lists Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Use numbers followed by a period to create ordered lists. Items will be automatically numbered. ```markdown 1. First 2. Second ``` -------------------------------- ### Display Math in Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates display math within a markdown code block. ```markdown ``` ${e}_x$ $$e_ alpha$$ ``` ``` ```latex ${e}_x$ $$e_\\alpha$$ ``` -------------------------------- ### Inline Math with KaTeX Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed inline mathematical expressions using single dollar signs ($). ```katex a\ne0 ``` -------------------------------- ### Use Zenn's Embedded Elements with markdownToHtml Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-markdown-html/README.md Specify the `embedOrigin` option with the URL of the hosted embed server if you are using embedded features. Zenn's embed server can be used for non-commercial purposes. ```javascript import markdownToHtml from 'zenn-markdown-html'; const html = markdownToHtml(markdown, { embedOrigin: 'https://embed.zenn.studio', }); ``` -------------------------------- ### Embedding a YouTube Video by URL Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Paste the YouTube video URL on its own line, ensuring it's surrounded by newlines, to embed the video. ```bash # YouTubeのURLだけの行(前後に改行が必要です) https://www.youtube.com/watch?v=WRVsOCh907o ``` -------------------------------- ### Heading Levels Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating different levels of headings. ```markdown # 見出し1 ## 見出し2 ### 見出し3 #### 見出し4 ``` -------------------------------- ### JavaScript code block with custom class Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A standard JavaScript code block with a custom class, demonstrating basic code block rendering. ```js test1; ``` -------------------------------- ### Inline Math Expression Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates a simple inline mathematical expression using single dollar signs. ```markdown `$a$` ``` ```latex $a$ ``` -------------------------------- ### Image with Width Specification Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for inserting an image and specifying its width. ```markdown ![altテキスト](https://画像のURL =250x) ``` -------------------------------- ### Insert Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to insert a code block. ```bash Ctrl + alt + C ``` -------------------------------- ### Inline Math with Spaces Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Shows inline math expressions with spaces. ```markdown `$x$ $` ``` ```latex $x$ $ ``` -------------------------------- ### Linked Image Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a linked image with a specified width. ```markdown [![altテキスト](https://画像のURL =250x)](https://zenn.dev) ``` -------------------------------- ### Dark Theme CSS Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html CSS for a dark theme, setting background and text colors. ```css body[data-theme^='dark'] { /* --c-dark-blue-1100 */ background: #0d223a; /* --c-text-body */ color: #ecf5ff; } .container { max-width: 700px; margin: 1.5rem auto; } ``` -------------------------------- ### Inline Matrix Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Shows how to embed a matrix within an inline math expression. ```markdown `$egin{pmatrix}x\y end{pmatrix}$` ``` ```latex $\\begin{pmatrix}x\\y\\end{pmatrix}$ ``` -------------------------------- ### Message Box Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a message box. ```markdown ! メッセージをここに ! ``` -------------------------------- ### Numbered List Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a nested numbered list. ```markdown 1. First 2. Second ``` -------------------------------- ### URL Specified Image Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md Images can be included using absolute URLs. ```markdown ![](http://placehold.jp/54/e3f2ff/000000/720x480.png?text=zenn-editor.png) ``` -------------------------------- ### Undo Action Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Shortcut to undo the last action. ```bash Ctrl + Z ``` -------------------------------- ### Display Matrix in Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode matrix using the \\begin{matrix} environment within a code block. ```markdown ``` $$\\begin{matrix} f & = & 2 + x + 3 \\ & = & 5 + x \\end{matrix}$$ ``` ``` ```latex $$\\begin{matrix} f & = & 2 + x + 3 \\ & = & 5 + x \\end{matrix}$$ ``` -------------------------------- ### Inline Summation Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline mathematical expression demonstrating summation notation. ```markdown `$ sum_{i=1}^n$` ``` ```latex $ \\sum_{i=1}^n$ ``` -------------------------------- ### XSS link with vbscript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Demonstrates a markdown link using the vbscript: protocol, which is also a target for XSS prevention. ```markdown [xss link](vbscript:alert(1)) ``` -------------------------------- ### Code Block with Filename Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Display a filename above the code block by specifying 'language:filename' after the opening backticks. ```javascript const great = () => { console.log("Awesome") } ``` -------------------------------- ### Embedding a GitHub File by URL Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Place a GitHub file URL or permalink on its own line to embed the file content. ```bash # GitHubのファイルURLまたはパーマリンクだけの行(前後に改行が必要です) https://github.com/octocat/Hello-World/blob/master/README ``` -------------------------------- ### Blockquote Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a blockquote. ```markdown > 引用文 > 引用文 ``` -------------------------------- ### Warning Box Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a warning message box. ```markdown ! 警告メッセージをここに ! ``` -------------------------------- ### Convert Markdown to Simple HTML Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-markdown-html/README.md Use `markdownToSimpleHtml` for converting Markdown to HTML with limited supported syntax, such as basic Markdown formatting and URL conversion. ```javascript import { markdownToSimpleHtml } from 'zenn-markdown-html'; const html = markdownToSimpleHtml(markdown); ``` -------------------------------- ### Display Math Expression (Simple) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A simple display mode mathematical expression. ```markdown `$$1+1=2$$` ``` ```latex $$1+1=2$$ ``` -------------------------------- ### Display Summation Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode mathematical expression demonstrating summation notation. ```markdown `$$ sum_{i=1}^n$$` ``` ```latex $$ \\sum_{i=1}^n$$ ``` -------------------------------- ### Image Insertion Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for inserting an image with alt text. ```markdown ![altテキスト](https://画像のURL) ``` -------------------------------- ### Embedding a JSFiddle with Options Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md For JSFiddle embeds with options, use the iframe embed URL format: '{URL}/embedded/{Tabs}/{Visual}/'. ```markdown @[jsfiddle](ページのURL /embedded/{Tabs}/{Visual}/) ``` -------------------------------- ### Markdown reference with javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A markdown reference-style link using the javascript: protocol, testing its sanitization. ```markdown [test]: javascript:alert(1) ``` -------------------------------- ### Bulleted List Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a nested bulleted list. ```markdown - Hello! - Hola! - Bonjour! * Hi! ``` -------------------------------- ### Rendering a Mermaid Flowchart with Chain Notation Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Mermaid.js allows grouping nodes using '&' for concise flowcharts. The number of '&' uses is limited to 10 per block. ```mermaid graph LR a --> b & c--> d ``` -------------------------------- ### Embedding a CodeSandbox Project Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed a CodeSandbox project by providing the 'src' URL from its iframe embed code. ```markdown @[codesandbox](embed用のURL) ``` -------------------------------- ### Embedding a blueprintUE Render Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed a blueprintUE render by providing the URL of the published page. ```markdown @[blueprintue](https://blueprintue.com/render/0ovgynk-/) ``` -------------------------------- ### Inline Math with Tilde and Bold Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline math expression featuring a tilde and bold characters. ```markdown `${ ildeold e}_ alpha$` ``` ```latex ${ \\tilde \\bold e }_\\alpha ``` -------------------------------- ### markdownToHtml Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-markdown-html/README.md Converts markdown to HTML with full Zenn syntax support. Supports customization of embedded elements and specifying an embed origin. ```APIDOC ## markdownToHtml ### Description Converts markdown to HTML with full Zenn syntax support. This function is used for Zenn articles, books, and comments. ### Method Signature `markdownToHtml(markdown: string, options?: { customEmbed?: object, embedOrigin?: string }): string` ### Parameters * **markdown** (string) - The markdown string to convert. * **options** (object, optional) - Configuration options. * **customEmbed** (object, optional) - An object to customize the behavior of embedded elements. Refer to Zenn's documentation for supported embeddable elements. * **embedOrigin** (string, optional) - The origin URL of the hosted embed server. Use this if you want to use the same embedded elements as zenn.dev. Only for non-commercial use. ### Request Example ```javascript import markdownToHtml from 'zenn-markdown-html'; const markdown = '# Hello Zenn\n\nThis is a **bold** text.'; const html = markdownToHtml(markdown); console.log(html); ``` ### Custom Embed Example ```javascript import markdownToHtml from 'zenn-markdown-html'; const markdown = '![tweet](https://twitter.com/user/status/12345)'; const html = markdownToHtml(markdown, { customEmbed: { tweet(url) { // Note: ``` -------------------------------- ### Incorrect Image Path Specification (Relative) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/books/chapter-by-filename/4.exmple-images.md Relative paths are not supported for images within the Zenn project. This will result in the image not being displayed. ```markdown ![](../../images/example-images/zenn-editor.png) ``` -------------------------------- ### XSS image with javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Tests if the image parser, sharing code with the link parser, correctly handles javascript: protocols. ```markdown ![xss link](<javascript:alert(1)>) ``` -------------------------------- ### Basic Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for a basic code block. ```markdown ``` ``` ``` -------------------------------- ### XSS link with uppercase VBSCRIPT protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Tests the sanitizer's case-insensitivity for the vbscript: protocol in markdown links. ```markdown [xss link](VBSCRIPT:alert(1)) ``` -------------------------------- ### Accordion (Toggle) Box Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Create collapsible content sections using ':::details Title'. Nested elements can be added using '::::details Title'. ```markdown :::details タイトル 表示したい内容 ::: ``` ```markdown ::::details タイトル :::message ネストされた要素 ::: :::: ``` -------------------------------- ### XSS link with script tag injection Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Demonstrates an attempt to inject a script tag directly into a markdown link, which should be neutralized. ```markdown [xss link]("><script>alert("xss")</script>) ``` -------------------------------- ### Incorrect Image Path (Relative Path) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/200-example-images.md Relative paths are not supported for images in the Zenn editor. ```markdown ![](../images/example-images/zenn-editor.png) ``` -------------------------------- ### XSS link with javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Shows a markdown link attempting to use the javascript: protocol, which should be disallowed by the sanitizer. ```markdown [xss link](javascript:alert(1)) ``` -------------------------------- ### Numbered List with Inline Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A numbered list where list items contain inline math expressions. ```markdown ``` 1. $1+2$ 2. $2+3$ 1. $3+4$ ``` ``` ```latex 1. $1+2$ 2. $2+3$ 1. $3+4$ ``` -------------------------------- ### XSS link with uppercase JAVASCRIPT protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Tests the sanitizer's case-insensitivity for the javascript: protocol in markdown links. ```markdown [xss link](JAVASCRIPT:alert(1)) ``` -------------------------------- ### Autolink with direct javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md An autolink directly using the javascript: protocol, which should be sanitized. ```html ``` -------------------------------- ### Display Math in Code Block (Multiline) Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A multiline display math expression within a code block. ```markdown ``` $$ 1+1=2 $$ ``` ```latex $$ 1+1=2 $$ ``` -------------------------------- ### Render HTML in React Source: https://github.com/zenn-dev/zenn-editor/blob/canary/README.md Render the converted HTML within a React component. The parent div must have the class 'znc' for Zenn's CSS to be applied. ```tsx
``` -------------------------------- ### Horizontal Rule Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-content-css/test.html Markdown syntax for creating a horizontal rule. ```markdown ----- ``` -------------------------------- ### Mixed Inline and Display Math in Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A code block containing a mix of inline and display math expressions. ```markdown ``` a$1+1=2$ $1+1=2$b c$x$d ``` ``` ```latex a$1+1=2$ $1+1=2$b c$x$d ``` -------------------------------- ### Code with Display Math and Number Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A code block containing text followed by a display math expression and a number. ```markdown ``` code ``` $$a+b$$ (1) ``` ```latex code $$ a+b $$ (1) ``` -------------------------------- ### Inline Greek Letter Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Shows how to embed a Greek letter like phi within an inline math expression. ```markdown `$\varphi$` ``` ```latex $\\varphi$ ``` -------------------------------- ### Embedding a SpeakerDeck Presentation Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed a SpeakerDeck presentation by providing the 'data-id' value from its embed code. ```markdown @[speakerdeck](スライドのID) ``` -------------------------------- ### Blockquote with Display Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A blockquote containing a display math expression. ```markdown > formula > > $$ a+b=c$$ (2) > > in blockquote. ``` ```latex > formula > > $$ a+b=c$$ (2) > > in blockquote. ``` -------------------------------- ### Long Inline Math Expression Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Demonstrates a very long inline mathematical expression that might cause overflow issues. ```latex $aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$ ``` -------------------------------- ### Autolink with encoded javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Shows an autolink containing an encoded javascript: protocol, testing entity decoding before parsing. ```html ``` -------------------------------- ### Code with Display Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A code block containing text followed by a display math expression. ```markdown ``` code ``` $$a+b$$ ``` ```latex code $$ a+b $$ ``` -------------------------------- ### Display Math Expression Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode mathematical expression using double dollar signs. ```markdown `$$e_ alpha$$` ``` ```latex $$e_\\alpha$$ ``` -------------------------------- ### Code block with script tag and text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A generic code block containing an HTML script tag and surrounding text. ```text hello ``` -------------------------------- ### Convert Markdown to HTML Source: https://github.com/zenn-dev/zenn-editor/blob/canary/README.md Convert a Markdown string to an HTML string using the imported markdownHtml function. Ensure the parent element has the class 'znc' for CSS to apply correctly. ```ts const html = markdownHtml(markdown); ``` -------------------------------- ### HTML Comment for Notes Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Use HTML comment syntax for private notes. These will not be displayed on the published page. ```html ``` -------------------------------- ### X (Twitter) Post Embed Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Embed an X (Twitter) post by placing its URL on a line by itself, ensuring it's surrounded by blank lines. ```bash # ポストのURLだけの行(前後に改行が必要です) https://twitter.com/jack/status/20 ``` -------------------------------- ### Embedding a Specific GitHub Gist File Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md To embed a particular file from a GitHub Gist, append '?file={filename}' to the Gist URL. ```markdown @[gist](https://gist.github.com/foo/bar?file=example.json) ``` -------------------------------- ### Linkifier with direct javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A direct javascript: protocol used with the linkifier, which should be sanitized. ```text javascript:alert(1) ``` -------------------------------- ### Inline Math with Asterisk Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline math expression containing an asterisk. ```markdown `$a^*b$ with $a^*$` ``` ```latex $a^*b$ with $a^*$ ``` -------------------------------- ### Inline Math with Leading/Trailing Text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline math expression surrounded by text. ```markdown `If you solve $1+2$ you get $3` ``` ```latex If you solve $1+2$ you get $3 ``` -------------------------------- ### Multiline Inline Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline math expression that spans multiple lines. ```markdown ``` $1+1= 2$ ``` ``` ```latex $1+1= 2$ ``` -------------------------------- ### Display Summation with Number Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode summation expression with an associated number. ```markdown `$$ sum_{i=1}^n$$ (2)` ``` ```latex $$ \\sum_{i=1}^n$$ (2) ``` -------------------------------- ### Display Vector in Code Block Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A display mode vector expression within a code block. ```markdown ``` $${old e}(\varphi) = \begin{pmatrix} \cos\varphi\\ \sin\varphi \end{pmatrix}$$ (3) ``` ``` ```latex $${\\bold e}(\\varphi) = \\begin{pmatrix} \\cos\\varphi\\ \\sin\\varphi \\end{pmatrix}$$ (3) ``` -------------------------------- ### Embedding a Tweet by URL Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Simply paste the tweet's URL on its own line to embed it. Previously, a specific syntax was required, but now direct URL pasting works. ```markdown https://x.com/jack/status/20 ``` -------------------------------- ### Linkifier with encoded javascript protocol Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Tests the linkifier's handling of an encoded javascript: protocol. ```text javascript:alert(1) ``` -------------------------------- ### Inline HTML with onerror attribute Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Demonstrates an XSS vulnerability using an inline image tag with an onerror attribute. This is typically blocked by sanitizers. ```html ``` -------------------------------- ### Raw HTML script tag Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A raw HTML script tag within a fenced code block, which should be rendered as code, not executed. ```html ``` -------------------------------- ### Long Display Math Expression Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md A long display mode mathematical expression designed to test horizontal scrolling. ```latex $$ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $$ ``` -------------------------------- ### Customize Embedded Elements with markdownToHtml Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-markdown-html/README.md Customize the behavior of embedded elements like tweets using the `customEmbed` option. Note that script tags for embedding may need to be handled separately. ```javascript import markdownToHtml from 'zenn-markdown-html'; const html = markdownToHtml(markdown, { customEmbed: { // @[tweet](...)に対応している埋め込み要素をカスタマイズする tweet(url) { // 注意: サニタイズによって hello; ``` -------------------------------- ### Handling URLs with Underscores in Tweets Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md If a tweet URL contains multiple underscores within path segments, auto-linking might break. Use the @[tweet](URL) syntax as a workaround. ```markdown https://twitter.com/__example__/status/12345678910 ``` -------------------------------- ### Inline Math within Text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md An inline math expression embedded within a phrase. ```markdown `so-what is $x$` ``` ```latex so-what is $x$ ``` -------------------------------- ### XSS link with encoded characters Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md Tests the sanitizer's ability to decode HTML entities before processing links, preventing bypasses. ```markdown [xss link](&#74;avascript:alert(1)) ``` -------------------------------- ### Horizontal Rule Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md Insert a horizontal rule (separator) using four or more hyphens. ```markdown ---- ``` -------------------------------- ### Inline Math Embedded in Text Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Shows an inline math expression embedded within a sentence. ```markdown `You get 3$ if you solve $1+2$` ``` ```latex You get 3$ if you solve $1+2$ ``` -------------------------------- ### JavaScript code block with colon and script tag Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A JavaScript code block with a colon in its identifier, followed by an HTML script tag. ```js : hello ``` -------------------------------- ### Escaped Dollar Sign in Text with Display Math Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/304-example-embed-katex.md Shows an escaped dollar sign within text preceding a display math expression. ```markdown ``` some text \$a+b=c$$ ``` ``` ```latex some text \$a+b=c$$ ``` -------------------------------- ### JavaScript code block with non-standard character Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/800-example-xss-check.md A JavaScript code block containing a non-standard character (form feed), testing parser robustness. ```js test2 ``` -------------------------------- ### Embedding a Tweet without Conversation History Source: https://github.com/zenn-dev/zenn-editor/blob/canary/packages/zenn-cli/articles/100-example-markdown-guide.md To embed a tweet and hide its reply thread, append '?conversation=none' to the tweet's URL. ```markdown https://twitter.com/jack/status/20?conversation=none ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.