Skip to content

[WIP] Improving formatting of valid chemical formulae #1121

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Apr 13, 2025

For now, this PR simply starts listing some rules on chemical formulae formatting that we can follow eventually, e.g.:

    chemFormulaFormat() {
      // Need to capture several groups, if the overall format doesn't apply, then
      // there should be no additional formatting whatsoever
      //
      // Some rules:
      //
      // * numbers between element symbols need to be subscripted, including "." and variables like "x"
      //    - e.g., Na3P => Na<sub>3</sub>P, Na3+xP => Na<sub>3+x</sub>P
      // * charges need to be handled separately and superscripted
      //    - e.g., Na+Cl- => Na<sup>+</sup>Cl<sup>-</sup>
      // * empirical labels for formula units like [pyr] must be left alone
      // * dots, when not used within numbers, must be treated as an interpunct "dot product" style dot
      //     - e.g., Cu2SO4.H2O => Cu<sub>2</sub>SO<sub>4</sub> · H<sub>2</sub>O

I think many of these can be handled selectively with some judicious regexes, and beyond formatting, the same rules could be used to validate e.g., empirical formulae in JS used for computing yields and the like.

Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.28%. Comparing base (c80ea21) to head (b386ed4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1121   +/-   ##
=======================================
  Coverage   70.28%   70.28%           
=======================================
  Files          63       63           
  Lines        4133     4133           
=======================================
  Hits         2905     2905           
  Misses       1228     1228           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

cypress bot commented Apr 13, 2025

datalab    Run #3102

Run Properties:  status check failed Failed #3102  •  git commit 71b95bb36e ℹ️: Merge b386ed46e624a5d7e3582628c262114b72ccd319 into c80ea21160faab435a06b3675b6d...
Project datalab
Branch Review ml-evs/chemform
Run status status check failed Failed #3102
Run duration 04m 51s
Commit git commit 71b95bb36e ℹ️: Merge b386ed46e624a5d7e3582628c262114b72ccd319 into c80ea21160faab435a06b3675b6d...
Committer Matthew Evans
View all properties for this run ↗︎

Test results
Tests that failed  Failures 3
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 144
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (firefox)

View Output

Test Artifacts
Edit Page > Checks editing the sample edit page Screenshots
Failed  cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (chrome)

View Output

Test Artifacts
Edit Page > Checks editing the sample edit page Test Replay Screenshots
Failed  cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (electron)

View Output

Test Artifacts
Edit Page > Checks editing the sample edit page Test Replay Screenshots

@ml-evs ml-evs modified the milestones: v0.6.x, v0.7.x May 20, 2025
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.

1 participant