Skip to content

Commit 283790e

Browse files
committed
fix(html-elements): callouts don't render correctly in markdown view
1 parent 61cefa7 commit 283790e

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/lib/data-conversion/json-to-x/json-to-html-element.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { ginkgo_welcome } from 'src/lib/data-conversion/test-data/ginkgo_welcome
66
import { ginkgo_academic_paper } from 'src/lib/data-conversion/test-data/ginkgo_acedemic_paper';
77
import { html_element_conflicting_elements } from 'src/lib/data-conversion/test-data/html-element-conflicting-elements';
88
import { htmlCommentToJson } from 'src/lib/data-conversion/x-to-json/html-comment-to-json';
9+
import { htmlElementToJson } from 'src/lib/data-conversion/x-to-json/html-element-to-json';
10+
import { jsonToHtmlComment } from './json-to-html-comment';
911

1012
describe('json to html element', () => {
1113
it('case 1', () => {
@@ -150,4 +152,26 @@ describe('json to html element', () => {
150152
const output = ['#🙄' + createHtmlElementMarker('', 1) + ' text'];
151153
expect(jsonToHtmlElement(input)).toEqual(output.join('\n'));
152154
});
155+
156+
it('html comments matches html elements', () => {
157+
const pairs = [
158+
[
159+
html_element_conflicting_elements.mdWithHtmlComment,
160+
html_element_conflicting_elements.mdWithHtmlElement,
161+
],
162+
[
163+
ginkgo_academic_paper.annotatedMd,
164+
ginkgo_academic_paper.mdWithHtmlElement,
165+
],
166+
];
167+
for (const [htmlComments, htmlElements] of pairs) {
168+
const jsonFromHtmlElements = htmlElementToJson(htmlElements);
169+
const jsonFromHtmlComments = htmlCommentToJson(htmlComments);
170+
const toHtmlElement = jsonToHtmlElement(jsonFromHtmlElements);
171+
const toHtmlComment = jsonToHtmlComment(jsonFromHtmlComments);
172+
expect(jsonFromHtmlElements).toEqual(jsonFromHtmlComments);
173+
expect(toHtmlElement).toEqual(htmlElements);
174+
expect(toHtmlComment).toEqual(htmlComments);
175+
}
176+
});
153177
});

src/lib/data-conversion/json-to-x/json-to-html-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const jsonToHtmlElement = (
2424
const tag = content.match(/^#[^\s#\uFEFF\u200B]+/)?.[0];
2525
content = `${tag}${marker}${content.slice(tag!.length)}`;
2626
} else if (content.startsWith('>')) {
27-
content = `> ${marker}${content.slice(1).trim()}`;
27+
content = `${marker}\n${content}`;
2828
} else if (content.match(/^[-*+]\s\[.\]\s/)) {
2929
// tasks
3030
const taskPrefix = content.match(/^[-*+]\s\[.\]\s/)?.[0];

src/lib/data-conversion/test-data/ginkgo_welcome.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,17 @@ The same happens with *expert writers*. They start off only being really think a
412412
413413
**Gingko Writer is explicitly designed to allow you to think like this**, no matter what your skill level is.
414414
415-
> <span data-section="1.1.1.1.1"/>"As, therefore, in the case of animate bodies and organisms a certain magnitude is necessary, and a magnitude which may be easily embraced in one view; so in the plot, a certain length is necessary, and a length which can be easily embraced by the memory."
415+
<span data-section="1.1.1.1.1"/>
416+
> "As, therefore, in the case of animate bodies and organisms a certain magnitude is necessary, and a magnitude which may be easily embraced in one view; so in the plot, a certain length is necessary, and a length which can be easily embraced by the memory."
416417
<div style="text-align:right;">— *Aristotle, Poetics VII*</div>
417418
418419
#### <span data-section="1.1.1.2"/>Levels of Detail - Sculpting Your Ideas
419420
By being able to see your work from many different "levels of detail" (big picture → smallest detail), you're able to shift your attention to where it needs to be at any given moment.
420421
421422
Once you've learned how to use Gingko Writer fluidly, writing becomes less about grinding through from start to end, and more like **sculpting your ideas**.
422423
423-
> <span data-section="1.1.1.2.1"/>"That goal will become clearer, will emerge slowly but surely, much as the rough draught turns into a sketch, and the sketch into a painting through the serious work done on it, through the elaboration of the original vague idea and through the consolidation of the first fleeting and passing thought."
424+
<span data-section="1.1.1.2.1"/>
425+
> "That goal will become clearer, will emerge slowly but surely, much as the rough draught turns into a sketch, and the sketch into a painting through the serious work done on it, through the elaboration of the original vague idea and through the consolidation of the first fleeting and passing thought."
424426
<div style="text-align:right;">— *Vincent van Gogh*</div>
425427
426428
### <span data-section="1.1.2"/>Specific Use-cases

src/lib/data-conversion/test-data/html-element-conflicting-elements.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ display: none;
1414
}
1515
\`\`\`
1616
17-
> <span data-section="5"/>quote
17+
<span data-section="5"/>
18+
> quote
1819
1920
<span data-section="6"/>
2021
2122
| a | b |
2223
| --- | --- |
2324
| 1 | 2 |
2425
25-
> <span data-section="7"/>[!info]
26+
<span data-section="7"/>
27+
> [!info]
2628
> information
2729
2830
<span data-section="8"/><!--comment -->`;

0 commit comments

Comments
 (0)