Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: various metadata preservation issues (boxing, LaTeX-parsing)#212

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
samueltlg wants to merge7 commits intocortex-js:main
base:main
Choose a base branch
Loading
fromsamueltlg:fix-verbatim-latex

Conversation

@samueltlg
Copy link
Contributor

@samueltlgsamueltlg commentedOct 24, 2024
edited
Loading

Noticed thatverbatimLatex not being saved on BoxedExpression instances created fromce.parse for some time. Looks as if this traceable to commits:

cd557e5 - 'arch: changed JSON canonical format, APIs for serialization to LaTeX and MathJSON' (2024-06-25)

^Wherein there is retraction of passing of 'metadata' toce.box from withince.parse
And:

e1f9e19 - 'arch' (2024-09-25)

^In which 'metadata' is retracted both as an argument to 'box' (the function) and its inner forwarding to BoxedExpression constructor calls when handling 'MathJSON object literals'.

As a guess, it appears to me that removingmetadata as a parameter frombox was apt due to these properties being foreseen as present on MathJSON object literals: if present at all. Looks however that in these changes that the step of checking for this meta elsewhere (i.e. object literals) and forwarding onwards (like before) is absent.
This 'fix' is only an educated guess & seems to address the issue,

But this change/request also appears tobreak a single test-case withintest/compute-engine/latex-syntax/numbers.test.ts - which I have not investigated - and thus is not suitable for merging.
(Note at the time of this request, the HEAD of main (#115272d, there is already extant a single test failure (test/compute-engine/functions.test.ts ->Apply -> Function and Hold), which is not related to this change).

Single commit also includes an unused utilityisExpressionObject, which was initially used, but could now be discarded.

(Could also do with a couple of test cases for this feature)

@arnog
Copy link
Member

On first reading, this looks like a good PR. Curious to see which test case breaks because of it.

samueltlg reacted with thumbs up emoji

Previously:```ce.parse("\text{string}", {preserveLatex: true})//-> Error(ErrorCode(invalid-identifier, invalid-first-char), "\text{'string'}")```With this fix, output from this previous parse-op. is as expected,('string')
@samueltlgsamueltlg changed the titlefix: preservation of (verbatim) latexfix: issues parsing with 'preserveLatex' set to 'true'Oct 30, 2024
samueltlgand others added2 commitsOctober 30, 2024 12:17
`ce.parse("\text{string}", {preserveLatex: true})` now results in aboxed-expression with string 'string' in contrast to ''string''
@arnog
Copy link
Member

The PR is still a draft, and therefore cannot be merged. Let me know when it's ready for review.

@samueltlg
Copy link
ContributorAuthor

The PR is still a draft, and therefore cannot be merged. Let me know when it's ready for review.

Apologies; I did think it was already ready to be merged.

I just did some investigation into why the breaking test-case, & I think it appears that everything is otherwise fine.
The reason for this particular matcher failure is because parsing of '1.0' with functionparseVal within 'compute-engine/latex-syntax/numbers.test.ts', when parsing this with meta-data (now the default), results in this being a number (ExactNumericValue, to be precise), rather than a 'ce.one' instance. Consequently, throughparseVal, the string-form of its numericValue is returned being "1", rather than the expected number-literal 1; so maybe just a little tweak somewhere.

Just marking it as ready, anyway

@samueltlgsamueltlg marked this pull request as ready for reviewNovember 7, 2024 14:37
-Consequently, as would be expected, allows usage of engine-scopedcommon symbols (ce.One, et cetera) in some scenarios (instead ofneedlessly missing out), fixing some test cases predicated upon thisalong the way
-*should result in correct preservation of metadata (latex,wikidata) insome scenarios: such as number boxing (ce.number), and some cases offunction boxing ('box', 'boxFunction') - wherever explicitly given.
@samueltlg
Copy link
ContributorAuthor

Good that this has not been merged yet! - detected a couple more related issues.
One of the commits addresses the failing numeric tests: in simple terms, not passing around empty 'metadata' permits usage of engine-scoped common symbols (-the reason for the failures being differing serialization, or number casting, between ce.One (et cetera) and equivalent 'ExactNumericValue's.)

@samueltlgsamueltlg changed the titlefix: issues parsing with 'preserveLatex' set to 'true'fix: various metadata preservation issues (boxing, LaTeX-parsing)Dec 13, 2024
latex?:string|undefined;
wikidata?:string|undefined;
};
exporttypeMetadata=Pick<Attributes,'latex'|'wikidata'>;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

May wish to revert this: personally just thought it made sense.

_fn(
name:MathJsonIdentifier,
ops:ReadonlyArray<BoxedExpression>,
options?:Metadata&{canonical?:boolean}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Quite sure that that was a mistake, or at least non-desirable

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@samueltlg@arnog

[8]ページ先頭

©2009-2025 Movatter.jp