@nova-lang/cli
v1.7.37
Published
Nova: Nested Ordered Versatile Architecture — a programmable markup language CLI
Maintainers
Readme
Nova
Nested Ordered Versatile Architecture — a programmable markup language.
Nova is not a simple mashup of HTML, YAML, and TeX. It abstracts their strengths into a unified node model — everything is a functional Block with attributes and children.
What problem does Nova solve? Traditional markup languages force you to pick a single paradigm: HTML for structure, YAML for data, TeX for typesetting, Markdown for simplicity. Nova unifies them all into one consistent syntax — write documents, schemas, data models, math, and code with the same grammar. Use it for technical writing, API documentation, code generation, data reports, and literate programming.
Installation
npm (recommended)
npm install -g @nova-lang/cliFrom source
git clone https://github.com/nova-markup-lang/cli.git
cd cli
npm install
npm linkQuick Start
Create a file hello.nv:
@meta {
title: "Hello Nova"
}
@page {
@h1 "Welcome to Nova"
@p "This is a @em{programmable} markup language."
@p "Inline math: $E = mc^2$"
}Render to HTML:
nova build hello.nv -o hello.htmlOpen hello.html in your browser.
CLI Usage
nova <file> # Render .nv file to HTML (stdout)
nova build <file> # Render to .html file
nova build <file> -o out # Specify output path
nova lex <file> # Show token stream (debug)
nova ast <file> # Show AST structure (debug)
nova watch <file> # Watch file and auto-rebuild
nova init [dir] # Scaffold new Nova project
nova help # Show full usage
nova -i # Read from stdinOptions
| Flag | Description |
|--------------------|------------------------------------|
| -i, --input <file> | Input .nv file |
| -o, --output <file> | Output file path (build) |
| -p, --pretty | Pretty-print HTML |
| --css <file> | Inject custom CSS file |
| --template <file> | Use custom HTML template |
| --latex | Render to LaTeX instead of HTML |
| -h, --help | Show help |
| -v, --version | Show version |
Syntax Overview
Blocks
Everything is a block: @BlockName(attrs) { children }.
@section(id: "intro") {
@p "This is a paragraph."
@ul {
- Item one
- Item two
}
}- No children → omit braces:
@image(src: "photo.png") - Anonymous block → unnamed container like
<div> - Attributes in
(), comma-separated,:or=for key-value pairs - Children indented 2 spaces
Inline Elements
Text with @em{emphasis}, @strong{bold},
a @a(href: "https://nova-lang.org"){link} and @code{print(x)}.Interpolations
@p "Hello, #{name}! You have #{count} messages."Conditionals
@if(condition) {
...
}
@else @if(other) {
...
}
@else {
...
}Loops
@for(item in list) {
- #{item}
}
@for(i in 5) {
@p "Iteration #{i}"
}Macros
@def greet(name) {
@p "Hello, #{name}!"
}
@def button(label: String = "Click", @content) {
@div(style: "border:1px solid #ccc; padding:8px") {
@strong "#{label}"
@content
}
}
@greet("World")
@button(label: "Submit") { @p "Click me" }Schemas & Services
@schema(Person) {
id: Int32 @1
name: String @2 = ""
email: String? @3
tags: List<String> @4
}
@service(UserAPI) {
getUser(id: Int64) -> Person
listUsers() -> List<Person>
}Tables
@table(caption: "Languages") {
@header { Name, Type, Paradigm }
@row { Nova, Markup, Multi-paradigm }
@row { HTML, Markup, Declarative }
}Or CSV-style arrays:
@table {
[["Name", "Age"], ["Alice", 30], ["Bob", 25]]
}Lists
@ul {
- Apple
- Banana
}
@ol {
+ First
+ Second
}Math
Inline: $E = mc^2$
Display: $$ \sum_{i=1}^n i = \frac{n(n+1)}{2} $$
Block: @equation { x = \frac{-b \pm \sqrt{b^2-4ac}}{2a} }API Reference
const nova = require("@nova-lang/cli");tokenize(source)
Tokenize a Nova source string into a stream of tokens.
const tokens = nova.tokenize('@p "Hello"');parse(tokens)
Parse a token stream into an AST.
const ast = nova.parse(tokens);interpret(ast, env)
Evaluate macros, conditionals, loops, and interpolations in the AST.
const { Env } = require("@nova-lang/cli");
const env = new Env();
const interpreted = nova.interpret(ast, env);render(doc, options)
Render an interpreted document to HTML.
const html = nova.render(doc, { pretty: true });renderLatex(doc, options)
Render an interpreted document to LaTeX.
const latex = nova.renderLatex(doc);Configuration
Custom CSS
nova build doc.nv --css style.cssCustom HTML Template
Create template.html:
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title>
<style>{{styles}}</style>
{{mathjax}}
</head>
<body class="nova-document">{{content}}</body>
</html>nova build doc.nv --template template.htmlLaTeX Preamble
When using --latex, Nova generates a complete LaTeX document. Pass @meta fields for document-level configuration.
Standard Library
Nova ships with a rich standard library. Load with @use "nova/std":
| Package | Description |
|-----------------------|------------------------------------------|
| std/sugar | Truthiness, comparison, string helpers |
| std/functional | pipe, compose, map, filter, etc. |
| std/control | when, unless, switch, cond |
| std/types | Type checking, conversion, JSON, clone |
| std/strings | String manipulation utilities |
| std/math | Math helpers |
| std/lists | List operations |
| std/datetime | Date/time formatting, math, ranges |
| std/encoding | Base64, URL, hex encoding |
| std/colors | Named colors utility |
| std/random | Random generation |
| std/json | JSON read/write utilities |
| std/io | File I/O helpers |
| std/plot | Plotting primitives |
| std/components | Reusable UI components |
| data/csv | CSV parsing and generation |
| data/json | JSON processing |
| data/yaml | YAML processing |
| data/sql | SQL query generation |
| data/excel | Excel file support |
| data/stats | Statistics functions |
| data/transform | Data transformation pipelines |
| schema/types | Type system definitions |
| schema/api | API specification |
| schema/openapi | OpenAPI code generation |
| schema/grpc | gRPC/Protobuf code generation |
| schema/graphql | GraphQL schema generation |
| schema/db | Database schema generation |
| schema/codegen | Multi-language code generation |
| schema/validation | Validation rule generation |
| ui/layout | Layout components |
| ui/typography | Typography components |
| ui/form | Form components |
| ui/navigation | Navigation components |
| ui/surface | Surface/card components |
| ui/media | Media components |
| ui/feedback | Feedback/alert components |
| nova/http | HTTP client |
| nova/crypto | Cryptography (hash, HMAC, AES, UUID) |
| nova/html | HTML rendering utilities |
| nova/markdown | Markdown conversion |
| nova/fs | Filesystem operations |
Examples
The examples/ directory contains many sample .nv files:
| Example | Demo |
|--------------------|-------------------------------------------|
| basics.nv | Comments, strings, numbers, attributes |
| blocks.nv | Block types and nesting |
| flow.nv | @if/@else, @for loops |
| macros.nv | @def macro definitions and calls |
| schemas.nv | @schema and @service type definitions |
| tables.nv | Table variants (array, header+row, mixed) |
| math.nv | Inline and display math |
| paper.nv | Complete academic paper example |
