Skip to content

Commit

Permalink
remove params to load function
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed Oct 25, 2024
1 parent b8f21c8 commit 21e2897
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
14 changes: 2 additions & 12 deletions src/api/embedsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ const fetchConceptVisualElement = async (
opts: TransformOptions,
): Promise<ConceptVisualElementMeta | undefined> => {
if (!visualElement) return undefined;
const html = load(visualElement, {
xmlMode: false,
decodeEntities: false,
});
const html = load(visualElement, {});
const embed = getEmbedsFromContent(html)[0];
if (!embed) return undefined;
const res = await transformEmbed(embed, context, index + 0.1, 0, {
Expand Down Expand Up @@ -325,14 +322,7 @@ const endsWithPunctuationRegex = /[.!?]$/;
export const parseCaption = (caption: string): string => {
const htmlCaption = parseMarkdown({ markdown: caption, inline: true });

const parsedCaption = load(
htmlCaption,
{
xmlMode: false,
decodeEntities: false,
},
false,
);
const parsedCaption = load(htmlCaption, {}, false);

const lastTextNode = parsedCaption.root().contents().last();

Expand Down
10 changes: 2 additions & 8 deletions src/api/resourceEmbedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ export const fetchResourceEmbed = async (
const embedHtml = toEmbedHtml(embed);

const content = toHtml(embedHtml);
const html = load(content, {
xmlMode: false,
decodeEntities: false,
});
const html = load(content, {});
const embeds = getEmbedsFromContent(html)[0];
if (!embeds) {
throw new Error("No embeds found");
Expand All @@ -133,10 +130,7 @@ export const fetchResourceEmbeds = async ({ resources }: GQLQueryResourceEmbedsA
const embeds = resources.map((params) => toEmbed(params)).filter((embed) => !!embed);
const content = embeds.map((embed) => toEmbedHtml(embed!)).join("");
const bodyString = toHtml(content);
const html = load(bodyString, {
xmlMode: false,
decodeEntities: false,
});
const html = load(bodyString, {});
const embedsFromContent = getEmbedsFromContent(html);

const embedPromises = await Promise.all(
Expand Down
13 changes: 2 additions & 11 deletions src/api/transformArticleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ export const transformArticle = async (
visualElement: string | undefined,
{ subject, previewH5p, showVisualElement, draftConcept, absoluteUrl, prettyUrl }: TransformArticleOptions,
) => {
const html = load(content, {
xmlMode: false,
decodeEntities: false,
});
const html = load(content, {});
html("math").each((_, el) => {
html(el)
.attr("data-math", html(el).html() ?? "")
Expand All @@ -123,13 +120,7 @@ export const transformArticle = async (
html("body").prepend(`<section>${visualElement}</section>`);
}

const visEl =
visualElement && !showVisualElement
? load(`${visualElement}`, {
xmlMode: false,
decodeEntities: false,
})
: undefined;
const visEl = visualElement && !showVisualElement ? load(`${visualElement}`, {}) : undefined;

const embeds = visEl ? getEmbedsFromContent(visEl).concat(getEmbedsFromContent(html)) : getEmbedsFromContent(html);

Expand Down

0 comments on commit 21e2897

Please sign in to comment.