{"id":21857889,"url":"https://github.com/mathematic-inc/node-pandoc-filter","last_synced_at":"2025-04-14T18:41:08.478Z","repository":{"id":143889206,"uuid":"317915535","full_name":"mathematic-inc/node-pandoc-filter","owner":"mathematic-inc","description":"Node.js Pandoc filtering","archived":false,"fork":false,"pushed_at":"2020-12-03T13:15:29.000Z","size":274,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T07:11:12.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/mathematic-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jun-sheaf","custom":"https://paypal.me/jeongjh"}},"created_at":"2020-12-02T16:03:41.000Z","updated_at":"2024-07-16T21:49:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"de649dce-fbdd-4c9a-8e19-35fd1db80957","html_url":"https://github.com/mathematic-inc/node-pandoc-filter","commit_stats":null,"previous_names":["mu-io/node-pandoc-filter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathematic-inc%2Fnode-pandoc-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathematic-inc%2Fnode-pandoc-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathematic-inc%2Fnode-pandoc-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathematic-inc%2Fnode-pandoc-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathematic-inc","download_url":"https://codeload.github.com/mathematic-inc/node-pandoc-filter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248938180,"owners_count":21186358,"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":[],"created_at":"2024-11-28T02:32:26.332Z","updated_at":"2025-04-14T18:41:08.470Z","avatar_url":"https://github.com/mathematic-inc.png","language":"TypeScript","funding_links":["https://github.com/sponsors/jun-sheaf","https://paypal.me/jeongjh"],"categories":[],"sub_categories":[],"readme":"# Node.js Pandoc Filters\n\n![CI](https://github.com/mu-io/node-pandoc-filter/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/mu-io/node-pandoc-filter/branch/main/graph/badge.svg?token=IKqBrTyEPs)](https://codecov.io/gh/mu-io/node-pandoc-filter)\n\n\u003e A Node.js framework for building\n\u003e [Pandoc filters](https://pandoc.org/filters.html#but-i-dont-want-to-learn-haskell)\n\n- [Background](#background)\n- [Documentation](#documentation)\n- [Install](#install)\n- [Getting Started](#getting-started)\n- [Examples](#examples)\n  - [JavaScript](#javascript)\n  - [TypeScript](#typescript)\n- [Compatibility](#compatibility)\n- [License](#license)\n\n## Background\n\nPandoc filters are executable scripts that Pandoc executes after compiling a document to Pandoc's\nproprietary AST. The pathway is as follows:\n\n1. Pandoc compiles the source document to an AST written in JSON.\n2. Pandoc streams (via `stdin`) the AST to each filter sequentially.\n3. Each filter outputs (via `stdout`) an augmented AST for Pandoc to read.\n4. Pandoc compiles the AST to the targeted format.\n\n## Documentation\n\nDocumentation is located [here](https://mu-io.github.io/node-pandoc-filter/).\n\n## Install\n\nYou should install `node-pandoc-filter` globally for `pandoc` to execute Node.js-based filters:\n\n```bash\nnpm install -g node-pandoc-filter\n```\n\n## Getting Started\n\nThis package comes with two entry points:\n\n- [`node-pandoc-filter/nodes`](https://mu-io.github.io/node-pandoc-filter/modules/_nodes_index_.html):\n  This is where all nodes (e.g. `Str`) and node-like creators (e.g. `Attr`) are imported from.\n- [`node-pandoc-filter`](https://mu-io.github.io/node-pandoc-filter/modules/_index_.html): Everything else.\n\n\u003e The `Math` node is renamed to `Formula` as to not conflict with the internal `Math` object in JavaScript.\n\nAs stated previously, Pandoc filters are executable scripts, so you must use a\n[hashbang](https://github.com/tc39/proposal-hashbang) at the top of each filter, targeting the\nspecific method of execution. For example, `#!/usr/bin/env node`.\n\n\u003e For TypeScript, you can use [`ts-node`](https://github.com/TypeStrong/ts-node) via it's\n\u003e `ts-node-script` executable rather than pre-compiling and using `node`. _If you are compiling many\n\u003e document_, this is **NOT RECOMMENDED**.\n\n## Examples\n\n### JavaScript\n\n```javascript\n#!/usr/bin/env node\nconst { Str } = require(\"node-pandoc-filter/nodes\");\nconst { toJSONFilter } = require(\"node-pandoc-filter\");\nconst requestPromise = require(\"request-promise-native\");\n\ntoJSONFilter({\n  async Str(value) {\n    const data = await requestPromise({ uri: value, json: true });\n    return Str(data.places[0][\"post code\"]);\n  },\n});\n```\n\n### TypeScript\n\n```typescript\n#!/usr/bin/env ts-node-script\nimport { Str } from \"node-pandoc-filter/nodes\";\nimport { toJSONFilter } from \"node-pandoc-filter\";\nimport itFilters from \"../utils/it-filters\";\n\ntoJSONFilter({\n  async Str(value) {\n    return Str(value.toUpperCase());\n  },\n});\n```\n\n## Compatibility\n\nThis package is compatible with\n\n- Node.js \u003e= v10\n- Pandoc \u003e= v1.17.2\n  - If older compatibility is required, see\n    [pandoc-filter-node](https://github.com/mvhenderson/pandoc-filter-node)\n\n## License\n\nCopyright © 2020 mu-io.\n\nLicensed under [MIT](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathematic-inc%2Fnode-pandoc-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathematic-inc%2Fnode-pandoc-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathematic-inc%2Fnode-pandoc-filter/lists"}