diff --git a/bin/confluence.js b/bin/confluence.js index 13afadd..334c94d 100755 --- a/bin/confluence.js +++ b/bin/confluence.js @@ -2200,7 +2200,7 @@ program const { convert: htmlToText } = require('html-to-text'); output = htmlToText(input, { wordwrap: 130 }); } else if (options.inputFormat === 'html' && options.outputFormat === 'markdown') { - output = converter.storageToMarkdown(input); + output = converter.htmlToMarkdown(input); } else if (options.inputFormat === 'markdown' && options.outputFormat === 'text') { const html = converter.markdown.render(input); const { convert: htmlToText } = require('html-to-text'); diff --git a/tests/convert.test.js b/tests/convert.test.js index fd96b48..c96c21c 100644 --- a/tests/convert.test.js +++ b/tests/convert.test.js @@ -95,6 +95,19 @@ describe('convert command', () => { expect(output).toContain('bold'); }); + test('html to markdown preserves fenced code blocks with language', () => { + // Multi-line
is the discriminating case
+ // between htmlToMarkdown and storageToMarkdown: the former emits a
+ // fenced block with the language tag, the latter collapses the body
+ // into inline `code` and drops the language. This test fails if the
+ // html → markdown path is ever routed back through storageToMarkdown.
+ const html = 'bold
\nconst x = 1;\nconst y = 2;
';
+ const inputFile = writeInput('input.html', html);
+ const output = run(['convert', '--input-file', inputFile, '--input-format', 'html', '--output-format', 'markdown']);
+ expect(output).toContain('**bold**');
+ expect(output).toMatch(/```js\nconst x = 1;\nconst y = 2;\n```/);
+ });
+
test('storage to text', () => {
const inputFile = writeInput('input.xml', 'Title
Content
');
const output = run(['convert', '--input-file', inputFile, '--input-format', 'storage', '--output-format', 'text']);