Litvis as a framework for interpreting markdown documents can have multiple implementations in various programming languages. A reference implementation of litvis has been developed using TypeScript, a typed superset of JavaScript. Most of this open-source software can be found in https://github.com/gicentre/litvis → packages directory and the remaining bits are located in these repositories:
- gicentre/mume-with-litvis
- gicentre/markdown-preview-enhanced-with-litvis
- gicentre/vscode-markdown-preview-enhanced-with-litvis
The easiest way to try litvis is to install Visual Studio Code extension.
Litvis code is organised in a form of a monorepo and relies on pnpm workspaces for package management. It also uses lerna for orchestrating packages in the monorepo.
Before getting started, please make sure you have the latest node and pnpm installed on your machine.
node --version
## ≥ 22.20
pnpm --version
## ≥ 10# cd gicentre/litvis
pnpm install## once
pnpm build
## continuously
pnpm build:watch## one-time password for two-factor auth
export NPM_CONFIG_OTP=??
pnpm lerna exec npm publishpnpm lerna exec pnpm link
## to unregister
# pnpm lerna exec --no-bail pnpm unlinkpnpm lintpnpm testChecking file formatting with Prettier
pnpm fix:prettierpnpm qa
pnpm build-and-qa
## ‘build-and-qa‘ is recommended for ‘cold start’
## (i.e. when packages have not been built previously)TODO: Replace Atom with VSCode
This section is based on the assumption that at least one package in this repo is being worked on.
First step is to clone the three repositories (this one, plus gicentre/mume-with-litvis and gicentre/markdown-preview-enhanced-with-litvis.
Open a terminal in the folder of this repo (gicentre/litvis),
-
Run
pnpm install -
For each package being worked on, go the folder of the package (e.g.
cd packages\narrative-schema) and runnpm link. This will create a symlink in a global/user node_modules folder. -
Back in the main folder, run
pnpm build:watch
Open a new terminal and navigate to the mume-with-litvis folder.
-
Run
npm install -
Open the
node_modulesfolder and check the modules that are dependencies from the litvis repository (e.g. litvis-integration-mume). Now, for those packages that were linked in the previous step, runnpm link package_name. For example, if working on litvis-integration-mume, runnpm link litvis-integration-mume. -
Back in the main folder, run
npm run build:watch
Lastly, open a new terminal in the markdown-preview-enhanced-with-litvis folder.
-
Run
npm install -
Open the
node_modulesfolder and find modules that are dependencies from the previous two repositories (mume-with-litivs and any of the packages in this repo). For each of them, runnpm link package_nameas previously. -
Back in the main folder, run
npm run build. -
Run
apm link -d. This will create a link from the package (in the repo) to the development folder of atom. -
Run again
npm run build:watch.
Finally, in a separate terminal, run atom -d to open the development version of Atom. This will ensure that the markdown preview litvis-enhanced package is taken from the development folder and will not conflict with the release version. Now, every time a file in this repo is changed and saved, a chain of build commands will be triggered, ensuring that the Markdown Preview package is (locally) updated. To reload Atom and the packages to actually see the changes, go to View -> Developer -> Reload Window. When committing and merging changes, don't forget to use pnpm lint to pass the github checks.
MacOS related:
-
coreutilsmight be required (npm install -g coreutils). -
There might be a problem with
fseventswhen building the packages or loading Atom.npm install -g fsevents@1.2.9and rebuilding the package when requested, in Atom, should solve it.
TODO
Vega and Vega-Lite are not direct dependencies of gicentre/litvis.
They are introduced downstream inside NPM package mume-with-litvis, which in turn is a dependency of Atom and VSCode extensions.
Vega, Vega-Lite and their auxiliary libraries are listed in mume-with-litvis → package.json.
The versions are specified with ^, which means that the latest available patches or semver minor features will be picked automatically on extension install (or reinstall).
To upgrade development versions of vega libraries in mume-with-litvis, you need to remove them from pnpm-lock.yaml and reinstall dependencies (pnpm install).
If you need to upgrade major versions, e.g. vega-lite@X.Y.Z to vega-lite@[X+1].0.0, new extension releases are necessary.
Please follow the steps below.
-
Check out the latest commit on the
mainbranch of https://github.com/gicentre/mume-with-litvis.git. -
Update versions for
vega,vega-lite,vega-embed,vega-loader,apache-arroworvega-loader-arrowinpackage.json. -
Run
pnpm install. -
Find
dependentLibraryConfigsinsrc/markdown-engine.tsand upgrade versions accordingly. Note that you might also need to updatebuildPathForWebviewif it has changed. -
In the unlikely case of breaking changes that affect the lifecycle of vega-based visualizations, consider updating additional files in
srcfolder. This may be necessary in a small subset of cases, and only when the major versions are bumped. -
Update
CHANGELOG.mdfile by adding a new## Unreleased (minor|patch)section (example). -
Commit the changes.
-
Update
CHANGELOG.mdagain by replacing## Unreleased (...)with a new expected version number. Stage this file. -
Run
pnpm publish --minororpnpm publish --patch. This will buildmume-with-litvisfrom its source, change version inpackage.json, publish the new version on NPM, commit tomainand add git tag (v*). 2FA authentication token should be asked as part of this. Beware that publishing may fail on a slow internet connection due to the size ofmume-with-litviscombined with the expiration of 2FA tokens. -
Open https://www.npmjs.com/package/mume-with-litvis and verify that the package version has been updated.
-
Commit your change in
package.jsonand push both commits to themainbranch on github.
You may also want to cherry-pick the first commit to mume in order to keep the fork in sync with its origin.
Example pull request: shd101wyy/mume#79.
-
Make sure you have the latest version of
vsceinstalled globally.npm install -g vsce
-
Check out the latest commit on the
mainbranch of https://github.com/gicentre/vscode-markdown-preview-enhanced-with-litvis.git. -
Run
pnpm install. -
Run
pnpm install mume-with-litvis@latestto update the version of this dependency. -
Open
CHANGELOG.mdand document upcoming changes. -
Commit (see example) and push.
-
Run
vsce publish patchorvsce publish minordepending on the nature of the upstream changes. You will be asked to authenticate at Visual Studio Marketplace if needed. -
Push the
mainbranch.