e.stopPropagation()}>
{/* Left: Login Form */}
@@ -257,6 +324,21 @@ export const LoginModal = ({ isOpen, onClose, onLoginSuccess }) => {
+
{renderMarkdown(readmeContent)}
From fc8638e62292d3b66f71f4af8818ae48a169843f Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Thu, 8 Jan 2026 03:45:07 +0000
Subject: [PATCH 2/2] feat: enhance markdown parser indentation logic
- Implement 'Header + 1 Step' indentation rule for non-header content.
- Update Markdown parser in `LoginModal.jsx` to track context via `contentIndentClass`.
- Ensure headers set correct indentation context (H1/H2 -> ml-4, H3 -> ml-8, H4 -> ml-12).
- Apply indentation to paragraphs, blockquotes, and list containers.
- Verify logic with `verify_indent.js` test script.
---
src/components/LoginModal.jsx | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/src/components/LoginModal.jsx b/src/components/LoginModal.jsx
index 262b4ac..52dc89c 100644
--- a/src/components/LoginModal.jsx
+++ b/src/components/LoginModal.jsx
@@ -10,6 +10,13 @@ const renderMarkdown = (text) => {
const elements = [];
let listBuffer = [];
+ // Track context for indentation of non-header content
+ // Default (start/after H1): ml-4
+ // After H2 (ml-0): ml-4
+ // After H3 (ml-4): ml-8
+ // After H4 (ml-8): ml-12
+ let contentIndentClass = 'ml-4';
+
// Helper to parse inline styles (Bold and Links)
const parseInline = (text) => {
if (!text) return { __html: '' };
@@ -63,8 +70,9 @@ const renderMarkdown = (text) => {
);
};
+ // Apply the current content indentation to the list container
elements.push(
-
+
{renderTree(roots)}
);
@@ -72,7 +80,7 @@ const renderMarkdown = (text) => {
};
for (let i = 0; i < lines.length; i++) {
- const line = lines[i]; // Do not trim globally yet, need to preserve indent
+ const line = lines[i];
const trimmed = line.trim();
// Empty line: flush list
@@ -89,9 +97,10 @@ const renderMarkdown = (text) => {
}
// Headers
- // H1
+ // H1: Centered. Next content indent: ml-4 (Step 1)
if (line.match(/^#\s/)) {
flushList();
+ contentIndentClass = 'ml-4';
elements.push(
{line.substring(2).trim()}
@@ -99,9 +108,10 @@ const renderMarkdown = (text) => {
);
continue;
}
- // H2
+ // H2: ml-0 (Step 0). Next content indent: ml-4 (Step 1)
if (line.match(/^##\s/)) {
flushList();
+ contentIndentClass = 'ml-4';
elements.push(
{line.substring(3).trim()}
@@ -109,9 +119,10 @@ const renderMarkdown = (text) => {
);
continue;
}
- // H3
+ // H3: ml-4 (Step 1). Next content indent: ml-8 (Step 2)
if (line.match(/^###\s/)) {
flushList();
+ contentIndentClass = 'ml-8';
elements.push(
{line.substring(4).trim()}
@@ -119,9 +130,10 @@ const renderMarkdown = (text) => {
);
continue;
}
- // H4
+ // H4: ml-8 (Step 2). Next content indent: ml-12 (Step 3)
if (line.match(/^####\s/)) {
flushList();
+ contentIndentClass = 'ml-12';
elements.push(
{line.substring(5).trim()}
@@ -131,33 +143,28 @@ const renderMarkdown = (text) => {
}
// List Items (- or *)
- // Capture indentation (group 1), marker (group 2), content (group 3)
const listMatch = line.match(/^(\s*)([-*])\s+(.+)$/);
if (listMatch) {
const indent = listMatch[1].length;
const content = listMatch[3];
- // Normalize indent: assume 2 spaces per level approx, or just use raw count
- // We will rely on relative comparison in tree builder.
listBuffer.push({ level: indent, content });
continue;
}
- // If we are here, it's not a list item. Flush any existing list.
+ // Flush list if we encounter non-list content
flushList();
// Blockquotes
if (trimmed.startsWith('> ')) {
elements.push(
-
+
);
continue;
}
// Paragraph
- // For simple parsing, just render as P.
- // Preserve some indentation? No, usually P are just text blocks.
elements.push(
-
+
);
}