Skip to content

Commit

Permalink
Renamed c program and library stmd -> cmark.
Browse files Browse the repository at this point in the history
Also renamed internal library functions accordingly.
  • Loading branch information
jgm committed Oct 25, 2014
1 parent 7f0d1a8 commit abc95bd
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 52 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LDFLAGS?=-g -O3 -Wall -Werror
SRCDIR?=src
DATADIR?=data
BENCHINP?=bench.md
PROG?=./stmd
PROG?=./cmark
JSMODULES=$(wildcard js/lib/*.js)

.PHONY: all test spec benchjs testjs
Expand Down Expand Up @@ -46,10 +46,10 @@ benchjs:

HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o

STMD_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c
CMARK_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c

$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c
$(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c
$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
$(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c

$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ CommonMark
==========

CommonMark is a [specification of Markdown syntax][the spec],
together with BSD3-licensed implementations (`stmd`) in C and JavaScript.
together with BSD3-licensed implementations (`cmark`) in C and
JavaScript.

The implementations
-------------------

The C implementation provides both a library and a standalone program
`stmd` that converts Markdown to HTML. It is written in standard C99
`cmark` that converts Markdown to HTML. It is written in standard C99
and has no library dependencies. (However, if you check it out from the
repository, you'll need [`re2c`](http://re2c.org) to generate
`scanners.c` from `scanners.re`. This is only a build dependency for
developers, since `scanners.c` can be provided in a released source
tarball.)

Usage: stmd [FILE*]
Usage: cmark [FILE*]
Options: --help, -h Print usage information
--ast Print AST instead of HTML
--version Print version
Expand All @@ -37,7 +38,7 @@ sanitizer to protect against
[XSS attacks](http://en.wikipedia.org/wiki/Cross-site_scripting).

[The spec] contains over 450 embedded examples which serve as conformance
tests. To run the tests for `stmd`, do `make test`. To run them for
tests. To run the tests for `cmark`, do `make test`. To run them for
another Markdown program, say `myprog`, do `make test PROG=myprog`. To
run the tests for `stmd.js`, do `make testjs`.

Expand Down
2 changes: 1 addition & 1 deletion man/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALL=man1/stmd.1
ALL=man1/cmark.1

.PHONY: all

Expand Down
14 changes: 7 additions & 7 deletions man/stmd.1.md → man/cmark.1.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
title: stmd
title: cmark
section: 1
footer: stmd manual
date: August 12, 2014
footer: cmark manual
date: October 22, 2014
...

# NAME

stmd - convert markdown formatted text to HTML
cmark - convert CommonMark formatted text to HTML

# SYNOPSIS

stmd [*options*] [file\*]
cmark [*options*] [file\*]

# DESCRIPTION

`stmd` acts as a pipe, reading from stdin or from the specified
files and writing to stdout. It converts markdown formatted plain
`cmark` acts as a pipe, reading from stdin or from the specified
files and writing to stdout. It converts Markdown formatted plain
text to HTML, using the conventions described in the CommonMark
spec.

Expand Down
10 changes: 5 additions & 5 deletions man/man1/stmd.1 → man/man1/cmark.1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.TH "stmd" "1" "August 12, 2014" "stmd manual" ""
.TH "cmark" "1" "October 22, 2014" "cmark manual" ""
.SH NAME
.PP
stmd \- convert markdown formatted text to HTML
cmark \- convert CommonMark formatted text to HTML
.SH SYNOPSIS
.PP
stmd [\f[I]options\f[]] [file*]
cmark [\f[I]options\f[]] [file*]
.SH DESCRIPTION
.PP
\f[C]stmd\f[] acts as a pipe, reading from stdin or from the specified
\f[C]cmark\f[] acts as a pipe, reading from stdin or from the specified
files and writing to stdout.
It converts markdown formatted plain text to HTML, using the conventions
It converts Markdown formatted plain text to HTML, using the conventions
described in the CommonMark spec.
.SH OPTIONS
.TP
Expand Down
6 changes: 3 additions & 3 deletions narrative.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ title: CommonMark

CommonMark is a [specification of Markdown
syntax](http://jgm.github.io/stmd/spec.html), together with
BSD3-licensed implementations (`stmd`) in C and JavaScript. The source
BSD3-licensed implementations (`cmark`) in C and JavaScript. The source
for the spec and the two implementations can be found in [this
repository](http://github.com/jgm/stmd).

The C implementation provides both a library and a standalone program
`stmd` that converts Markdown to HTML. It is written in standard C99 and
has no library dependencies.
`cmark` that converts Markdown to HTML. It is written in standard C99
and has no library dependencies.

The JavaScript implementation is a single JavaScript file, with no
dependencies. [Try it now!](http://jgm.github.io/stmd/js/)
Expand Down
10 changes: 5 additions & 5 deletions src/blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdbool.h>
#include <ctype.h>

#include "stmd.h"
#include "cmark.h"
#include "utf8.h"
#include "scanners.h"
#include "inlines.h"
Expand Down Expand Up @@ -253,7 +253,7 @@ static node_block* add_child(node_block* parent,
}

// Free a node_block list and any children.
void stmd_free_nodes(node_block *e)
void cmark_free_nodes(node_block *e)
{
node_block * next;
while (e != NULL) {
Expand All @@ -265,7 +265,7 @@ void stmd_free_nodes(node_block *e)
} else if (e->tag == BLOCK_DOCUMENT) {
reference_map_free(e->as.document.refmap);
}
stmd_free_nodes(e->children);
cmark_free_nodes(e->children);
free(e);
e = next;
}
Expand Down Expand Up @@ -380,7 +380,7 @@ static node_block *finalize_document(node_block *document, int linenum)
return document;
}

extern node_block *stmd_parse_file(FILE *f)
extern node_block *cmark_parse_file(FILE *f)
{
strbuf line = GH_BUF_INIT;
unsigned char buffer[4096];
Expand All @@ -398,7 +398,7 @@ extern node_block *stmd_parse_file(FILE *f)
return finalize_document(document, linenum);
}

extern node_block *stmd_parse_document(const unsigned char *buffer, size_t len)
extern node_block *cmark_parse_document(const unsigned char *buffer, size_t len)
{
strbuf line = GH_BUF_INIT;
int linenum = 1;
Expand Down
10 changes: 5 additions & 5 deletions src/stmd.h → src/cmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ struct node_block {

typedef struct node_block node_block;

node_block *stmd_parse_document(const unsigned char *buffer, size_t len);
node_block *stmd_parse_file(FILE *f);
node_block *cmark_parse_document(const unsigned char *buffer, size_t len);
node_block *cmark_parse_file(FILE *f);

void stmd_free_nodes(node_block *e);
void cmark_free_nodes(node_block *e);

void stmd_debug_print(node_block *root);
void stmd_render_html(strbuf *html, node_block *root);
void cmark_debug_print(node_block *root);
void cmark_render_html(strbuf *html, node_block *root);

#endif
4 changes: 2 additions & 2 deletions src/html/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string.h>
#include <assert.h>

#include "stmd.h"
#include "cmark.h"
#include "debug.h"
#include "html/houdini.h"

Expand Down Expand Up @@ -222,7 +222,7 @@ static void blocks_to_html(strbuf *html, node_block *b, bool tight)
}
}

void stmd_render_html(strbuf *html, node_block *root)
void cmark_render_html(strbuf *html, node_block *root)
{
blocks_to_html(html, root, false);
}
2 changes: 1 addition & 1 deletion src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdbool.h>
#include <ctype.h>

#include "stmd.h"
#include "cmark.h"
#include "html/houdini.h"
#include "utf8.h"
#include "scanners.h"
Expand Down
18 changes: 9 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "stmd.h"
#include "cmark.h"
#include "debug.h"

void print_usage()
{
printf("Usage: stmd [FILE*]\n");
printf("Usage: cmark [FILE*]\n");
printf("Options: --help, -h Print usage information\n");
printf(" --ast Print AST instead of HTML\n");
printf(" --version Print version\n");
Expand All @@ -17,9 +17,9 @@ static void print_document(node_block *document, bool ast)
strbuf html = GH_BUF_INIT;

if (ast) {
stmd_debug_print(document);
cmark_debug_print(document);
} else {
stmd_render_html(&html, document);
cmark_render_html(&html, document);
printf("%s", html.ptr);
strbuf_free(&html);
}
Expand All @@ -34,7 +34,7 @@ int main(int argc, char *argv[])

for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--version") == 0) {
printf("stmd %s", VERSION);
printf("cmark %s", VERSION);
printf(" - CommonMark converter (c) 2014 John MacFarlane\n");
exit(0);
} else if ((strcmp(argv[i], "--help") == 0) ||
Expand All @@ -52,9 +52,9 @@ int main(int argc, char *argv[])
}

if (numfps == 0) {
document = stmd_parse_file(stdin);
document = cmark_parse_file(stdin);
print_document(document, ast);
stmd_free_nodes(document);
cmark_free_nodes(document);
} else {
for (i = 0; i < numfps; i++) {
FILE *fp = fopen(argv[files[i]], "r");
Expand All @@ -65,9 +65,9 @@ int main(int argc, char *argv[])
exit(1);
}

document = stmd_parse_file(fp);
document = cmark_parse_file(fp);
print_document(document, ast);
stmd_free_nodes(document);
cmark_free_nodes(document);
fclose(fp);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/print.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "stmd.h"
#include "cmark.h"
#include "debug.h"

static void print_str(const unsigned char *s, int len)
Expand Down Expand Up @@ -170,7 +170,7 @@ static void print_blocks(node_block* b, int indent)
}
}

void stmd_debug_print(node_block *root)
void cmark_debug_print(node_block *root)
{
print_blocks(root, 0);
}
2 changes: 1 addition & 1 deletion src/references.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stmd.h"
#include "cmark.h"
#include "utf8.h"
#include "references.h"
#include "inlines.h"
Expand Down
2 changes: 1 addition & 1 deletion src/scanners.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stmd.h"
#include "cmark.h"

extern int _scan_autolink_uri(const unsigned char *p);
extern int _scan_autolink_email(const unsigned char *p);
Expand Down
4 changes: 2 additions & 2 deletions src/utf8.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _H_STMD_UTF8_
#define _H_STMD_UTF8_
#ifndef _H_cmark_UTF8_
#define _H_cmark_UTF8_

#include <stdint.h>
#include "buffer.h"
Expand Down

0 comments on commit abc95bd

Please sign in to comment.