{"name":"micromark-util-resolve-all","version":"1.0.0-alpha.2","description":"micromark utility to resolve subtokens","license":"MIT","keywords":["micromark","util","utility","resolve"],"repository":{"type":"git","url":"git+https://github.com/micromark/micromark.git#main"},"bugs":{"url":"https://github.com/micromark/micromark/issues"},"funding":[{"type":"GitHub Sponsors","url":"https://github.com/sponsors/unifiedjs"},{"type":"OpenCollective","url":"https://opencollective.com/unified"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","exports":"./index.js","dependencies":{"micromark-util-types":"1.0.0-alpha.2"},"scripts":{"build":"rimraf \"*.d.ts\" && tsc && type-coverage"},"xo":false,"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"readme":"# micromark-util-resolve-all\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][bundle-size-badge]][bundle-size]\n[![Sponsors][sponsors-badge]][opencollective]\n[![Backers][backers-badge]][opencollective]\n[![Chat][chat-badge]][chat]\n\nmicromark utility to resolve subtokens.\n\n[Resolvers][resolver] are functions that take events and manipulate them.\nThis is needed for example because media (links, images) and attention (strong,\nitalic) aren’t parsed left-to-right.\nInstead, their openings and closings are parsed, and when done, their openings\nand closings are matched, and left overs are turned into plain text.\nBecause media and attention can’t overlap, we need to perform that operation\nwhen one closing matches an opening, too.\n\n## Contents\n\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`resolveAll(constructs, events, context)`](#resolveallconstructs-events-context)\n*   [Security](#security)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install micromark-util-resolve-all\n```\n\n## Use\n\n```js\nimport {push} from 'micromark-util-chunked'\nimport {resolveAll} from 'micromark-util-resolve-all'\n\n/**\n * @type {Resolver}\n */\nfunction resolveAllAttention(events, context) {\n  // …\n\n  // Walk through all events.\n  while (++index < events.length) {\n    // Find a token that can close.\n    if (\n      events[index][0] === 'enter' &&\n      events[index][1].type === 'attentionSequence' &&\n      events[index][1]._close\n    ) {\n      open = index\n\n      // Now walk back to find an opener.\n      while (open--) {\n        // Find a token that can open the closer.\n        if (\n          // …\n        ) {\n          // …\n\n          // Opening.\n          nextEvents = push(nextEvents, [\n            // …\n          ])\n\n          // Between.\n          nextEvents = push(\n            nextEvents,\n            resolveAll(\n              context.parser.constructs.insideSpan.null,\n              events.slice(open + 1, index),\n              context\n            )\n          )\n\n          // Closing.\n          nextEvents = push(nextEvents, [\n            // …\n          ])\n\n          // …\n        }\n      }\n    }\n  }\n\n  // …\n}\n```\n\n## API\n\nThis module exports the following identifiers: `resolveAll`.\nThere is no default export.\n\n### `resolveAll(constructs, events, context)`\n\nCall all `resolveAll`s in `constructs`.\n\n###### Parameters\n\n*   `constructs` (`Construct[]`) — List of constructs, optionally with\n    `resolveAll`s\n*   `events` (`Event[]`) — List of events\n*   `context` (`TokenizeContext`) — Context used by `tokenize`\n\n###### Returns\n\n`Events[]` — Changed events.\n\n## Security\n\nSee [`security.md`][securitymd] in [`micromark/.github`][health] for how to\nsubmit a security report.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`micromark/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organisation, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg\n\n[build]: https://github.com/micromark/micromark/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg\n\n[coverage]: https://codecov.io/github/micromark/micromark\n\n[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-resolve-all.svg\n\n[downloads]: https://www.npmjs.com/package/micromark-util-resolve-all\n\n[bundle-size-badge]: https://img.shields.io/bundlephobia/minzip/micromark-util-resolve-all.svg\n\n[bundle-size]: https://bundlephobia.com/result?p=micromark-util-resolve-all\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[opencollective]: https://opencollective.com/unified\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/micromark/micromark/discussions\n\n[license]: https://github.com/micromark/micromark/blob/main/license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/micromark/.github\n\n[securitymd]: https://github.com/micromark/.github/blob/HEAD/security.md\n\n[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/micromark/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md\n\n[resolver]: https://github.com/micromark/micromark/blob/a571c09/packages/micromark-util-types/index.js#L219\n","readmeFilename":"readme.md","homepage":"https://github.com/micromark/micromark/tree/main#readme","_id":"micromark-util-resolve-all@1.0.0-alpha.2","_nodeVersion":"16.2.0","_npmVersion":"7.15.1","dist":{"integrity":"sha512-199DKlVvzpBcXtQLnxd04G1XL2d8fzkVRLniWgJHA1C41fZICGT4fEkuocppzsb72FOVmIpnUesT3YMiEOHN1w==","shasum":"ee65b2b2c552fff85d7ded0fc5ae1d4c210192a4","tarball":"http://registry-npm.ywwl.com/micromark-util-resolve-all/download/micromark-util-resolve-all-1.0.0-alpha.2.tgz","fileCount":4,"unpackedSize":7457,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgviDKCRA9TVsSAnZWagAAWr4P+wWoBDlAZJW+HrLiKqop\nK1dDoydnQq7PFKDYZqqrrsoNj3nYBlYKnliGkmaug68AUnjqoXspWZ1DK62v\nU4HBgOJ+EHw1neLEiJMzyTRVEp2mtp//wndumlYrGQNMDYQGWU7XJHUbUDZE\ncMoH24oWVQBMWfLScln55FKQfIHvCE5nvYhyxyOHbSSRbTrSr4qX8uWneEeN\nmknGVL1zDyZ+hojEJT3EVDBlxf64KvuggEHBklQsF9/hAghSgkPQoKGwfQmV\nEiCUySgGW/DeWHxHTAlfBuNJdW4jnqDBRhKbCotSItZDIbaSoHInc6YkCgGF\nEmsMk1tKTwCnMylwpHb7aCUjVQ2WdE1ygtRvHKBVjKZQ318DSAzirOrUQde0\nGVymr02MS3OfUqErqYG9cOtUJ5eTL6gRa2/n30LEL3x2JxUUTIT/HQW2it/t\n+M3BgjmRREfEq0uSyw4ehkobClHbwd0WcaAwUxxVGfRUgOEgKVwxPTuoB2ej\nzxoqbAQXaR0nFsH1B9ZqK0hqP2PYaJ3A/dcYmvidf2MoSCe+CgidB298vcdH\nx9QgBmoqb8wNjjf+t0h0qAXOZ5CYtVhFS2w02xg8cPNTKeYP0yDqbaJomQG/\nEScpURCZNcPSBBtVUO3z/cfOVqEd4Za1YeBfGBW+YknF3Sh9goP8S0+Q4mtL\nqWrQ\r\n=5cpq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIElHrB4VQOMFiSzxRJz8ArC7PXpDmEboYnDUQ1c3246uAiEA4CTXADEOMvbtcyaEJSq1Rn4vZ1tzkCJyPgbxOsuvL6g="}],"size":2552,"noattachment":false,"key":"/micromark-util-resolve-all/-/micromark-util-resolve-all-1.0.0-alpha.2.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/micromark-util-resolve-all_1.0.0-alpha.2_1623072970328_0.28868983885713373"},"_hasShrinkwrap":false,"publish_time":1623072970530,"_cnpm_publish_time":1623072970530,"dist-tags":{"latest":"2.0.1","next":"1.0.0-beta.1"}}