You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-27Lines changed: 54 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -515,25 +515,36 @@ When you specified the path to JavaScript file (`.js`, `.cjs`, or `.mjs`) in `--
515
515
516
516
The functional engine should export a function as the default export, which should have a single argument representing [the constructor option of Marpit](https://marpit-api.marp.app/marpit)/[Marp Core](https://github.com/marp-team/marp-core#constructor-options).
517
517
518
-
The function must return a class inherited from Marpit, or an instance of Marpit-based engine made by the parameter passed by argument.
518
+
The function must return a class that inherits from Marpit, or an instance of a Marpit-based engine created with the constructor options passed as an argument.
// Return an instance of Marpit initialized by passed constructor options
533
-
returnnewMarpitBasedEngine(constructorOptions)
534
-
}
537
+
module.exports= () => MarpitBasedEngine
538
+
539
+
// module.exports = function (constructorOptions) {
540
+
// return new MarpitBasedEngine(constructorOptions)
541
+
// }
535
542
```
536
543
544
+
</details>
545
+
546
+
#### Async function
547
+
537
548
This function can return [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object so you can use [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) too.
Marp CLI also exposes `marp` getter property to the parameter. It returns a prepared instance of the built-in Marp Core engine, so you can apply several customizations to Marp engine with simple declarations.
`marpCli()` accepts an argument of CLI options as array, and returns `Promise` to resolve an expected exit status in CLI. It would be rejected with the instance of `Error` if CLI met an error to suspend the conversion process.
@@ -805,25 +817,40 @@ We have exported [`CLIError` class and `CLIErrorCode` enum](https://github.com/m
805
817
806
818
If `CLIError` instance was thrown, you can identify the reason why CLI threw error by checking `errorCode` member.
`marpCli()` would not be resolved initiatively if started some observation: Watch mode, server mode, and preview window.
811
835
812
836
`waitForObservation()` is helpful to handle them. It returns `Promise` that would be resolved with helper object when ready to observe resources in `marpCli()`.
0 commit comments