cmark VS re2c

Compare cmark vs re2c and see what are their differences.

cmark

CommonMark parsing and rendering library and program in C (by commonmark)

re2c

Lexer generator for C, C++, Go and Rust. (by skvadrik)
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
cmark re2c
10 12
1,571 1,022
1.0% -
8.7 6.8
8 days ago 11 days ago
C C
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

cmark

Posts with mentions or reviews of cmark. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-03-29.
  • Ask HN: What's the simplest static website generator?
    10 projects | news.ycombinator.com | 29 Mar 2024
    I use GNU make. Write content in markdown, feed it to https://github.com/commonmark/cmark to create html. I intended to splice files together using xslt but echo and cat written in the makefile sufficed.

    I'm not totally sure I'd recommend that but I do like the markdown => html flow.

  • Building a Personal Internet from Markdown Files
    3 projects | news.ycombinator.com | 7 Jan 2024
    I seem to be in the middle of trying to build something similar to this. I want it to run on an android phone but otherwise the same sort of idea, offline-first information I want access to.

    There's some weirdness around android browsers refusing to load html from the phone itself on security grounds. The OP uses a "progressive web app" which seems to be the proper way to do this at some point in the past, but firefox has killed that for some reason. Thus the most difficult part of the project seems to be persuading my phone to render html without copying the files to some server (or running a fileserver on the phone itself, to look at from the phone, which seems absurd).

    What I can offer for people stumbling down the same path:

    - Obsidian works fine as for ad hoc authoring of markdown while walking around

    - It is known on stack overflow that markdown can't be sanely parsed into an AST

    - That knowledge is kind of a branding misfire, the 'markdown' one is looking for is here https://github.com/commonmark/cmark

    - That cmark binary + some foreach-file style script will turn markdown into html or xml. If you choose makefile and put spaces in the name of files you'll have a moderately bad few minutes cursing your tools

    - Given that output xml/html, you can build whatever other html you see fit

    - That html can be written back to the obsidian vault and opened by a phone browser (at least if it's a single file)

    - CSS thus far appears to be required, I was really hoping to annotate the html instead

    First 90% done here, second 90% to go.

  • commonmark/cmark: CommonMark standard-based Markdown parsing and rendering library and program in C
    1 project | /r/Clibs | 11 Sep 2021
  • Using Rust with Elixir for code reuse and performance
    4 projects | news.ycombinator.com | 19 Aug 2021
    Yeah no doubt it, although in this case the C implementation has been a long running project that's under the official commonmark GitHub repo at https://github.com/commonmark/cmark.

    But I think the most important thing here is an Elixir NIF already exists to use it. The blog post as is leaves readers having to implement ~100 lines of Elixir code to use the Rust version because the authors of blog post didn't include that in the article, or open source it as a library for others to use.

    So from a reader's POV, if your goal is to get a highly stable, fast and safe Markdown parser running in Elixir, the Elixir cmark library I linked in a parent comment solves that problem out of the box.

  • Share Your Tasks That Help You Use Tasker!
    1 project | /r/tasker | 17 Aug 2021
  • How do I link and use a c library?
    2 projects | /r/Zig | 13 Aug 2021
    I'm confused about how to use a c library (specifically, cmark) from zig.
  • My favorite cli/tui programs:
    43 projects | /r/commandline | 15 Jul 2021
    Writing Documents Markdown (and md2pdf or cmark + html2ps + ps2pdf) / plain text / groff
  • Presenting SwiftDown my markdown live editor package
    2 projects | /r/swift | 5 Apr 2021
    It's built on top of cmark which make it fast, and use pure markdown without any proprietary format. It currently supports both macOS and iOS.
  • Thoughts on lex/GNU Flex?
    3 projects | /r/suckless | 24 Feb 2021
    However, writing a proper markdown parser is quite difficult as you have to support nesting and many weird corner cases. So, if you do not need to write your own parser (e.g. for learning purposes), it would be a lot easier to use an existing parser and write a custom renderer for roff. Some such parsers are cmark, commonmark.js, and goldmark.
  • My stack will outlive yours
    8 projects | news.ycombinator.com | 7 Jan 2021
    I just use the small reference C implementation of CommonMark and it works great:

    https://github.com/commonmark/cmark

    There is an example where you load it via shared library in Python, i.e. send a Markdown string and get back an HTML string.

re2c

Posts with mentions or reviews of re2c. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-12-02.
  • Ask HN: What are some unpopular technologies you wish people knew more about?
    56 projects | news.ycombinator.com | 2 Dec 2023
    (1) Zulip Chat - https://zulip.com/ - seems to be reasonably popular, but more people should know about it

    I’ve been using it for over 5 years now [1], and it’s as good as ever. It’s way faster than any other chat app I’ve used. It has a good UI and conversation model. It has a simple and functional API that lets me curl threads and write blog posts based on them.

    (only problem is that I Ctrl-+ in my browser to make the font bigger – I think it’s too dense for most people)

    (2) re2c regex to state machine compiler - https://re2c.org

    A gem from the 90’s, which people have done a great job maintaining and improving (getting Go and Rust target support in the last few years). I started using it in 2016, and used for a new program a few months ago. I came to the conclusion that it should have been built into C, because C has shitty string processing – and Ken Thompson both invented C AND brought regular languages to computing !!

    In comparison, treesitter lexers are very low level, fiddly, and error prone. I recently saw dozens of ad hoc fixes to the tree-sitter-bash lexer, which is unsurprising if you look at the structure of the code (manually crawling through backslashes and braces in C).

    https://github.com/tree-sitter/tree-sitter-bash/blob/master/...

    These fixes are definitely appreciated, but I think it indicates a problem with the model itself.

    (based on https://lobste.rs/s/endspx/software_you_are_thankful_for#c_y...)

    [1] https://www.oilshell.org/blog/2018/04/26.html

  • Irregular Expressions
    1 project | news.ycombinator.com | 9 Apr 2023
    The "Papers" section on re2c's web site continues Laurikari's work: http://re2c.org/

    ... but I haven't found them particularly accessible. And it's not clear it's a viable strategy in a general purpose regex engine. Namely, I'm not sure how much bigger it makes the DFA.

    Also, AFAIK, these are DFAs. They are different theoretical structures with explicitly more power.

    > and then an NDFA is used to match a third time, to extract the capture groups.

    That's the PikeVM. It's an NFA simulation. Although it uses additional storage and is otherwise more computationally powerful than just a plain NFA.

  • My experience crafting an interpreter with Rust (2021)
    3 projects | news.ycombinator.com | 25 Mar 2023
    > What do you gain by using it?

    Performance, although this possibly depends on your compiler, whether you use PGO, and similar finicky issues.

    Example: https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e...

    Some prior HN discussion: https://news.ycombinator.com/item?id=18678920

    Another example where goto is relevant is implementing finite automata. A (very short) paper from 1988 that discusses three different ways of implementing a finite state machine is "How (Not) to Code a Finite State Machine". The documentation of RE2C may be even more interesting: https://re2c.org

    RE2C is a program that compiles finite automata into C, Go, or Rust code. It provides many implementation strategies: it can make use of computed or labelled gotos when the language provides them.

    Implementing pushdown automata comes with similar issues.

  • How to compile DPDK-22.11.1
    3 projects | dev.to | 6 Dec 2022
    wget https://github.com/skvadrik/re2c/releases/download/1.0.3/re2c-1.0.3.tar.gz tar -zxvf re2c-1.0.3.tar.gz cd re2c-1.0.3/ ./configure make make install
  • Best approach for writing a lexer
    1 project | /r/Compilers | 28 Nov 2022
    In Rust I use https://docs.rs/logos/latest/logos/. I think another similar is http://re2c.org
  • re2c is a free and open-source lexer generator for C/C++, Go and Rust
    1 project | news.ycombinator.com | 21 Sep 2022
  • File parsing with PHP, Bison and re2c
    2 projects | dev.to | 25 Aug 2022
    re2c is an open-source lexer generator. It uses regular expressions to recognize tokens.
  • Best option for Rust Parser and Lexer Generators?
    3 projects | /r/rust | 25 Feb 2022
    Those suggested crates are still more or less the popular options. There was also recently added support for Rust in re2c.
  • How Does One Develop the Grammar for their New Language
    2 projects | /r/ProgrammingLanguages | 15 Oct 2021
  • Javascript Date String Parsing
    8 projects | dev.to | 29 Apr 2021
    First, the implementation of strtotime is a textbook study in why other people's C code is not where you want to spend time. You can see the guts of the implementation logic here. This isn't stock C code -- it's code for a system called re2c. This system allows you to write regular expressions in a custom DSL (domain specific language), and then transform/compile those regular expressions down to C programs (also C++ and Go) that will execute those regular expressions. Something in PHP's make file uses this parse_date.re file to generate parse_date.c. If you don't realize parse_date.c is a generated file, this can be extremely rough going. If you've not familiar with re2c is can be regular rough going. We leave further exploration as an exercise for the reader -- an exercise we haven't taken ourself.

What are some alternatives?

When comparing cmark and re2c you can also consider the following projects:

nimler - Erlang/Elixir NIFs in Nim

parser-demo - Good source layout with Flex and Bison

rss-proxy - RSS-proxy allows you to do create an RSS or ATOM feed of almost any website, just by analyzing just the static HTML structure.

Luxon - ⏱ A library for working with dates and times in JS

cmark - 💧 Elixir NIF for cmark (C), a parser library following the CommonMark spec, a compatible implementation of Markdown.

lowdown - simple markdown translator

moment - Parse, validate, manipulate, and display dates in javascript.

pulldown-cmark - An efficient, reliable parser for CommonMark, a standard dialect of Markdown

plex - a parser and lexer generator as a Rust procedural macro

gitui - Blazing 💥 fast terminal-ui for git written in rust 🦀

dperf - dperf is a 100Gbps network load tester.