Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimdemedes committed Sep 1, 2023
1 parent 0ee8e89 commit a5b407d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 12 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,13 @@ For example, to implement a hanging indent component, you can indent all the lin
import {render, Transform} from 'ink';

const HangingIndent = ({content, indent = 4, children, ...props}) => (
<Transform transform={(line, index) =>
index === 0 ? line : (' '.repeat(indent) + line)} {...props}>
{children}
<Transform
transform={(line, index) =>
index === 0 ? line : ' '.repeat(indent) + line
}
{...props}
>
{children}
</Transform>
);

Expand All @@ -1396,7 +1400,11 @@ const text =
'present I am a sojourner in civilized life again.';

// Other text properties are allowed as well
render(<HangingIndent bold dimColor indent={4}>{text}</HangingIndent>);
render(
<HangingIndent bold dimColor indent={4}>
{text}
</HangingIndent>
);
```

#### transform(outputLine, index)
Expand Down
6 changes: 5 additions & 1 deletion src/squash-text-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const squashTextNodes = (node: DOMElement): string => {

for (let index = 0; index < node.childNodes.length; index++) {
const childNode = node.childNodes[index];
if (childNode === undefined) continue;

if (childNode === undefined) {
continue;
}

let nodeText = '';

if (childNode.nodeName === '#text') {
Expand Down

0 comments on commit a5b407d

Please sign in to comment.