Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

📚 Allow multiple pages in typst export #844

Merged
merged 1 commit into from
Jan 11, 2024
Merged

📚 Allow multiple pages in typst export #844

merged 1 commit into from
Jan 11, 2024

Conversation

rowanc1
Copy link
Member

@rowanc1 rowanc1 commented Jan 11, 2024

This allows for multi-page exports for typst

Comment on lines 31 to +32
ExportFormats.tex,
ExportFormats.typst,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fwkoch I am not actually sure we should add this, can you confirm?

@@ -261,12 +262,13 @@ export async function localArticleToTypstTemplated(
const includeFileBases = results.map((result, ind) => {
const base = `${name}-${content[ind]?.slug ?? ind}${ext}`;
const includeFile = path.format({ dir, ext, base });
writeFileToFolder(includeFile, result.value);
const exports = renderTypstImports(false, collected);
writeFileToFolder(includeFile, `${versionString}\n\n${exports}\n\n${result.value}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typst exports on different pages need to also have imports in each page.

@@ -29,6 +29,7 @@ export async function resolvePageExports(session: ISession, file: string) {
ExportFormats.docx,
ExportFormats.pdf,
ExportFormats.tex,
ExportFormats.typst,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to the site 👍

@@ -3,18 +3,18 @@ import type { TypstTemplateImports } from '../types.js';
import { writeFileToFolder } from 'myst-cli-utils';

export function renderTypstImports(
output: string,
output: string | false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this stops writing myst.typ multiple times for multi-page export. Shouldn't be false in other cases.

writeFileToFolder(mystTypst, macros.join('\n\n'));
}
importStatements.push('#set math.equation(numbering: "(1)")');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this moved to the template?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@@ -261,12 +262,13 @@ export async function localArticleToTypstTemplated(
const includeFileBases = results.map((result, ind) => {
const base = `${name}-${content[ind]?.slug ?? ind}${ext}`;
const includeFile = path.format({ dir, ext, base });
writeFileToFolder(includeFile, result.value);
const exports = renderTypstImports(false, collected);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, a bit tedious we have to add these here, but they get added to the main page during render... but makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was a bit suprised.

@rowanc1 rowanc1 merged commit 9178a21 into main Jan 11, 2024
4 checks passed
@rowanc1 rowanc1 deleted the typst/multi branch January 11, 2024 22:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants