Repository: hexojs/hexo-renderer-markdown-it Branch: master Commit: 0c5034e87fff Files: 27 Total size: 95.7 KB Directory structure: gitextract_pxi85g_4/ ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ └── tester.yml ├── .gitignore ├── .mocharc.yml ├── LICENSE ├── README.md ├── index.js ├── lib/ │ ├── anchors.js │ ├── images.js │ └── renderer.js ├── package.json └── test/ ├── .eslintrc ├── fixtures/ │ ├── markdownit.md │ └── outputs/ │ ├── anchors.html │ ├── commonmark-deprecated.html │ ├── commonmark.html │ ├── custom.html │ ├── default-disable_rules.html │ ├── default.html │ ├── plugins.html │ ├── zero-enable_rules.html │ └── zero.html ├── index.js └── scripts/ └── enable_unsafe_link.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintignore ================================================ node_modules/ coverage/ tmp/ ================================================ FILE: .eslintrc ================================================ { "extends": "hexo", "root": true } ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto *.cs text diff=csharp *.java text diff=java *.html text diff=html *.css text *.js text # absolute paths are ok, as are globs test/**/* text eol=lf ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: npm directory: "/" schedule: interval: monthly ignore: - dependency-name: "*" update-types: ["version-update:semver-patch"] open-pull-requests-limit: 3 ================================================ FILE: .github/workflows/tester.yml ================================================ name: Tester on: [push, pull_request] jobs: tester: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] node-version: ['14.x', '16.x', '18.x'] fail-fast: false steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Cache NPM dependencies uses: actions/cache@v1 with: path: node_modules key: ${{ runner.os }}-npm-cache restore-keys: ${{ runner.os }}-npm-cache - name: Install Dependencies run: npm install - name: Test run: npm run test env: CI: true coverage: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] node-version: ['14.x'] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Cache NPM dependencies uses: actions/cache@v1 with: path: node_modules key: ${{ runner.os }}-npm-cache restore-keys: ${{ runner.os }}-npm-cache - name: Install Dependencies run: npm install - name: Coverage run: npm run test-cov env: CI: true - name: Coveralls uses: coverallsapp/github-action@master with: github-token: ${{ secrets.github_token }} ================================================ FILE: .gitignore ================================================ .DS_Store node_modules/ tmp/ *.log .idea/ coverage/ package-lock.json ================================================ FILE: .mocharc.yml ================================================ color: true ================================================ FILE: LICENSE ================================================ Copyright (c) 2015 Celso Miranda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # hexo-renderer-markdown-it [![Build Status](https://github.com/hexojs/hexo-renderer-markdown-it/workflows/Tester/badge.svg)](https://github.com/hexojs/hexo-renderer-markdown-it/actions?query=workflow%3ATester) [![npm version](https://badge.fury.io/js/hexo-renderer-markdown-it.svg)](https://www.npmjs.com/package/hexo-renderer-markdown-it) [![Coverage Status](https://coveralls.io/repos/github/hexojs/hexo-renderer-markdown-it/badge.svg?branch=master)](https://coveralls.io/github/hexojs/hexo-renderer-markdown-it?branch=master) This renderer plugin uses [Markdown-it] as a render engine on [Hexo]. Adds support for [Markdown] and [CommonMark]. ## Main Features - Support for [Markdown], [GFM] and [CommonMark] - Extensive configuration - Faster than the default renderer | `hexo-renderer-marked` - Safe ID for headings - Anchors for headings with ID - Footnotes - `` H2O - `` x2 - `` Inserted ## Installation **Warning:** make sure you're inside the main hexo directory before starting this guide. A default Hexo installation will include a markdown renderer plugin which uses `marked`, so you will have to remove it if you want to use `hexo-renderer-markdown-it`. ``` sh $ npm un hexo-renderer-marked --save ``` If you have already removed the default renderer, and others you might of added, you can now safely install `hexo-renderer-markdown-it` ``` sh $ npm i hexo-renderer-markdown-it --save ``` ## Options ``` yml markdown: preset: 'default' render: html: true xhtmlOut: false langPrefix: 'language-' breaks: true linkify: true typographer: true quotes: '“”‘’' enable_rules: disable_rules: plugins: anchors: level: 2 collisionSuffix: '' permalink: false permalinkClass: 'header-anchor' permalinkSide: 'left' permalinkSymbol: '¶' case: 0 separator: '-' images: lazyload: false prepend_root: false post_asset: false inline: false # https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline ``` See below for more details. ## Advanced Configuration ### [Preset](https://markdown-it.github.io/markdown-it/#MarkdownIt.new) options ``` yml markdown: preset: 'default' ``` - **"commonmark"** - configures parser to strict [CommonMark](https://commonmark.org/) mode. - **"default"** - similar to [GFM](https://github.github.com/gfm/), used when no preset name given. Enables all available rules, but still without html, typographer & autolinker. - **"zero"** - all rules disabled. Useful to quickly setup your config via `.enable()`. For example, when you need only `bold` and `italic` markup and nothing else. Note that the [default](https://github.com/hexojs/hexo-renderer-markdown-it#options) render and anchor options override some options in the preset. If you prefer to have the preset only: ``` yml markdown: preset: 'default' render: anchors: ``` ### Render options #### html The `html` setting defines whether or not HTML content inside the document should be escaped or passed to the final result. ``` yaml html: true # Doesn't escape HTML content ## OR html: false # Escapes HTML content so the tags will appear as text. ``` #### xhtmlOut The `xhtmlOut` setting defines whether the parser will export fully XHTML compatible tags. This only needs to be `true` for complete [CommonMark] support. ``` yaml xhtmlOut: true # Parser produces fully XHTML compliant code. # Ex: A line breaks will be
## OR xhtmlOut: false # Parser will not produce XHTML compliant code. # Ex: A line break will be
``` #### breaks Makes line breaks in the source file will be parsed into `
` tags. So every time you press the `Enter` key you will create a line break, which is not the default Markdown, CommonMark, or GFM behaviour. ``` yaml breaks: true # Parser produces `
` tags every time there is a line break in the source document. ## OR breaks: false # Parser will ignore line breaks in the source document. #Default double line break creates paragraph is still supported ``` #### langPrefix Add a prefix to the class name of code blocks (when a language is specified). ``` yaml langPrefix: 'language-' # default ``` _This option only applies when both Hexo's built-in highlighters are [**disabled**](https://hexo.io/docs/syntax-highlight#Disabled)._ **Example:** ``` yml langPrefix: 'lang-' ``` Source: ```` ``` js example ``` ```` HTML: ```html
example
``` #### linkify The parser has the ability to inline links pasted directly into the text. If you write a piece of text that looks like a link it will be rendered as `http://example.com`. ``` yaml linkify: true # Returns text links as proper links inlined with the paragraph. ## OR linkify: false # Returns text links as text. ``` #### typographer This is enables the substitution for common typography elements like ©, curly quotes, dashes, etc. ``` yaml typographer: true # Substitution of common typographical elements will take place. ## OR typographer: false # No substitution, so dumb quotes will remain dumb quotes, etc. ``` #### quotes Defines the double and single quotes used for substituting dumb quotes if typographer is set to `true`. ``` yaml quotes: '“”‘’' # "double" will be turned into “single” # 'single' will be turned into ‘single’ ## OR quotes: '«»“”' # "double" will be turned into «single» # 'single' will be turned into “single” ``` #### Example configuration ``` yaml markdown: render: html: true xhtmlOut: false breaks: false linkify: true typographer: true quotes: '“”‘’' ``` ### Manage rules Certain rules are enabled or disabled depending on the [preset](#preset-options). For example, "zero" preset disables all rules, to enable specific rules: ``` yml markdown: preset: 'zero' # Single rule enable_rules: 'link' # Multiple rules enable_rules: - 'link' - 'image' ``` "default" preset enables all rules, to disable specific rules: ``` yml markdown: preset: 'default' # Single rule disable_rules: 'link' # Multiple rules disable_rules: - 'link' - 'image' ``` #### Available rules Since the rules are subject to change, it's better to check the Markdown-it's source code for up-to-date rules. Look for the `_rules` variable in the following files: - [parser_block.js](https://github.com/markdown-it/markdown-it/blob/master/lib/parser_block.js) - [parser_core.js](https://github.com/markdown-it/markdown-it/blob/master/lib/parser_core.js) - [parser_inline.js](https://github.com/markdown-it/markdown-it/blob/master/lib/parser_inline.js) ### Automatic Headline ID's Enables you to automatically create ID's for the headings so you can link back to them. A valid html document cannot have two elements with duplicate id value, for example if `title` id is already used, subsequent `title` values will be updated to `title-2`, `title-3` and so on. Default options: ``` yaml markdown: anchors: # Minimum level for ID creation. (Ex. h2 to h6) level: 2 # A suffix that is prepended to the number given if the ID is repeated. collisionSuffix: '' # If `true`, creates an anchor tag with a permalink besides the heading. permalink: false # Class used for the permalink anchor tag. permalinkClass: header-anchor # Set to 'right' to add permalink after heading permalinkSide: 'left' # The symbol used to make the permalink permalinkSymbol: ¶ # Transform anchor to (1) lower case; (2) upper case case: 0 # Replace space with a character separator: '-' ``` ### Plugins Included plugins: - markdown-it-abbr - markdown-it-attrs - markdown-it-cjk-breaks - markdown-it-container - markdown-it-deflist - markdown-it-emoji - markdown-it-footnote - markdown-it-ins - markdown-it-mark - markdown-it-sub - markdown-it-sup Plugins are not enabled by default, to enable: ``` yaml markdown: plugins: - markdown-it-abbr # installed external plugins also can be enabled - markdown-it-table-of-contents ``` #### Plugin option ``` yaml markdown: plugins: - name: 'markdown-it-emoji' options: shortcuts: laughing: ':D' - name: 'other-plugin' options: ... ``` ## Extensibility This plugin overrides some default behaviors of how markdown-it plugin renders the markdown into html, to integrate with the Hexo ecosystem. It is possible to override this plugin too, without resorting to forking the whole thing. For example, to enable [unsafe links](https://markdown-it.github.io/markdown-it/#MarkdownIt.prototype.validateLink) (which is disabled by default): ``` js hexo.extend.filter.register('markdown-it:renderer', function(md) { const { config } = this; // Optional, parse user config from _config.yml md.validateLink = function() { return true; }; }); // Specify custom function in plugin option const { slugize } = require('hexo-util'); const opts = hexo.config.markdown.anchors; const mdSlugize = (str) => { return slugize(str, { transform: opts.case, ...opts }); }; hexo.extend.filter.register('markdown-it:renderer', function(md) { md.use(require('markdown-it-table-of-contents'), { includeLevel: [2,3,4], slugify: mdSlugize }); }); ``` Save the file in "scripts/" folder and run Hexo as usual. Refer to markdown-it [API documentation](https://markdown-it.github.io/markdown-it/#MarkdownIt). ## Frequently Asked Questions ### Missing Styles of GFM Task Lists In general, adding the following styles to the theme can solve the problem. ```css li.task-list-item { list-style-type: none; } li.task-list-item .task-list-item-checkbox { margin: 0 0.2em 0.25em -1.6em; } ``` ### How can I add math support? First, install KaTeX plugin for markdown-it. ```bash npm install katex @renbaoshuo/markdown-it-katex ``` Then add [`@renbaoshuo/markdown-it-katex`](https://github.com/renbaoshuo/markdown-it-katex) to plugins list. ```yaml plugins: - '@renbaoshuo/markdown-it-katex' # Other plugins... ``` If you need to allow spaces before and after delimiters (e.g. `$ 1 + 1 = 2 $`), set the `skipDelimitersCheck` option to `true`: ```yaml plugins: - name: '@renbaoshuo/markdown-it-katex' options: skipDelimitersCheck: true ``` Don't forget to include the KaTeX stylesheet in your html: ```html ``` ### How can I merge table cells with the same content? Install the [`markdown-it-merge-cells`](https://github.com/Menci/markdown-it-merge-cells) plugin. ```bash npm install markdown-it-merge-cells ``` Then add the plugin to plugins list. ```yaml plugins: - markdown-it-merge-cells # Other plugins... ``` ## Requests and bug reports If you have any feature requests or bugs to report, you're welcome to [file an issue](https://github.com/hexojs/hexo-renderer-markdown-it/issues). [CommonMark]: http://commonmark.org/ [Markdown]: http://daringfireball.net/projects/markdown/ [GFM]: https://help.github.com/articles/github-flavored-markdown/ [Markdown-it]: https://github.com/markdown-it/markdown-it [Hexo]: http://hexo.io/ ================================================ FILE: index.js ================================================ /* global hexo */ 'use strict'; hexo.config.markdown = Object.assign({ preset: 'default', render: {}, anchors: {} }, hexo.config.markdown); hexo.config.markdown.render = Object.assign({ html: true, xhtmlOut: false, breaks: true, linkify: true, typographer: true, quotes: '“”‘’' }, hexo.config.markdown.render); hexo.config.markdown.anchors = Object.assign({ level: 2, collisionSuffix: '', permalink: false, permalinkClass: 'header-anchor', permalinkSide: 'left', permalinkSymbol: '¶', case: 0, separator: '-' }, hexo.config.markdown.anchors); const Renderer = require('./lib/renderer'); const renderer = new Renderer(hexo); renderer.disableNunjucks = Boolean(hexo.config.markdown.disableNunjucks); function render(data, options) { return renderer.render(data, options); } hexo.extend.renderer.register('md', 'html', render, true); hexo.extend.renderer.register('markdown', 'html', render, true); hexo.extend.renderer.register('mkd', 'html', render, true); hexo.extend.renderer.register('mkdn', 'html', render, true); hexo.extend.renderer.register('mdwn', 'html', render, true); hexo.extend.renderer.register('mdtxt', 'html', render, true); hexo.extend.renderer.register('mdtext', 'html', render, true); ================================================ FILE: lib/anchors.js ================================================ 'use strict'; const Token = require('markdown-it/lib/token'); const { slugize } = require('hexo-util'); const renderPermalink = function(slug, opts, tokens, idx) { const permalink = [Object.assign(new Token('link_open', 'a', 1), { attrs: [['class', opts.permalinkClass], ['href', '#' + slug]] }), Object.assign(new Token('text', '', 0), { content: opts.permalinkSymbol }), new Token('link_close', 'a', -1), Object.assign(new Token('text', '', 0), { content: '' })]; if (opts.permalinkSide === 'right') { return tokens[idx + 1].children.push(...permalink); } return tokens[idx + 1].children.unshift(...permalink); }; const anchor = function(md, opts) { Object.assign(opts, { renderPermalink }); let titleStore = {}; const originalHeadingOpen = md.renderer.rules.heading_open; const slugOpts = { transform: opts.case, ...opts }; md.renderer.rules.heading_open = function(...args) { const [tokens, idx, something, somethingelse, self] = args; // eslint-disable-line no-unused-vars if (tokens[idx].tag.substr(1) >= opts.level) { let _tokens$idx; const title = tokens[idx + 1].children.reduce((acc, t) => { return acc + t.content; }, ''); let slug = slugize(title, slugOpts); if (Object.prototype.hasOwnProperty.call(titleStore, slug)) { titleStore[slug] = titleStore[slug] + 1; slug = slug + '-' + opts.collisionSuffix + titleStore[slug].toString(); } else { titleStore[slug] = 1; } (_tokens$idx = tokens[idx], !_tokens$idx.attrs && (_tokens$idx.attrs = []), _tokens$idx.attrs) .push(['id', slug]); if (opts.permalink) { opts.renderPermalink.apply(opts, [slug, opts].concat(args)); } } return originalHeadingOpen ? originalHeadingOpen.apply(this, args) : self.renderToken.apply(self, args); }; md.core.ruler.push('clear_anchor_title_store', () => { titleStore = {}; }); }; module.exports = anchor; ================================================ FILE: lib/images.js ================================================ 'use strict'; const { join, relative: relativePosix } = require('path').posix; const { relative, basename, extname, dirname, isAbsolute } = require('path'); const { url_for } = require('hexo-util'); function images(md, opts) { const { hexo, images } = opts; const { lazyload, prepend_root: prependRoot, post_asset: postAsset } = images; const { relative_link, model, base_dir, source_dir } = hexo; md.renderer.rules.image = function(tokens, idx, options, env, self) { const token = tokens[idx]; const { postPath } = env; token.attrSet('alt', token.content); if (lazyload) { token.attrSet('loading', 'lazy'); } if (!prependRoot && !postAsset) { return self.renderToken(tokens, idx, options); } const srcIdx = token.attrs.findIndex(attr => attr[0] === 'src'); let src = token.attrs[srcIdx][1]; if (!/^(#|\/\/|http(s)?:)/.test(src) && !relative_link) { if (!(src.startsWith('/') || src.startsWith('\\')) && postAsset) { const PostAsset = model.call(hexo, 'PostAsset'); let assetDirBasePath = join(basename(source_dir), dirname(relativePosix(source_dir, postPath)), basename(postPath, extname(postPath))); if (isAbsolute(assetDirBasePath)) assetDirBasePath = relative(base_dir, assetDirBasePath); assetDirBasePath = assetDirBasePath.replace(/\\/g, '/'); const asset = [ join(assetDirBasePath, src), join(assetDirBasePath, src.replace(new RegExp('^' + basename(postPath, extname(postPath)) + '/'), '')) ] .map(id => PostAsset.findById(id)) .filter(Boolean); if (asset.length) { src = asset[0].path.replace(/\\/g, '/'); } } token.attrSet('src', url_for.call(hexo, src)); } return self.renderToken(tokens, idx, options); }; } module.exports = images; ================================================ FILE: lib/renderer.js ================================================ 'use strict'; const MarkdownIt = require('markdown-it'); const path = require('path'); class Renderer { /** * constructor * * @param {*} hexo context of hexo */ constructor(hexo) { this.hexo = hexo; let { markdown } = hexo.config; // Temporary backward compatibility if (typeof markdown === 'string') { markdown = { preset: markdown, }; hexo.log.warn( `Deprecated config detected. Please use\n\nmarkdown:\n preset: ${markdown.preset}\n\nSee https://github.com/hexojs/hexo-renderer-markdown-it#options` ); } const { preset, render, enable_rules, disable_rules, plugins, anchors, images } = markdown; this.parser = new MarkdownIt(preset, render); if (enable_rules) { this.parser.enable(enable_rules); } if (disable_rules) { this.parser.disable(disable_rules); } if (plugins) { this.parser = plugins.reduce((parser, pugs) => { if (pugs instanceof Object && pugs.name) { const resolved = require.resolve(pugs.name, { paths: [ // find from root hexo base directory node_modules path.join(hexo.base_dir, 'node_modules'), // find from current installed library node_modules path.join(__dirname, '../node_modules'), // find from root hexo base directory hexo.base_dir, // find from current library directory path.join(__dirname, '../'), ], }); return parser.use(require(resolved), pugs.options); } return parser.use(require(pugs)); }, this.parser); } if (anchors) { this.parser.use(require('./anchors'), anchors); } if (images) { this.parser.use(require('./images'), { images, hexo: this.hexo, }); } } render(data, options) { this.hexo.execFilterSync('markdown-it:renderer', this.parser, { context: this }); if (options != null && options.inline === true) { return this.parser.renderInline(data.text, { postPath: data.path }); } return this.parser.render(data.text, { postPath: data.path, }); } } module.exports = Renderer; ================================================ FILE: package.json ================================================ { "name": "hexo-renderer-markdown-it", "version": "7.1.1", "description": "Markdown-it is a Markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.", "main": "index.js", "scripts": { "eslint": "eslint .", "test": "mocha test/index.js", "test-cov": "c8 --reporter=lcovonly npm run test" }, "repository": "hexojs/hexo-renderer-markdown-it", "keywords": [ "hexo", "renderer", "markdown", "markdown-it", "hexo-renderer" ], "directories": { "lib": "./lib" }, "files": [ "index.js", "lib/" ], "author": "Celso Miranda (http://celsomiranda.net/)", "maintainers": [ "Hexo Core Team (https://github.com/orgs/hexojs/teams/core)" ], "license": "MIT", "bugs": "https://github.com/hexojs/hexo-renderer-markdown-it/issues", "homepage": "https://github.com/hexojs/hexo-renderer-markdown-it", "dependencies": { "hexo-util": "^3.0.1", "markdown-it": "^13.0.1", "markdown-it-abbr": "^1.0.4", "markdown-it-attrs": "^4.1.3", "markdown-it-cjk-breaks": "^1.1.2", "markdown-it-container": "^3.0.0", "markdown-it-deflist": "^2.0.3", "markdown-it-emoji": "^2.0.0", "markdown-it-footnote": "^3.0.1", "markdown-it-ins": "^3.0.0", "markdown-it-mark": "^3.0.0", "markdown-it-sub": "^1.0.0", "markdown-it-sup": "^1.0.0" }, "devDependencies": { "chai": "^4.3.7", "eslint": "^8.41.0", "eslint-config-hexo": "^5.0.0", "hexo": "^7.0.0", "mocha": "^10.2.0", "c8": "^8.0.1" }, "engines": { "node": ">=14" } } ================================================ FILE: test/.eslintrc ================================================ { "extends": "hexo/test" } ================================================ FILE: test/fixtures/markdownit.md ================================================ # h1 Heading em português ## h2 Heading :P ### h3 Heading #### h4 Heading ##### h5 Heading ###### h6 Heading ## Horizontal Rule ___ ## Horizontal Rule --- ## Horizontal Rule *** ## Typographic replacements Enable typographer option to see result. (c) (C) (r) (R) (tm) (TM) +- test.. test... test..... test?..... test!.... !!!!!! ???? ,, -- --- "Smartypants, double quotes" and 'single quotes' ## Emphasis **This is bold text** __This is bold text__ *This is italic text* _This is italic text_ ~~Strikethrough~~ ## Blockquotes > Blockquotes can also be nested... >> ...by using additional greater-than signs right next to each other... > > > ...or with spaces between arrows. ## Lists Unordered + Create a list by starting a line with `+`, `-`, or `*` + Sub-lists are made by indenting 2 spaces: - Marker character change forces new list start: * Ac tristique libero volutpat at + Facilisis in pretium nisl aliquet - Nulla volutpat aliquam velit + Very easy! Ordered 1. Lorem ipsum dolor sit amet 2. Consectetur adipiscing elit 3. Integer molestie lorem at massa ## Code Inline `code` Indented code // Some comments line 1 of code line 2 of code line 3 of code Block code "fences" ``` Sample text here... ``` Syntax highlighting ``` js var foo = function (bar) { return bar++; }; console.log(foo(5)); ``` ## Tables | Option | Description | | ------ | ----------- | | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. | Right aligned columns | Option | Description | | ------:| -----------:| | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. | ## Links [link text](http://dev.nodeca.com) Autoconverted link https://github.com/nodeca/pica (enable linkify to see) ## Images ![Minion](https://octodex.github.com/images/minion.png) ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat") ![Alt text][id] [id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat" ## Plugins The killer feature of `markdown-it` is very effective support of [syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin). ### [Emojies](https://github.com/markdown-it/markdown-it-emoji) > Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum: > > Shortcuts (emoticons): :-) :-( 8-) ;) see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji. ### [Subscipt](https://github.com/markdown-it/markdown-it-sub) / [Superscirpt](https://github.com/markdown-it/markdown-it-sup) - 19^th^ - H~2~O ### [\](https://github.com/markdown-it/markdown-it-ins) ++Inserted text++ ### [\](https://github.com/markdown-it/markdown-it-mark) ==Marked text== ### [Footnotes](https://github.com/markdown-it/markdown-it-footnote) Footnote 1 link[^first]. Footnote 2 link[^second]. Inline footnote^[Text of inline footnote] definition. Duplicated footnote reference[^second]. [^first]: Footnote **can have markup** and multiple paragraphs. [^second]: Footnote text. ### [Definition lists](https://github.com/markdown-it/markdown-it-deflist) Term 1 : Definition 1 with lazy continuation. Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2. _Compact style:_ Term 1 ~ Definition 1 Term 2 ~ Definition 2a ~ Definition 2b ### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr) This is HTML abbreviation example. It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on. *[HTML]: Hyper Text Markup Language ### [Custom containers](https://github.com/markdown-it/markdown-it-container) ::: warning *here be dragons* ::: ### [Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true } This is an attribute example. ================================================ FILE: test/fixtures/outputs/anchors.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

© © ® ® ™ ™ ±

test… test… test… test?.. test!..

!!! ??? , – —

“Smartypants, double quotes” and ‘single quotes’

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code “fences”

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19^th^
  • H~2~O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1
with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning
here be dragons
:::

Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/commonmark-deprecated.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

~~Strikethrough~~

Blockquotes

Blockquotes can also be nested...

...by using additional greater-than signs right next to each other...

...or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code "fences"

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

| Option | Description | | ------ | ----------- | | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

Right aligned columns

| Option | Description | | ------:| -----------:| | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

Links

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19^th^
  • H~2~O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1 with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1 ~ Definition 1

Term 2 ~ Definition 2a ~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning here be dragons :::

Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/commonmark.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

~~Strikethrough~~

Blockquotes

Blockquotes can also be nested...

...by using additional greater-than signs right next to each other...

...or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code "fences"

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

| Option | Description |
| ------ | ----------- |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |

Right aligned columns

| Option | Description |
| ------:| -----------:|
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19^th^
  • H~2~O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1
with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning
here be dragons
:::

Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/custom.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

© © ® ® ™ ™ ±

test… test… test… test?.. test!..

!!! ??? , – —

«Smartypants, double quotes» and “single quotes”

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code «fences»

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19^th^
  • H~2~O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1
with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts «HTML», but keep intact partial entries like «xxxHTMLyyy» and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning
here be dragons
:::

Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/default-disable_rules.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

© © ® ® ™ ™ ±

test… test… test… test?.. test!..

!!! ??? , – —

“Smartypants, double quotes” and ‘single quotes’

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code “fences”

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

[link text](http://dev.nodeca.com)

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
[syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin).

[Emojies](https://github.com/markdown-it/markdown-it-emoji)

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji.

[Subscipt](https://github.com/markdown-it/markdown-it-sub) / [Superscirpt](https://github.com/markdown-it/markdown-it-sup)

  • 19^th^
  • H~2~O

[<ins>](https://github.com/markdown-it/markdown-it-ins)

++Inserted text++

[<mark>](https://github.com/markdown-it/markdown-it-mark)

==Marked text==

[Footnotes](https://github.com/markdown-it/markdown-it-footnote)

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

[Definition lists](https://github.com/markdown-it/markdown-it-deflist)

Term 1

: Definition 1
with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b

[Abbreviations](https://github.com/markdown-it/markdown-it-abbr)

This is HTML abbreviation example.

It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.

*[HTML]: Hyper Text Markup Language

[Custom containers](https://github.com/markdown-it/markdown-it-container)

::: warning
here be dragons
:::

[Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/default.html ================================================

h1 Heading em português

h2 Heading :P

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

© © ® ® ™ ™ ±

test… test… test… test?.. test!..

!!! ??? , – —

“Smartypants, double quotes” and ‘single quotes’

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code “fences”

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19^th^
  • H~2~O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1
with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
~ Definition 1

Term 2
~ Definition 2a
~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning
here be dragons
:::

Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/plugins.html ================================================

h1 Heading em português

h2 Heading 😛

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rule


Horizontal Rule


Horizontal Rule


Typographic replacements

Enable typographer option to see result.

© © ® ® ™ ™ ±

test… test… test… test?.. test!..

!!! ??? , – —

“Smartypants, double quotes” and ‘single quotes’

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code “fences”

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion
Stormtroopocat

Alt text

Plugins

The killer feature of markdown-it is very effective support of
syntax plugins.

Emojies

Classic markup: 😉 :crush: 😢 :tear: 😆 😋

Shortcuts (emoticons): 😃 😦 😎 😉

see how to change output with twemoji.

Subscipt / Superscirpt

  • 19th
  • H2O

<ins>

Inserted text

<mark>

Marked text

Footnotes

Footnote 1 link[1].

Footnote 2 link[2].

Inline footnote[3] definition.

Duplicated footnote reference[2:1].

Definition lists

Term 1

Definition 1
with lazy continuation.

Term 2 with inline markup

Definition 2

  { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1
Definition 1
Term 2
Definition 2a
Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.

Custom containers

::: warning
here be dragons
:::

Attributes

This is an attribute example.


  1. Footnote can have markup

    and multiple paragraphs. ↩︎

  2. Footnote text. ↩︎ ↩︎

  3. Text of inline footnote ↩︎

================================================ FILE: test/fixtures/outputs/zero-enable_rules.html ================================================

# h1 Heading em português ## h2 Heading :P ### h3 Heading #### h4 Heading ##### h5 Heading ###### h6 Heading

## Horizontal Rule

___

## Horizontal Rule

---

## Horizontal Rule

***

## Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'

## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~

## Blockquotes

> Blockquotes can also be nested... >> ...by using additional greater-than signs right next to each other... > > > ...or with spaces between arrows.

## Lists

Unordered

+ Create a list by starting a line with `+`, `-`, or `*` + Sub-lists are made by indenting 2 spaces: - Marker character change forces new list start: * Ac tristique libero volutpat at + Facilisis in pretium nisl aliquet - Nulla volutpat aliquam velit + Very easy!

Ordered

1. Lorem ipsum dolor sit amet 2. Consectetur adipiscing elit 3. Integer molestie lorem at massa

## Code

Inline `code`

Indented code

// Some comments line 1 of code line 2 of code line 3 of code

Block code "fences"

``` Sample text here... ```

Syntax highlighting

``` js var foo = function (bar) { return bar++; };

console.log(foo(5)); ```

## Tables

| Option | Description | | ------ | ----------- | | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

Right aligned columns

| Option | Description | | ------:| -----------:| | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

## Links

link text

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

## Images

Minion Stormtroopocat

![Alt text][id]

[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat"

## Plugins

The killer feature of `markdown-it` is very effective support of syntax plugins.

### Emojies

> Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum: > > Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

### Subscipt / Superscirpt

- 19^th^ - H~2~O

### \<ins>

++Inserted text++

### \<mark>

==Marked text==

### Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote **can have markup**

and multiple paragraphs.

[^second]: Footnote text.

### Definition lists

Term 1

: Definition 1 with lazy continuation.

Term 2 with *inline markup*

: Definition 2

{ some code, part of Definition 2 }

Third paragraph of definition 2.

_Compact style:_

Term 1 ~ Definition 1

Term 2 ~ Definition 2a ~ Definition 2b

### Abbreviations

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

### Custom containers

::: warning *here be dragons* :::

### Attributes { data-attr=true }

This is an attribute example.

================================================ FILE: test/fixtures/outputs/zero.html ================================================

# h1 Heading em português ## h2 Heading :P ### h3 Heading #### h4 Heading ##### h5 Heading ###### h6 Heading

## Horizontal Rule

___

## Horizontal Rule

---

## Horizontal Rule

***

## Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'

## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~

## Blockquotes

> Blockquotes can also be nested... >> ...by using additional greater-than signs right next to each other... > > > ...or with spaces between arrows.

## Lists

Unordered

+ Create a list by starting a line with `+`, `-`, or `*` + Sub-lists are made by indenting 2 spaces: - Marker character change forces new list start: * Ac tristique libero volutpat at + Facilisis in pretium nisl aliquet - Nulla volutpat aliquam velit + Very easy!

Ordered

1. Lorem ipsum dolor sit amet 2. Consectetur adipiscing elit 3. Integer molestie lorem at massa

## Code

Inline `code`

Indented code

// Some comments line 1 of code line 2 of code line 3 of code

Block code "fences"

``` Sample text here... ```

Syntax highlighting

``` js var foo = function (bar) { return bar++; };

console.log(foo(5)); ```

## Tables

| Option | Description | | ------ | ----------- | | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

Right aligned columns

| Option | Description | | ------:| -----------:| | data | path to data files to supply the data that will be passed into templates. | | engine | engine to be used for processing templates. Handlebars is the default. | | ext | extension to be used for dest files. |

## Links

[link text](http://dev.nodeca.com)

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

## Images

![Minion](https://octodex.github.com/images/minion.png) ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")

![Alt text][id]

[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat"

## Plugins

The killer feature of `markdown-it` is very effective support of [syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin).

### [Emojies](https://github.com/markdown-it/markdown-it-emoji)

> Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum: > > Shortcuts (emoticons): :-) :-( 8-) ;)

see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji.

### [Subscipt](https://github.com/markdown-it/markdown-it-sub) / [Superscirpt](https://github.com/markdown-it/markdown-it-sup)

- 19^th^ - H~2~O

### [\<ins>](https://github.com/markdown-it/markdown-it-ins)

++Inserted text++

### [\<mark>](https://github.com/markdown-it/markdown-it-mark)

==Marked text==

### [Footnotes](https://github.com/markdown-it/markdown-it-footnote)

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote **can have markup**

and multiple paragraphs.

[^second]: Footnote text.

### [Definition lists](https://github.com/markdown-it/markdown-it-deflist)

Term 1

: Definition 1 with lazy continuation.

Term 2 with *inline markup*

: Definition 2

{ some code, part of Definition 2 }

Third paragraph of definition 2.

_Compact style:_

Term 1 ~ Definition 1

Term 2 ~ Definition 2a ~ Definition 2b

### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr)

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

### [Custom containers](https://github.com/markdown-it/markdown-it-container)

::: warning *here be dragons* :::

### [Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true }

This is an attribute example.

================================================ FILE: test/index.js ================================================ 'use strict'; require('chai').should(); const { readFileSync } = require('fs'); const { join } = require('path').posix; const { sep } = require('path'); const Renderer = require('../lib/renderer'); const source = readFileSync('./test/fixtures/markdownit.md', 'utf8'); const Hexo = require('hexo'); const { url_for } = require('hexo-util'); describe('Hexo Renderer Markdown-it', () => { const hexo = new Hexo(__dirname, { silent: true }); const defaultCfg = JSON.parse(JSON.stringify(Object.assign(hexo.config, { markdown: { preset: 'default', render: { html: true, xhtmlOut: false, breaks: true, linkify: true, typographer: true, quotes: '“”‘’' }, anchors: { level: 2, collisionSuffix: '', permalink: false, permalinkClass: 'header-anchor', permalinkSide: 'left', permalinkSymbol: '¶', case: 0, separator: '' } } }))); beforeEach(() => { hexo.config = JSON.parse(JSON.stringify(defaultCfg)); }); describe('preset', () => { it('default', () => { hexo.config.markdown.preset = 'default'; const parsed_gfm = readFileSync('./test/fixtures/outputs/default.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_gfm); }); it('commonmark', () => { hexo.config.markdown.preset = 'commonmark'; const parsed_commonmark = readFileSync('./test/fixtures/outputs/commonmark.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_commonmark); }); // Deprecated it('handle deprecated config', () => { hexo.config.markdown = 'commonmark'; const parsed_commonmark = readFileSync('./test/fixtures/outputs/commonmark-deprecated.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_commonmark); }); it('zero', () => { hexo.config.markdown.preset = 'zero'; const parsed_zero = readFileSync('./test/fixtures/outputs/zero.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_zero); }); }); describe('render options', () => { it('custom options', () => { hexo.config.markdown.render = { html: false, xhtmlOut: true, breaks: true, langPrefix: '', linkify: true, typographer: true, quotes: '«»“”' }; const parsed_custom = readFileSync('./test/fixtures/outputs/custom.html', 'utf8'); const source = readFileSync('./test/fixtures/markdownit.md', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_custom); }); it('langPrefix', () => { hexo.config.markdown.render = { langPrefix: 'lang-' }; const text = '```js\nexample\n```'; const renderer = new Renderer(hexo); const result = renderer.parser.render(text); result.should.eql('
example\n
\n'); }); it('render inline', () => { const text = 'inline text'; const renderer = new Renderer(hexo); const resultBlock = renderer.render({ text }); const resultInline = renderer.render({ text }, { inline: true }); resultBlock.should.eql('

inline text

\n'); resultInline.should.eql('inline text'); }); }); describe('plugins', () => { it('default', () => { hexo.config.markdown.plugins = [ 'markdown-it-abbr', 'markdown-it-attrs', 'markdown-it-container', 'markdown-it-deflist', 'markdown-it-emoji', 'markdown-it-footnote', 'markdown-it-ins', 'markdown-it-mark', 'markdown-it-sub', 'markdown-it-sup' ]; const parsed_plugins = readFileSync('./test/fixtures/outputs/plugins.html', 'utf8'); const source = readFileSync('./test/fixtures/markdownit.md', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_plugins); }); it('custom options', () => { hexo.config.markdown.plugins = [ { name: 'markdown-it-emoji', options: { defs: { smile: ':lorem:' } } } ]; const text = ':smile:'; const renderer = new Renderer(hexo); const result = renderer.parser.render(text); result.should.equal('

:lorem:

\n'); }); }); describe('anchors', () => { it('collisionSuffix & permalinkClass', () => { hexo.config.markdown.anchors = { level: 2, collisionSuffix: 'ver', permalink: true, permalinkClass: 'header-anchor', permalinkSymbol: '¶' }; const expected = readFileSync('./test/fixtures/outputs/anchors.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.eql(expected); }); it('permalink disabled', () => { hexo.config.markdown.anchors = { level: 1, collisionSuffix: '', permalink: false, permalinkClass: 'header-anchor', permalinkSymbol: '¶' }; const renderer = new Renderer(hexo); const result = renderer.parser.render('# This is an H1 title\n# This is an H1 title'); const expected = '

This is an H1 title

\n

This is an H1 title

\n'; result.should.eql(expected); }); it('slugize - case & separator', () => { hexo.config.markdown.anchors = { level: 2, case: 1, separator: '_' }; const renderer = new Renderer(hexo); const result = renderer.parser.render('## foo BAR'); result.should.equal('

foo BAR

\n'); }); it('multiple posts anchor id', () => { hexo.config.markdown.anchors = { level: 2, collisionSuffix: 'ver', permalink: true, permalinkClass: 'header-anchor', permalinkSymbol: '¶' }; const expected = readFileSync('./test/fixtures/outputs/anchors.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); const result2 = renderer.parser.render(source); result.should.eql(expected); result2.should.eql(expected); }); describe('permalinkSide', () => { const text = '## foo'; it('left', () => { hexo.config.markdown.anchors = { level: 2, permalink: true, permalinkClass: 'anchor', permalinkSide: 'left', permalinkSymbol: '#' }; const renderer = new Renderer(hexo); const result = renderer.parser.render(text); result.should.equal('

#foo

\n'); }); it('right', () => { hexo.config.markdown.anchors = { level: 2, permalink: true, permalinkClass: 'anchor', permalinkSide: 'right', permalinkSymbol: '#' }; const renderer = new Renderer(hexo); const result = renderer.parser.render(text); result.should.equal('

foo#

\n'); }); }); }); describe('rules', () => { it('enable_rules', () => { hexo.config.markdown.preset = 'zero'; hexo.config.markdown.enable_rules = ['link', 'image']; const parsed_zero = readFileSync('./test/fixtures/outputs/zero-enable_rules.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed_zero); }); it('disable_rules', () => { hexo.config.markdown.preset = 'default'; hexo.config.markdown.render.linkify = false; hexo.config.markdown.disable_rules = 'link'; const parsed = readFileSync('./test/fixtures/outputs/default-disable_rules.html', 'utf8'); const renderer = new Renderer(hexo); const result = renderer.parser.render(source); result.should.equal(parsed); }); }); describe('execFilter', () => { it('default', () => { const renderer = new Renderer(hexo); const result = renderer.render({ text: '[foo](javascript:bar)' }); result.should.equal('

[foo](javascript:bar)

\n'); }); it('enable unsafe link', () => { const filter = md => { md.validateLink = function() { return true; }; }; hexo.extend.filter.register('markdown-it:renderer', filter); const renderer = new Renderer(hexo); const result = renderer.render({ text: '[foo](javascript:bar)' }); hexo.extend.filter.unregister('markdown-it:renderer', filter); result.should.equal('

foo

\n'); }); it('should execute loaded scripts', async () => { const renderer = new Renderer(hexo); hexo.env.init = true; await hexo.init(); const result = renderer.render({ text: '[foo](javascript:bar)' }); result.should.equal('

foo

\n'); }); it('should be called in render', () => { const iterates = 3; const spy = { called: 0, call() { this.called++; } }; const filter = md => spy.call(md); hexo.extend.filter.register('markdown-it:renderer', filter); const renderer = new Renderer(hexo); for (let i = 0; i < iterates; i++) { renderer.render({ text: '' }); } hexo.extend.filter.unregister('markdown-it:renderer', filter); spy.called.should.equal(iterates); }); }); describe('nunjucks', () => { const hexo = new Hexo(__dirname, { silent: true }); const loremFn = () => { return 'ipsum'; }; const engine = 'md'; before(async () => { await hexo.init(); hexo.config.markdown = {}; const renderer = new Renderer(hexo); function render(data, options) { return renderer.parser.render(data.text); } hexo.extend.tag.register('lorem', loremFn); hexo.extend.renderer.register('md', 'html', render, true); }); it('default', async () => { const result = await hexo.post.render(null, { content: '**foo** {% lorem %}', engine }); result.content.should.eql('

foo ipsum

\n'); }); it('enable disableNunjucks', async () => { const renderer = hexo.render.renderer.get('md'); renderer.disableNunjucks = true; hexo.extend.renderer.register('md', 'html', renderer, true); const result = await hexo.post.render(null, { content: '**foo** {% lorem %}', engine }); result.content.should.eql('

foo {% lorem %}

\n'); }); }); describe('image options', () => { const body = '![](/bar/baz.jpg)'; it('add lazyload attribute', () => { hexo.config.markdown.images = { lazyload: true }; const renderer = new Renderer(hexo); const result = renderer.render({ text: body }); result.should.eql('

\n'); }); it('keep lazyload attribute', () => { hexo.config.markdown.images = { lazyload: true }; const renderer = new Renderer(hexo); const result = renderer.render({ text: body }); result.should.eql('

\n'); }); it('should prepend root', () => { hexo.config.markdown.images = { prepend_root: true }; const renderer = new Renderer(hexo); hexo.config.root = '/blog'; const result = renderer.render({ text: body }); result.should.eql('

\n'); }); it('alt text', () => { hexo.config.markdown.images = { test: true }; const renderer = new Renderer(hexo); const result = renderer.render({ text: '![alt text](/bar/baz.jpg)' }); result.should.eql('

alt text

\n'); }); describe('post_asset', () => { const Post = hexo.model('Post'); const PostAsset = hexo.model('PostAsset'); beforeEach(() => { hexo.config.post_asset_folder = true; hexo.config.markdown.images = { prepend_root: true, post_asset: true }; }); it('should prepend post path', async () => { const renderer = new Renderer(hexo); const asset = 'img/bar.svg'; const slug = asset.replace(/\//g, sep); const content = `![](${asset})`; const post = await Post.insert({ source: '_posts/foo.md', slug: 'foo' }); const postasset = await PostAsset.insert({ _id: `source/_posts/foo/${asset}`, slug, post: post._id }); const expected = url_for.call(hexo, join(post.path, asset)); const result = renderer.render({ text: content, path: post.full_source }); result.should.eql(`

\n`); // should not be Windows path expected.includes('\\').should.eql(false); await PostAsset.removeById(postasset._id); await Post.removeById(post._id); }); it('should prepend post path without slug', async () => { const renderer = new Renderer(hexo); const asset = 'img/bar.svg'; const slug = asset.replace(/\//g, sep); const content = `![](foo/${asset})`; const post = await Post.insert({ source: '_posts/foo.md', slug: 'foo' }); const postasset = await PostAsset.insert({ _id: `source/_posts/foo/${asset}`, slug, post: post._id }); const expected = url_for.call(hexo, join(post.path, asset)); const result = renderer.render({ text: content, path: post.full_source }); result.should.eql(`

\n`); // should not be Windows path expected.includes('\\').should.eql(false); await PostAsset.removeById(postasset._id); await Post.removeById(post._id); }); it('should not modify non-post asset', async () => { const renderer = new Renderer(hexo); const asset = 'bar.svg'; const siteasset = '/logo/brand.png'; const site = 'http://lorem.ipsum/dolor/huri.bun'; const content = `![](${asset})![](${siteasset})![](${site})`; const post = await Post.insert({ source: '_posts/foo.md', slug: 'foo' }); const postasset = await PostAsset.insert({ _id: `source/_posts/foo/${asset}`, slug: asset, post: post._id }); const result = renderer.render({ text: content, path: post.full_source }); result.should.eql([ `

`, ``, `

` ].join('') + '\n'); await PostAsset.removeById(postasset._id); await Post.removeById(post._id); }); it('post located in subfolder', async () => { const renderer = new Renderer(hexo); const asset = 'img/bar.svg'; const slug = asset.replace(/\//g, sep); const content = `![](${asset})`; const post = await Post.insert({ source: '_posts/lorem/foo.md', slug: 'foo' }); const postasset = await PostAsset.insert({ _id: `source/_posts/lorem/foo/${asset}`, slug, post: post._id }); const expected = url_for.call(hexo, join(post.path, asset)); const result = renderer.render({ text: content, path: post.full_source }); result.should.eql(`

\n`); await PostAsset.removeById(postasset._id); await Post.removeById(post._id); }); }); }); }); ================================================ FILE: test/scripts/enable_unsafe_link.js ================================================ 'use strict'; // eslint-disable-next-line no-undef hexo.extend.filter.register('markdown-it:renderer', md => { md.validateLink = function() { return true; }; });