nizel-plugin-details 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2391,7 +2391,7 @@ var NizelDetails = (() => {
2391
2391
  var lazyContinuationCandidate = (line) => {
2392
2392
  let candidate = line;
2393
2393
  while (true) {
2394
- const quoteMarker = /^ {0,3}> ?(.*)$/.exec(candidate);
2394
+ const quoteMarker = /^ {0,3}> ?([^]*)$/.exec(candidate);
2395
2395
  if (quoteMarker) {
2396
2396
  candidate = quoteMarker[1];
2397
2397
  continue;
@@ -3713,7 +3713,7 @@ ${line}`) !== null;
3713
3713
  const quoteLines = [];
3714
3714
  let allowLazyContinuation = false;
3715
3715
  while (index < lines.length) {
3716
- const quoteMarker = /^( {0,3}> ?)(.*)$/.exec(lines[index]);
3716
+ const quoteMarker = /^( {0,3}> ?)([^]*)$/.exec(lines[index]);
3717
3717
  if (quoteMarker) {
3718
3718
  const markerColumn = quoteMarker[1].endsWith(" ") ? quoteMarker[1].length : quoteMarker[1].length + 1;
3719
3719
  const quoteLine = expandLeadingTabsFromColumn(quoteMarker[2], markerColumn);
@@ -3733,11 +3733,7 @@ ${line}`) !== null;
3733
3733
  if (quoteLines[quoteLines.length - 1] === "") {
3734
3734
  quoteLines.pop();
3735
3735
  }
3736
- if (index > 0) {
3737
- index -= 1;
3738
- } else {
3739
- index += 1;
3740
- }
3736
+ index -= 1;
3741
3737
  children.push({
3742
3738
  type: "blockquote",
3743
3739
  children: parseBlocks(quoteLines, options, seenSlugs, state)
@@ -4377,7 +4373,7 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4377
4373
  };
4378
4374
 
4379
4375
  // ../nizel/dist/use-nizel.js
4380
- function createNizel(options = {}, htmlBackend) {
4376
+ function createNizel(options = {}, htmlBackend, astBackend) {
4381
4377
  const presetOptions = options.preset ? resolvePreset(options.preset) : {};
4382
4378
  const effectiveOptions = { ...presetOptions, ...options, preset: void 0 };
4383
4379
  const baseResolved = resolveOptions(effectiveOptions, {});
@@ -4411,6 +4407,9 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4411
4407
  const accelerated = htmlBackend?.(source, prepared.resolved);
4412
4408
  if (accelerated !== void 0)
4413
4409
  return applyAfterRender(accelerated, prepared.resolved);
4410
+ const parsed = astBackend?.(source, prepared.resolved);
4411
+ if (parsed !== void 0)
4412
+ return renderPreparedHtml(applyAstHooks(parsed, prepared.resolved), prepared.resolved);
4414
4413
  const { ast, resolved } = prepareMarkdown(markdown, runtimeOptions, prepared, source);
4415
4414
  return renderPreparedHtml(ast, resolved);
4416
4415
  };
@@ -4424,7 +4423,7 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4424
4423
  nizel.meta = async (markdown, runtimeOptions) => {
4425
4424
  return prepareMeta(markdown, runtimeOptions).meta;
4426
4425
  };
4427
- nizel.preset = (name) => createNizel(resolvePreset(name), htmlBackend);
4426
+ nizel.preset = (name) => createNizel(resolvePreset(name), htmlBackend, astBackend);
4428
4427
  nizel.parse = async (markdown, runtimeOptions) => {
4429
4428
  const resolved = resolveRuntime(runtimeOptions);
4430
4429
  const extracted = resolved.frontmatter === false ? { markdown, frontmatter: {} } : extractFrontmatter(markdown);
@@ -4462,16 +4461,7 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4462
4461
  safe: preparedMeta.resolved.safe !== false,
4463
4462
  slugStyle: preparedMeta.resolved.slugStyle
4464
4463
  });
4465
- for (const plugin of preparedMeta.resolved.plugins ?? []) {
4466
- const afterResult = plugin.hooks?.afterParse?.(ast, preparedMeta.resolved);
4467
- if (afterResult)
4468
- ast = afterResult;
4469
- }
4470
- for (const transform of preparedMeta.resolved.transforms ?? []) {
4471
- const transformResult = transform(ast);
4472
- if (transformResult)
4473
- ast = transformResult;
4474
- }
4464
+ ast = applyAstHooks(ast, preparedMeta.resolved);
4475
4465
  return {
4476
4466
  ast,
4477
4467
  meta: preparedMeta.meta,
@@ -4518,6 +4508,20 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4518
4508
  };
4519
4509
  }
4520
4510
  }
4511
+ function applyAstHooks(parsed, resolved) {
4512
+ let ast = parsed;
4513
+ for (const plugin of resolved.plugins ?? []) {
4514
+ const afterResult = plugin.hooks?.afterParse?.(ast, resolved);
4515
+ if (afterResult)
4516
+ ast = afterResult;
4517
+ }
4518
+ for (const transform of resolved.transforms ?? []) {
4519
+ const transformResult = transform(ast);
4520
+ if (transformResult)
4521
+ ast = transformResult;
4522
+ }
4523
+ return ast;
4524
+ }
4521
4525
  function prepareSource(prepared) {
4522
4526
  let markdown = prepared.markdown;
4523
4527
  for (const plugin of prepared.resolved.plugins ?? []) {
@@ -4554,10 +4558,10 @@ ${" ".repeat(marker.length + 1)}${line}`).join("")}`;
4554
4558
  function hasRuntimeOptions(runtimeOptions) {
4555
4559
  return Boolean(runtimeOptions && Object.keys(runtimeOptions).length > 0);
4556
4560
  }
4557
- function createNizelFactory(htmlBackend) {
4558
- const factory = (options) => createNizel(options, htmlBackend);
4561
+ function createNizelFactory(htmlBackend, astBackend) {
4562
+ const factory = (options) => createNizel(options, htmlBackend, astBackend);
4559
4563
  return Object.assign(factory, {
4560
- preset: (name) => createNizel(resolvePreset(name), htmlBackend)
4564
+ preset: (name) => createNizel(resolvePreset(name), htmlBackend, astBackend)
4561
4565
  });
4562
4566
  }
4563
4567
  var useNizel = createNizelFactory();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nizel-plugin-details",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Details disclosure block plugin for Nizel.",
5
5
  "repository": {
6
6
  "type": "git",