@bendyline/squisq 1.5.1 → 1.5.2

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.
@@ -376,6 +376,14 @@ export function serializePandocAttributes(attrs: HeadingAttributes): string | nu
376
376
  return `{${parts.join(' ')}}`;
377
377
  }
378
378
 
379
+ function hasPrintablePandocAttributes(attrs: HeadingAttributes): boolean {
380
+ return Boolean(
381
+ attrs.id ||
382
+ (attrs.classes && attrs.classes.length > 0) ||
383
+ (attrs.params && Object.keys(attrs.params).length > 0),
384
+ );
385
+ }
386
+
379
387
  /**
380
388
  * Serialize a HeadingTemplateAnnotation back to `{[templateName key=value …]}` text.
381
389
  * Values are quoted via the shared {@link quoteAttrValue} rule (same as
@@ -977,7 +985,9 @@ function blockToMdast(node: MarkdownBlockNode): MdastNode {
977
985
  const suffixes: string[] = [];
978
986
  if (node.attributes) {
979
987
  const pandoc = serializePandocAttributes(node.attributes);
980
- if (pandoc != null) suffixes.push(pandoc);
988
+ if (pandoc != null && (pandoc !== '{}' || hasPrintablePandocAttributes(node.attributes))) {
989
+ suffixes.push(pandoc);
990
+ }
981
991
  }
982
992
  if (node.templateAnnotation) {
983
993
  suffixes.push(serializeTemplateAnnotation(node.templateAnnotation));