Skip to content

Commit

Permalink
fix: rendering of additional whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jan 18, 2025
1 parent bfad4e0 commit 83b808c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/renderer/markup/ast-converter/shared/constraint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { convertType } from "unwritten:renderer/markup/ast-converter/shared/type";
import { registerAnonymousAnchor } from "unwritten:renderer/markup/registry/registry";
import { createInlineTitleNode, createParagraphNode } from "unwritten:renderer/markup/utils/nodes";
import { createInlineTitleNode } from "unwritten:renderer/markup/utils/nodes";
import { spaceBetween } from "unwritten:renderer/markup/utils/renderer";
import { getTranslator } from "unwritten:renderer/markup/utils/translations";
import { isMultilineType } from "unwritten:renderer/markup/utils/types";
Expand All @@ -16,11 +16,9 @@ export function convertConstraintForType(ctx: MarkupRenderContext, type: Type) {
const { inlineType, multilineType } = convertType(ctx, type);

const inlineConstraint = !isMultilineType(type) || !multilineType
? createParagraphNode(
spaceBetween(
`${translate("constraint", { capitalize: true })}:`,
inlineType
)
? spaceBetween(
`${translate("constraint", { capitalize: true })}:`,
inlineType
)
: undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/markup/utils/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function renderEntityPrefix(ctx: MarkupRenderContext, target: "documentat

export function spaceBetween(...nodes: ASTNode[]) {
return nodes
.filter(node => !!node)
.filter(node => !!node && (!Array.isArray(node) || node.length > 0))
.reduce<ASTNode[]>((acc, node, index) => {
if(index > 0){
acc.push(" ", node);
Expand Down

0 comments on commit 83b808c

Please sign in to comment.