{"id":20475188,"url":"https://github.com/AegisJSProject/markdown","last_synced_at":"2025-05-09T01:31:59.058Z","repository":{"id":221076830,"uuid":"753347921","full_name":"AegisJSProject/markdown","owner":"AegisJSProject","description":"Markdown parser for `@aegisjsproject/core`","archived":false,"fork":false,"pushed_at":"2025-04-24T17:56:48.000Z","size":840,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T18:48:03.573Z","etag":null,"topics":["aegis","markdown","sanitizer-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@aegisjsproject/markdown","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AegisJSProject.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"shgysk8zer0","liberapay":"shgysk8zer0"}},"created_at":"2024-02-05T23:56:07.000Z","updated_at":"2025-04-24T17:56:51.000Z","dependencies_parsed_at":"2024-03-20T17:29:56.356Z","dependency_job_id":"25da49d5-28e3-4a3f-8319-9b3044250c6b","html_url":"https://github.com/AegisJSProject/markdown","commit_stats":null,"previous_names":["shgysk8zer0/aegis-markdown","aegisjsproject/markdown"],"tags_count":10,"template":false,"template_full_name":"shgysk8zer0/npm-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AegisJSProject%2Fmarkdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AegisJSProject%2Fmarkdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AegisJSProject%2Fmarkdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AegisJSProject%2Fmarkdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AegisJSProject","download_url":"https://codeload.github.com/AegisJSProject/markdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253174390,"owners_count":21865856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aegis","markdown","sanitizer-api"],"created_at":"2024-11-15T15:14:56.457Z","updated_at":"2025-05-09T01:31:58.643Z","avatar_url":"https://github.com/AegisJSProject.png","language":"JavaScript","funding_links":["https://github.com/sponsors/shgysk8zer0","https://liberapay.com/shgysk8zer0","https://liberapay.com/shgysk8zer0/donate"],"categories":[],"sub_categories":[],"readme":"# `@aegisjsproject/markdown`\n\nMarkdown parser for [`@aegisjsproject/core`](https://github.com/AegisJSProject/core)\n\n[![CodeQL](https://github.com/AegisJSProject/markdown/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AegisJSProject/markdown/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/AegisJSProject/markdown/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/AegisJSProject/markdown/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/AegisJSProject/markdown.svg)](https://github.com/AegisJSProject/markdown/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/AegisJSProject/markdown.svg)](https://github.com/AegisJSProject/markdown/commits/master)\n[![GitHub release](https://img.shields.io/github/release/AegisJSProject/markdown?logo=github)](https://github.com/AegisJSProject/markdown/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/AegisJSProject?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@aegisjsproject/markdown)](https://www.npmjs.com/package/@aegisjsproject/markdown)\n![node-current](https://img.shields.io/node/v/@aegisjsproject/markdown)\n![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/%40aegisjsproject%2Fmarkdown)\n\n[![npm](https://img.shields.io/npm/dw/@aegisjsproject/markdown?logo=npm)](https://www.npmjs.com/package/@aegisjsproject/markdown)\n\n[![GitHub followers](https://img.shields.io/github/followers/AegisJSProject.svg?style=social)](https://github.com/AegisJSProject)\n![GitHub forks](https://img.shields.io/github/forks/AegisJSProject/markdown.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/AegisJSProject/markdown.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n\u003c!-- - [Security Policy](./.github/SECURITY.md) --\u003e\n\n## Adding language support\n\nIn order to reduce bundle size, only plaintext is available/supported by default.\nHowever, you can easily add support for additional languages in a variety of ways:\n\n### Registering from Static Imports\n\n**Note**: All languages provided by `highlight.js` may be found at [`/es/languages/${lang}.min.js`](https://unpkg.com/browse/@highlightjs/cdn-assets/es/languages/).\n\n```js\nimport { registerLanguage } from '@aegisjsproject/markdown';\nimport javascript from 'highlight.js/lanuages/javascript.min.js';\nimport xml from 'highlight.js/languages/xml.min.js';\nimport css from 'highlight.js/languages/css.min.js';\n\nregisterLanguage('javascript', javascript);\nregisterLanguage('xml', xml);\nregisterLanguage('css',css);\n\n// Or\nimport { registerLanguages } from '@aegisjsproject/markdown';\nimport javascript from 'highlight.js/lanuages/javascript.min.js';\nimport xml from 'highlight.js/languages/xml.min.js';\nimport css from 'highlight.js/languages/css.min.js';\n\nregisterLanguages({ javascript, xml, css });\n```\n\n### Dynamically Loading and Registering using Dynamic Imports\n\nThis uses `import()` for dynamic loading of language modules from `unpkg.com`.\n\n**Note**: These are case-sensitive and **MUST** be the correct filename (without extension).\n\n```js\nimport { loadLanguages } from '@aegisjsproject/markdown';\n\nawait loadLanguages('javascript', 'css', 'xml', 'typescript');\n```\n\n## Example\n\n```js\nimport { md, createStyleSheet, getMarkdown, registerLanguages } from '@aegisjsproject/markdown';\nimport javascript from 'highlight.js/languages/javascript.min.js';\nimport css from 'highlight.js/languages/css.min.js';\nimport xml from 'highlight.js/languages/xml.min.js';\n\nregisterLanguages({ javascript, css, xml });\n\ndocument.head.append(\n  createStyleSheet('github', { media: '(prefers-color-scheme: light)' }),\n  createStyleSheet('github-dark', { media: '(prefers-color-scheme: dark)' }),\n);\n\ndocument.getElementById('header').append(md`\n  # Hello, World!\n\n  ## It is currently ${new Date()}.\n`);\n\ncustomElements.define('md-preview', class HTMLMDPreviewElement extends HTMLElement {\n  #shadow;\n\n  constructor() {\n    super();\n\n    this.#shadow = this.attachShadow({ mode: 'closed' });\n    const container = document.createElement('div');\n    container.id = 'container';\n    container.part.add('container');\n\n    this.#shadow.append(\n      createStyleSheet('github', { media: '(prefers-color-scheme: light)' }),\n      createStyleSheet('github-dark', { media: '(prefers-color-scheme: dark)' }),\n      container,\n    );\n  }\n\n  async attributeChangedCallback(name, oldVal, newVal) {\n    switch(name) {\n      case 'src':\n        if (typeof newVal === 'string') {\n          this.#shadow.getElementById('container').replaceChildren(await getMarkdown(this.src));\n        } else {\n          this.#shadow.getElementById('container').replaceChildren();\n        }\n        break;\n\n      default:\n        throw new Error(`Unhandled attribute change: ${name}.`);\n    }\n  }\n\n  set content(val) {\n    if (typeof val === 'string' \u0026\u0026 val.length !== 0) {\n      this.#shadow.getElementById('container').replaceChildren(md`${val}`);\n      this.scrollIntoView({ behavior: 'smooth', block: 'start' });\n    } else {\n      this.#shadow.getElementById('container').replaceChildren();\n    }\n  }\n\n  get src() {\n    return this.getAttribute('src');\n  }\n\n  set src(val) {\n    if (typeof val === 'string' || val instanceof URL) {\n      this.setAttribute('src', val);\n    } else {\n      this.removeAttribute('src');\n    }\n  }\n\n  clear() {\n    this.content = null;\n  }\n\n  static get observedAttributes() {\n    return ['src'];\n  }\n});\n\ndocument.forms.test.addEventListener('submit', event =\u003e {\n  event.preventDefault();\n  const data = new FormData(event.target);\n  document.getElementById('preview').content = data.get('md');\n});\n\ndocument.forms.test.addEventListener('reset', () =\u003e document.getElementById('preview').clear());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAegisJSProject%2Fmarkdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAegisJSProject%2Fmarkdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAegisJSProject%2Fmarkdown/lists"}