Skip to content

Commit

Permalink
ndlaskip is the magic word
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed May 16, 2024
1 parent 36fdf09 commit 001a489
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/server/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ const doFetch = (name: string, element: ApiTranslateType): Promise<ResponseType>
const formData = new FormData();
const html = load(`${element.content}`);
html("span[lang]").each((_, el) => {
html(el).wrap("<ndskip></ndskip>");
html(el).wrap("<ndlaskip></ndlaskip>");
});
html("math").each((_, el) => {
html(el).wrap("<ndskip></ndskip>");
html(el).wrap("<ndlaskip></ndlaskip>");
});
const buffer = Buffer.from(html.html());
const params = { stilmal };
console.log(html.html());

formData.append("file", buffer, { filename: `${name}.html` });
return fetch(`${htmlUrl}?${queryString.stringify(params)}`, {
Expand All @@ -82,11 +81,10 @@ const doFetch = (name: string, element: ApiTranslateType): Promise<ResponseType>
.then((res) => res.text())
.then(async (res) => {
const response = load(res);
response("ndskip").each((_, el) => {
response("ndlaskip").each((_, el) => {
response(el).contents().unwrap();
});
const strippedResponse = response("body").unwrap().html() ?? "";
//const strippedResponse = res.replace("<html>", "").replace("</html>", "");
return { key: name, value: strippedResponse };
});
}
Expand Down

0 comments on commit 001a489

Please sign in to comment.