No description
Find a file
2022-02-15 09:50:46 +03:00
.github/workflows v0.1.2 2020-10-26 23:22:09 +03:00
src [CHECKPOINT] 2021-02-04 18:41:25 +03:00
tests [CHECKPOINT] 2021-01-11 21:51:09 +03:00
.gitignore [REPO] Update gitignore 2020-08-26 21:54:35 +03:00
hasts.nimble v0.1.6 2021-02-04 18:41:29 +03:00
index.rst [>>>] Add index.rst 2020-08-29 13:37:58 +03:00
readme.org Update readme.org 2022-02-15 09:50:46 +03:00
todo.org [FEATURE] Convert colored string chunks to HTML 2020-08-10 20:21:39 +03:00

deprecated, functionality is moved to hmisc

Statically typed wrappers for various markup lanuages - grapvhiz, svg, openscad, latex. Allows easier generation - library takes care of as much edge cases as possible, and composition - instead of ropes and string interpolation all over the place you can use (somewhat) statically typed API with lots of helper functions.

Installation

nimble install hasts

Usage

Most of the markup ast nodes has lots of fields - providing parametetric constructor functions for all of them would be really tedious to implement. Instead withIt template from hmisc/algo/halgorithm might be used for constructing ast element and setting all fields immediately.

import hasts/graphviz_ast
import hmisc/algo/halgorithm

var g = makeDotGraph()
g.styleNode.shape = nsaEgg
for i in 0 .. 5:
  g.addEdge makeEdge(i, i * 2)
  g.addNode makeNode(i, "Position " & $i).withIt do:
    it.height = i.float

echo g
digraph G {
  node[shape=egg];
  t0[label="Position 0"];
  t1[label="Position 1", height=1.0];
  t2[label="Position 2", height=2.0];
  t3[label="Position 3", height=3.0];
  t4[label="Position 4", height=4.0];
  t5[label="Position 5", height=5.0];
  t0 -> t0;
  t1 -> t2;
  t2 -> t4;
  t3 -> t6;
  t4 -> t8;
  t5 -> t10;
}

Parially implemented (not 100% coverage, but most important parts are present)

  • graphviz
  • openscad
  • svg
  • html

WIP

  • latex
  • latex math
  • pandoc

Conitribution & development

  • REFACTOR: use regular strings instead of ropes for AST conversion.

Most of the features in the library are implemented on as-needed basis. If you have any question about implementation details or API free to join my discord server and ask questions there.