Merge pull request #34145 from overleaf/ds-download-html-using-pandoc-clsi-1

[CLSI] Download as HTML feature

GitOrigin-RevId: 374101c1f957a00eda423a6be0363c08b5de7a95
This commit is contained in:
Mathias Jakobsen
2026-06-04 11:43:52 +01:00
committed by Copybot
parent 0501586743
commit fc31a88767
4 changed files with 63 additions and 0 deletions
@@ -19,6 +19,7 @@ import { z } from '@overleaf/validation-tools'
const CONVERSION_CONFIGS = {
docx: { extension: 'docx' },
markdown: { extension: 'zip' },
html: { extension: 'zip' },
}
async function convertDocumentToLaTeX(req, res) {
+13
View File
@@ -162,6 +162,19 @@ const LATEX_EXPORT_CONFIGS = {
'markdown',
],
},
html: {
fileExtension: 'html',
compressOutput: true,
getPandocArgs: ({ outputPath }) => [
'--output',
outputPath,
'--from',
'latex',
'--to',
'html',
'--standalone',
],
},
}
async function convertLaTeXToDocumentInDirWithLock(
@@ -592,6 +592,37 @@ describe('ConversionController', function () {
})
})
describe('with conversionType=html', function () {
beforeEach(async function (ctx) {
ctx.req.query = { type: 'html' }
ctx.fs.stat.resolves(ctx.documentStat)
await ctx.ConversionController.convertProjectToDocument(
ctx.req,
ctx.res,
sinon.stub()
)
})
it('should call convertLaTeXToDocumentInDirWithLock with type=html', function (ctx) {
sinon.assert.calledWith(
ctx.ConversionManager.promises.convertLaTeXToDocumentInDirWithLock,
sinon.match(
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
),
sinon.match(
/^\/compiles\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
),
'main.tex',
'html'
)
})
it('should set the attachment filename with .zip extension', function (ctx) {
sinon.assert.calledWith(ctx.res.attachment, 'output.zip')
})
})
describe('when conversion fails', function () {
beforeEach(async function (ctx) {
ctx.next = sinon.stub()
@@ -77,6 +77,24 @@ const LATEX_TO_DOCUMENT_CASES = [
'--extract-media=.',
],
},
{
type: 'html',
extension: 'html',
compressOutput: true,
pandocArgs: outputId => [
'pandoc',
Path.join('..', 'main.tex'),
'--output',
'main.html',
'--from',
'latex',
'--to',
'html',
'--standalone',
'--resource-path=..',
'--extract-media=.',
],
},
]
describe('ConversionManager', function () {