English | 简体中文
Table of Contents
Render the chemical formula of SVG format in the browser, using the accurate Cuiping formula syntax.
You can try the demo at icelava.top.
- Try to input Cuiping formula and view rendered results in real time
- Save the formulas you tried to browser
- Modify the rendering configuration at any time
- Check some preset examples and edit them
- Hover over the rendering result to zoom, copy Cuiping formula or download SVG images
- Support syntax highlighting of Cuiping Formula
- Support auto-completion of Refs and Attributes
- Support going to definition of Refs (Ctrl-Click or Right Click >
Go To Definition) - Support marking Groups (Ctrl-M or Right Click >
Toggle Group Mark)
- Hover on the output and click
SVGin the pop-up toolbar to download vector graph. - To get non-vector images (e.g. for PPT), turn on the
Use Imageoption in configuration, then you can copy or save the image by right-clicking them.
| Options | Type | Description |
|---|---|---|
useMonacoEditor |
boolean | Whether to use Monaco Editor |
useImage |
boolean | Whether to render to PNG instead of SVG |
imageScale |
number | Scale of the image, only when useImage is on. Larger scale makes the image clearer |
| Param | Description |
|---|---|
debug |
Enable debug |
nohistory |
Do not display the history |
noexamples |
Do not display examples |
-
Use your familiar package manager to install the core package
cuiping.$ pnpm i cuiping $ yarn add cuiping $ npm i cuiping
-
Use TypeScript.
import { render } from 'cuiping' const molecule = getMolecule() // Assume to obtain Cuiping formula from user input. const data = render(molecule, { onError: err => { console.warn(err) // Handling errors. }, renderer: 'svg', // Only SVG rendering mode is supported currently. rendererOptions: { /*...*/ } // Render configuration, see below. }) if (data) { // SVG rendering results will be obtained if there is no error. showSvg(data.svg) // Show SVG to the user. }
| Options | Type | Description |
|---|---|---|
unitLen |
integer | Unit length |
paddingX |
integer | X padding |
paddingY |
integer | Y padding |
displayBonds |
boolean | Whether to display bonds |
bondGap |
integer | Gap between double/triple bonds |
lineBaseColor |
string | Base color of lines |
textBaseColor |
string | Base color of text |
displayBackground |
boolean | Whether to display background |
backgroundColor |
string | Background color |
halfFontSize |
integer | Half font size |
halfTextBoxWidth |
integer | Half width of text boxes |
halfTextBoxHeight |
integer | Half height of text boxes |
displayTextBox |
boolean | Whether to display text boxes |
See component document.
We use ESLint to unify code style and run checks by Husky and GitHub Action.
The development plan of this project can be found on Notion.
- Clone the code repository in your familiar way.
$ git clone https://github.com/ForkKILLET/Cuiping.js $ gh repo clone ForkKILLET/Cuiping.js
- Use pnpm to install dependencies.
$ pnpm i
- Start the main building job.
Or start package-level building job separately, using workspace.
$ pnpm build
Or$ pnpm -F {cuiping,cuiping-component,cuiping-frontend}cdinto package directories and start package-level building job.$ cd {backend,component,frontend} $ pnpm build
- Test the backend only.
You may set environment variable to enable debug.
$ cd backend $ pnpm build:runRun testcases: (How to add testcases is shown below)$ DEBUG=1 pnpm build:run
$ pnpm build:test
- Test all functions in the frontend. (recommended)
Development mode:Production mode:$ cd frontend $ pnpm dev$ cd frontend $ pnpm build $ pnpm preview - You may add
?debugURL param to enable debug. When debug is on, the program will:- Print debug-level logs
- Expose debug functions to
window(printStructandshowMoleculeSequence) - Add a TestCase button to the toolbar of the component. You may click it to copy the testcase.
Please use ng style for commit message.
You may refer to git log.
This project is open source under MIT license.
