Hacker News new | past | comments | ask | show | jobs | submit login

No code samples without digging into links in the documentation doesn’t seem very inviting. Especially when the project itself is a programming language.



I was able to find a link to examples in the main README, although it's true that in the Documentation markdown file itself is missing the reference.

In case it's useful for future readers, here are some samples: https://github.com/titzer/virgil/tree/master/doc/tutorial/ex...


The syntax is not the same.

This is an example from itzer/virgil [1]:

  def fib(i: int) -> int {
    if (i <= 1) return 1;
    return fib(i - 1) + fib(i - 2);
  }
And an example from munificent/vigil [2]:

  def fib(n):
    if n < 2:
        result = n
    else:
        result = fib(n - 1) + fib(n - 2)
    swear result >= 0
    return result
[1] https://github.com/titzer/virgil/blob/master/doc/tutorial/Me...

[2] https://github.com/munificent/vigil


Documentation could definitely use a nicer coat of paint. Not sure how to do syntax highlighting in raw markdown, and GitHub won't accept a new language definition unless it is in "hundreds" of projects. So maybe an image?


I've used a markdown to html converter to convert my blog posts into HTML with very nice and customizable code samples... in my case I used Go's Blackfriday library with bfchroma[1] doing syntax highlighting with Chroma[2]. To add your language to Chroma you have to provide a lexer, which in turn is written in Pygments[3] syntax.

Once you have that, you can post your docs in GitHub Pages (or something like Netlify[4] or Cloudflare[5]), they both can run a command to build your website (from markdown to html) every time you push to a branch, and then serve the HTML generated as a static site.

Before this though, your language seems similar enough to others (maybe Java or C#?) that if you tell the converter to use those languages, you'll get decent enough highlighting. I did this to highlight Zig code before it became supported by telling the converter it was typescript code (coincidentally, many keywords seem to have aligned well enough)!

[1] https://github.com/Depado/bfchroma/

[2] https://github.com/alecthomas/chroma#supported-languages

[3] https://pygments.org/docs/lexerdevelopment/

[4] https://www.netlify.com/blog/2016/10/27/a-step-by-step-guide...

[5] https://pages.cloudflare.com/




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: