Skip to content

Commit 7a1e15d

Browse files
authored
fix: markdown single lines (#7002)
Reverts a change makes in #6969 which breaks a lot of markdown. Fixes #6997
1 parent 6b5500e commit 7a1e15d

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

packages/smart-cells/src/__tests__/markdown-parser.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,13 @@ Count: {str(data["items"][0]["count"])}`.trim(),
119119
quotePrefix: "",
120120
});
121121
expect(pythonCode).toMatchInlineSnapshot(`
122-
"mo.md(
123-
"""
122+
"mo.md("""
124123
# Markdown Title
125124
126125
Some content here.
127-
"""
128-
)"
126+
""")"
129127
`);
130-
expect(offset).toBe(16);
128+
expect(offset).toBe(11);
131129
});
132130

133131
it("should preserve r-string prefix", () => {
@@ -146,12 +144,10 @@ Count: {str(data["items"][0]["count"])}`.trim(),
146144
quotePrefix: "f",
147145
});
148146
expect(pythonCode).toMatchInlineSnapshot(`
149-
"mo.md(
150-
f"""
147+
"mo.md(f"""
151148
# Title
152149
{some_variable}
153-
"""
154-
)"
150+
""")"
155151
`);
156152
});
157153

packages/smart-cells/src/parsers/markdown-parser.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,7 @@ export class MarkdownParser implements LanguageParser<MarkdownMetadata> {
114114
// If it's one line and not bounded by quotes, write it as single line
115115
const isOneLine = !code.includes("\n");
116116
const boundedByQuote = code.startsWith('"') || code.endsWith('"');
117-
const startQuote = `${quotePrefix}"""`;
118117
if (isOneLine && !boundedByQuote) {
119-
const markdown = `${startQuote}${escapedCode}"""`;
120-
const prefix = "mo.md(";
121-
if (markdown.length >= 80 - prefix.length) {
122-
// Single lines are broken up if they exceed line length
123-
const start = `${prefix}"\n ${startQuote}`;
124-
return {
125-
code: `${start}${escapedCode}"""\n)`,
126-
offset: start.length,
127-
};
128-
}
129118
const start = `mo.md(${quotePrefix}"""`;
130119
const end = `""")`;
131120
return { code: start + escapedCode + end, offset: start.length };

0 commit comments

Comments
 (0)