Coder Social home page Coder Social logo

typst-syntree's Introduction

typst-syntree

syntree is a typst package for rendering syntax trees / parse trees (the kind linguists use).

The name and syntax are inspired by Miles Shang's syntree. Here's an example to get started:

#import "@preview/syntree:0.2.0": syntree

#syntree(
  nonterminal: (font: "Linux Biolinum"),
  terminal: (fill: blue),
  child-spacing: 3em, // default 1em
  layer-spacing: 2em, // default 2.3em
  "[S [NP This] [VP [V is] [^NP a wug]]]"
)

Output tree for "This is a wug"

There's limited support for formulas inside nodes; try #syntree("[DP$zws_i$ this]") or #syntree("[C $diameter$]").

For more flexible tree-drawing, use tree:

#import "@preview/syntree:0.2.0": tree

#let bx(col) = box(fill: col, width: 1em, height: 1em)
#tree("colors",
  tree("warm", bx(red), bx(orange)),
  tree("cool", bx(blue), bx(teal)))

Output tree of colors

typst-syntree's People

Contributors

lynn avatar jocap avatar

Stargazers

洛言志 avatar ᡥᠠᡳᡤᡳᠶᠠ ᡥᠠᠯᠠ·ᠨᡝᡴᠣ 猫 avatar Alexander Hwang avatar Tadeo Kondrak avatar Adrian Sieber avatar Marcus K. Zhong avatar mad0perator avatar Anne Thorpe avatar la .uetcis. avatar Yang Ming-Tian avatar  avatar  avatar Nico Baier avatar Tristan Pieper avatar Erika avatar  avatar Taylor Hillegeist avatar

Watchers

 avatar  avatar

typst-syntree's Issues

Movement

I noticed in testing the examples provided that movement doesn't seem to be supported yet. Is there a plan in the works for this?

Typst v0.7.0 breaking change for syntree package

Description

After upgrading Typst from version v0.6.0 to v0.7.0 I noticed that my syntax tree lines were all over the place.

Used Package: https://github.com/typst/packages/tree/main/packages/preview/syntree/0.1.0

I haven't figured out the exact change that caused this problem, but I suspect it might be something that changed the behavior of the place or measure functions, or the line display in PDFs in general.

Before (v0.6.0):

image

After (v0.7.0):

image

Typst code

#import "@preview/syntree:0.1.0": syntree

#figure(
  caption: [Vereinfachter Syntaxbaum zu ...],
  syntree(
    nonterminal: (font: "Linux Biolinum"),
    terminal: (fill: blue),
    "[twig_block 
        [name my_block]
        [inner_twig
          [div_tag 
            [inner_tag
              [attribute
                [name class]
                [string
                  my-block-div
                  [twig_expression additional_class]
                ]
              ]
            ]
            [children
              [text hello]
            ]
          ]
        ]
      ]"
  )
) <valid_twig_example_tree>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.