Skip to content

Commit 5523d80

Browse files
authored
Merge pull request #9 from manmeet231/fix/added-extra-indents
added extra indents after the code ends , if the code is shorter than minLines
2 parents 9bb1d88 + 4ac632e commit 5523d80

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/components/InteractivePython

src/components/InteractivePython/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ export default function InteractivePython({ children }) {
99
const { siteConfig } = useDocusaurusContext();
1010
const baseUrl = siteConfig.baseUrl;
1111

12-
const initialCode = children?.props?.children?.trim() || '';
12+
const rawCode = children?.props?.children?.trim() || '';
13+
const lines = rawCode.split('\n').length;
14+
const minLines = 5;
15+
16+
const initialCode =
17+
lines < minLines
18+
? rawCode + '\n'.repeat(minLines - lines)
19+
: rawCode;
1320
const [code, setCode] = useState(initialCode);
1421
const [isRunning, setIsRunning] = useState(false);
1522

0 commit comments

Comments
 (0)