Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix(export): keep a multi-line title inside the markdown heading

davbio337d5c582d31
diff --git a/src/core/export/__tests__/markdown-export.test.ts b/src/core/export/__tests__/markdown-export.test.ts
index 16a34df..fcf39ab 100644
--- a/src/core/export/__tests__/markdown-export.test.ts
+++ b/src/core/export/__tests__/markdown-export.test.ts
@@ -45,6 +45,12 @@ function makeScreenshot(stepId: string, content = 'img'): Screenshot {
}
describe('exportGuideAsMarkdown', () => {
+ it('keeps a legacy multi-line title inside the H1', async () => {
+ const md = await exportGuideAsMarkdown(makeGuide({ title: 'Set up\nyour profile' }), [], new Map());
+ expect(md).toContain('# Set up your profile');
+ expect(md.split('\n')[0]).toBe('# Set up your profile');
+ });
+
it('creates valid markdown with H1 title', async () => {
const guide = makeGuide({ title: 'My Guide' });
const steps = [makeStep()];
diff --git a/src/core/export/markdown-export.ts b/src/core/export/markdown-export.ts
index 53da7d7..cad347d 100644
--- a/src/core/export/markdown-export.ts
+++ b/src/core/export/markdown-export.ts
@@ -1,6 +1,7 @@
import { i18n } from '#imports';
import { blobToBase64, extractDomain, formatDate } from '@/core/export/utils';
import { actionSteps, isBlock, stepNumbers, variantLabel } from '@/core/guides/blocks';
+import { sanitizeGuideTitle } from '@/core/guides/title';
import type { Guide, Screenshot, Step } from '@/core/guides/types';
import { renderScreenshot } from '@/core/screenshot/render';
@@ -24,7 +25,7 @@ export async function exportGuideAsMarkdown(
...(domain ? [i18n.t('export.sourceLabel', [domain])] : []),
].join(' Β· ');
- const lines: string[] = [`# ${guide.title}`, ''];
+ const lines: string[] = [`# ${sanitizeGuideTitle(guide.title)}`, ''];
if (guide.description) lines.push(guide.description, '');
lines.push(`*${meta}*`, '', '---', '');