jonschlinkert/remarkable là dự án phía máy chủ trên GitHub với 5.8k sao, viết chủ yếu bằng JavaScript. Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one. Gulp and metalsmith plugins available. Used by Facebook, Docusaurus and many others! Use https://github.com/breakdance/breakdance for HTML-to-markdown conversion. Use https://github.com/jonschlinkert/markdown-toc to generate a table of contents.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
See the docs directory for documentation on the following topics:
parser
parsing_block
parsing_core
parsing_inline
plugins
renderer
Options
By default, remarkable is configured to be similar to GFM, but with HTML disabled.
This is easy to change if you prefer different settings.
There are two ways to define options.
constructor
Define options in the constructor:
// Actual default values
var md = new Remarkable({
html: false, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags (<br />)
breaks: false, // Convert '\n' in paragraphs into <br>
langPrefix: 'language-', // CSS language prefix for fenced blocks
// Enable some language-neutral replacement + quotes beautification
typographer: false,
// Double + single quotes replacement pairs, when typographer enabled,
// and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
quotes: '“”‘’',
// Highlighter function. Should return escaped HTML,
// or '' if the source string is not changed
highlight: function (/*str, lang*/) { return ''; }
});
console.log(md.render('# Remarkable rulezz!'));
// => <h1>Remarkable rulezz!</h1>
.set
Or define options via the .set() method:
import { Remarkable } from 'remarkable';
var md = new Remarkable();
md.set({
html: true,
breaks: true
});
Note: To achieve the best possible performance, don't modify a Remarkable
instance on the fly. If you need multiple configurations, create
multiple instances and initialize each with a configuration that is ideal for
that instance.
Presets
Remarkable offers some "presets" as a convenience to quickly enable/disable
active syntax rules and options for common use cases.
commonmark
Enable strict CommonMark mode with the commonmark preset:
import { Remarkable } from 'remarkable';
var md = new Remarkable('commonmark');
full
Enable all available rules (but still with default options, if not set):
import { Remarkable } from 'remarkable';
var md = new Remarkable('full');
// Or with options:
var md = new Remarkable('full', {
html: true,
typographer: true
});
Syntax highlighting
Apply syntax highlighting to fenced code blocks with the highlight option:
import { Remarkable } from 'remarkable';
import hljs from 'highlight.js' // https://highlightjs.org/
// Actual default values
var md = new Remarkable({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (err) {}
}
try {
return hljs.highlightAuto(str).value;
} catch (err) {}
return ''; // use external default escaping
}
});
Syntax extensions
Enabled by default:
Footnotes
Tables (GFM)
<del>
(GFM strikethrough) - ~~deleted text~~
Disabled by default:
<sup> - 19^th^
<sub> - H~2~O
abbreviations
<ins> - ++inserted text++ (experimental)
<mark> - ==marked text== (experimental)
HEADS UP!: Experimental extensions can be changed later for something like Critic Markup, but you will still be able to use old-style rules via external plugins if you prefer.
Manage rules
var md = new Remarkable();
md.inline.ruler.enable([ 'ins', 'mark' ]);
md.block.ruler.disable([ 'table', 'footnote' ]);
// Enable everything
md = new Remarkable('full', {
html: true,
typographer: true,
});
//
// Manually enable rules, disabled by default:
//
var md = new Remarkable();
md.core.ruler.enable([
'abbr'
]);
md.block.ruler.enable([
'footnote',
'deflist'
]);
md.inline.ruler.enable([
'footnote_inline',
'ins',
'mark',
'sub',
'sup'
]);
Typographer
Although full-weight typographical replacements are language specific, remarkable
provides coverage for the most common and universal use cases:
Big thanks to John MacFarlane for his work on the
CommonMark spec and reference implementations. His work saved us a lot of time
during this project's development.
Related Links:
https://github.com/jgm/CommonMark - reference CommonMark implementations in C & JS,
also contains latest spec & online demo.
http://talk.commonmark.org - CommonMark forum, good place to collaborate
developers' efforts.
Development / Modification
Parser consists of several responsibility chains filled with
rules. You can reconfigure any of them as you wish. Renderer also
can be modified and extended. See source code to understand details. Pay
attention to these properties:
Here is result of CommonMark spec parse at Core i5 2.4 GHz (i5-4258U):
$ benchmark/benchmark.js spec
Selected samples: (1 of 27)
> spec
Sample: spec.txt (110610 bytes)
> commonmark-reference x 40.42 ops/sec ±4.07% (51 runs sampled)
> current x 74.99 ops/sec ±4.69% (67 runs sampled)
> current-commonmark x 93.76 ops/sec ±1.23% (79 runs sampled)
> marked-0.3.2 x 22.92 ops/sec ±0.79% (41 runs sampled)
As you can see, remarkable doesn't pay with speed for its flexibility. Because
it's written in monomorphic style and uses JIT inline caches effectively.
jonschlinkert/remarkable thuộc nhóm Backend trên TopGit, cùng 15 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về jonschlinkert/remarkable ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jonschlinkert/remarkable là nguồn chính thức.
jonschlinkert/remarkable có bao nhiêu sao?
jonschlinkert/remarkable có 5.8k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/jonschlinkert/remarkable. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
jonschlinkert/remarkable còn đang phát triển không?
Commit gần nhất trên jonschlinkert/remarkable là 2.5 năm trước (theo timestamp GitHub). Repo có 374 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
jonschlinkert/remarkable viết bằng ngôn ngữ gì?
jonschlinkert/remarkable chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao jonschlinkert/remarkable được xếp vào nhóm Backend?
TopGit xếp jonschlinkert/remarkable vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "commonmark", "compile", "docusaurus"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về remarkable?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về remarkable.