Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Convert backgroundImage dimensions to numbers during parsing #1923

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

benchristel
Copy link
Member

Issue: LEMS-2582

Test plan:

yarn test

@benchristel benchristel self-assigned this Nov 27, 2024
@khan-actions-bot khan-actions-bot requested a review from a team November 27, 2024 17:53
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Nov 27, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/smooth-taxis-mate.md, packages/perseus/src/util/parse-perseus-json/general-purpose-parsers/string-to-number.test.ts, packages/perseus/src/util/parse-perseus-json/general-purpose-parsers/string-to-number.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/perseus-image-background.ts, packages/perseus/src/util/parse-perseus-json/regression-tests/data/interactive-graph-with-string-backgroundImage-left.json

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Nov 27, 2024

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (74aa161) and published it to npm. You
can install it using the tag PR1923.

Example:

yarn add @khanacademy/perseus@PR1923

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR1923

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Size Change: +71 B (+0.01%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 422 kB +71 B (+0.02%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 77.9 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 698 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.68 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@benchristel benchristel changed the base branch from benc/inline-version-in-expression-widget-parser to main November 27, 2024 17:57
An error occurred while trying to automatically change base from benc/inline-version-in-expression-widget-parser to main November 27, 2024 17:57
@benchristel benchristel force-pushed the benc/parse-backgroundImage-numbers branch from 72ecdd0 to 73648ba Compare November 27, 2024 17:58
Comment on lines +15 to +17
const numericToNumber = pipeParsers(union(number).or(string).parser).then(
stringToNumber,
).parser;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why we need to union number or string and then pass that result through stringToNumber. Doesn't stringToNumber handle parsing a string or number within itself already?

@@ -0,0 +1,17 @@
import type {PartialParser} from "../parser-types";

export const stringToNumber: PartialParser<string | number, number> = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sadly, there is more than one place where Perseus data contains both actual numbers and stringified numbers.

No action needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants