Skip to content

Commit

Permalink
fixed bug in to pretext file
Browse files Browse the repository at this point in the history
  • Loading branch information
renee-k committed Aug 11, 2024
1 parent b5cfa21 commit 11a5182
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export function toPretextWithLoggerFactory(
const titleTag = x("title", title?.flatMap(toPretext));

if (divisionName && title) {
return x(divisionName, [titleTag]);
return x(divisionName, [
titleTag,
...node.content.flatMap(toPretext),
]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
import { macroReplacements as _macroReplacements } from "./pre-conversion-subs/macro-subs";
import { streamingMacroReplacements } from "./pre-conversion-subs/streaming-command-subs";
import { unifiedLatexWrapPars } from "./unified-latex-wrap-pars";
import { breakOnBoundaries, isMappedEnviron } from "./pre-conversion-subs/break-on-boundaries";
import {
breakOnBoundaries,
isMappedEnviron,
} from "./pre-conversion-subs/break-on-boundaries";
import { reportMacrosUnsupportedByKatex } from "./pre-conversion-subs/report-unsupported-macro-katex";
import { htmlLike } from "@unified-latex/unified-latex-util-html-like";
import { getArgsContent } from "@unified-latex/unified-latex-util-arguments";
Expand Down Expand Up @@ -116,12 +119,11 @@ export const unifiedLatexToXmlLike: Plugin<

// Must be done *after* streaming commands are replaced.
// We only wrap PARs if we *need* to. That is, if the content contains multiple paragraphs
console.log(shouldBeWrappedInPars(tree));
if (shouldBeWrappedInPars(tree)) {
processor = processor.use(unifiedLatexWrapPars);
}
// *THIS CAUSES TITLE TO BE WRAPPED IN PARS
tree = processor.runSync(tree, file);
//console.log(printRaw(tree))

// Replace text-mode environments and then macros. Environments *must* be processed first, since
// environments like tabular use `\\` as a newline indicator, but a `\\` macro gets replaced with
Expand Down Expand Up @@ -154,7 +156,6 @@ export const unifiedLatexToXmlLike: Plugin<
return replacement;
}
});


// before replacing math-mode macros, report any macros that can't be replaced
const unsupportedByKatex = reportMacrosUnsupportedByKatex(tree);
Expand Down Expand Up @@ -211,7 +212,7 @@ function shouldBeWrappedInPars(tree: Ast.Root): boolean {
return EXIT;
}
},
{ test: (node) => match.environment(node, "document") || isMappedEnviron(node) }
{ test: (node) => match.environment(node, "document") }
);

return content.some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ describe("unified-latex-to-pretext:unified-latex-to-pretext", () => {

ast = process(`\\paragraph{Important.} Paragraph`);
expect(normalizeHtml(ast)).toEqual(
normalizeHtml(`
<pargraphs><title>Important.</title> Paragraph</paragraphs>
`)
normalizeHtml(
`<paragraphs><title>Important.</title> Paragraph</paragraphs>`
)
);
});
it("custom replacers work", () => {
Expand Down

0 comments on commit 11a5182

Please sign in to comment.