Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # mdast-util-from-markdown
  2. [![Build][build-badge]][build]
  3. [![Coverage][coverage-badge]][coverage]
  4. [![Downloads][downloads-badge]][downloads]
  5. [![Size][size-badge]][size]
  6. [![Sponsors][sponsors-badge]][collective]
  7. [![Backers][backers-badge]][collective]
  8. [![Chat][chat-badge]][chat]
  9. **[mdast][]** utility to parse markdown.
  10. ## Install
  11. [npm][]:
  12. ```sh
  13. npm install mdast-util-from-markdown
  14. ```
  15. ## Use
  16. Say we have the following markdown file, `example.md`:
  17. ```markdown
  18. ## Hello, *World*!
  19. ```
  20. And our script, `example.js`, looks as follows:
  21. ```js
  22. var fs = require('fs')
  23. var fromMarkdown = require('mdast-util-from-markdown')
  24. var doc = fs.readFileSync('example.md')
  25. var tree = fromMarkdown(doc)
  26. console.log(tree)
  27. ```
  28. Now, running `node example` yields (positional info removed for brevity):
  29. ```js
  30. {
  31. type: 'root',
  32. children: [
  33. {
  34. type: 'heading',
  35. depth: 2,
  36. children: [
  37. {type: 'text', value: 'Hello, '},
  38. {
  39. type: 'emphasis',
  40. children: [{type: 'text', value: 'World'}]
  41. },
  42. {type: 'text', value: '!'}
  43. ]
  44. }
  45. ]
  46. }
  47. ```
  48. ## API
  49. ### `fromMarkdown(doc[, encoding][, options])`
  50. Parse markdown to a **[mdast][]** tree.
  51. ##### Parameters
  52. ###### `doc`
  53. Value to parse (`string` or [`Buffer`][buffer]).
  54. ###### `encoding`
  55. [Character encoding][encoding] to understand `doc` as when it’s a
  56. [`Buffer`][buffer] (`string`, default: `'utf8'`).
  57. ###### `options.extensions`
  58. Array of syntax extensions (`Array.<MicromarkSyntaxExtension>`, default: `[]`).
  59. Passed to [`micromark` as `extensions`][micromark-extensions].
  60. ###### `options.mdastExtensions`
  61. Array of mdast extensions (`Array.<MdastExtension>`, default: `[]`).
  62. ##### Returns
  63. [`Root`][root].
  64. ## List of extensions
  65. * [`syntax-tree/mdast-util-directive`](https://github.com/syntax-tree/mdast-util-directive)
  66. — parse directives
  67. * [`syntax-tree/mdast-util-footnote`](https://github.com/syntax-tree/mdast-util-footnote)
  68. — parse footnotes
  69. * [`syntax-tree/mdast-util-frontmatter`](https://github.com/syntax-tree/mdast-util-frontmatter)
  70. — parse frontmatter (YAML, TOML, more)
  71. * [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm)
  72. — parse GFM
  73. * [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)
  74. — parse GFM autolink literals
  75. * [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
  76. — parse GFM strikethrough
  77. * [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)
  78. — parse GFM tables
  79. * [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)
  80. — parse GFM task list items
  81. * [`syntax-tree/mdast-util-math`](https://github.com/syntax-tree/mdast-util-math)
  82. — parse math
  83. * [`syntax-tree/mdast-util-mdx`](https://github.com/syntax-tree/mdast-util-mdx)
  84. — parse MDX or MDX.js
  85. * [`syntax-tree/mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)
  86. — parse MDX or MDX.js expressions
  87. * [`syntax-tree/mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)
  88. — parse MDX or MDX.js JSX
  89. * [`syntax-tree/mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)
  90. — parse MDX.js ESM
  91. ## Security
  92. As Markdown is sometimes used for HTML, and improper use of HTML can open you up
  93. to a [cross-site scripting (XSS)][xss] attack, use of `mdast-util-from-markdown`
  94. can also be unsafe.
  95. When going to HTML, use this utility in combination with
  96. [`hast-util-sanitize`][sanitize] to make the tree safe.
  97. ## Related
  98. * [`micromark/micromark`](https://github.com/micromark/micromark)
  99. — the smallest commonmark-compliant markdown parser that exists
  100. * [`remarkjs/remark`](https://github.com/remarkjs/remark)
  101. — markdown processor powered by plugins
  102. * [`syntax-tree/mdast-util-to-markdown`](https://github.com/syntax-tree/mdast-util-to-markdown)
  103. — serialize mdast to markdown
  104. ## Contribute
  105. See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
  106. started.
  107. See [`support.md`][support] for ways to get help.
  108. This project has a [code of conduct][coc].
  109. By interacting with this repository, organization, or community you agree to
  110. abide by its terms.
  111. ## License
  112. [MIT][license] © [Titus Wormer][author]
  113. <!-- Definitions -->
  114. [build-badge]: https://github.com/syntax-tree/mdast-util-from-markdown/workflows/main/badge.svg
  115. [build]: https://github.com/syntax-tree/mdast-util-from-markdown/actions
  116. [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-from-markdown.svg
  117. [coverage]: https://codecov.io/github/syntax-tree/mdast-util-from-markdown
  118. [downloads-badge]: https://img.shields.io/npm/dm/mdast-util-from-markdown.svg
  119. [downloads]: https://www.npmjs.com/package/mdast-util-from-markdown
  120. [size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-from-markdown.svg
  121. [size]: https://bundlephobia.com/result?p=mdast-util-from-markdown
  122. [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
  123. [backers-badge]: https://opencollective.com/unified/backers/badge.svg
  124. [collective]: https://opencollective.com/unified
  125. [chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
  126. [chat]: https://github.com/syntax-tree/unist/discussions
  127. [npm]: https://docs.npmjs.com/cli/install
  128. [license]: license
  129. [author]: https://wooorm.com
  130. [contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
  131. [support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
  132. [coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
  133. [mdast]: https://github.com/syntax-tree/mdast
  134. [root]: https://github.com/syntax-tree/mdast#root
  135. [encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
  136. [buffer]: https://nodejs.org/api/buffer.html
  137. [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
  138. [sanitize]: https://github.com/syntax-tree/hast-util-sanitize
  139. [micromark-extensions]: https://github.com/micromark/micromark#optionsextensions