Skip to content

Commit

Permalink
Upskirt is now known as Sundown. Updated it to a40cdb9ece259d35aa4b.
Browse files Browse the repository at this point in the history
  • Loading branch information
madari committed Aug 26, 2011
1 parent 85a2f0c commit a1b8d32
Show file tree
Hide file tree
Showing 17 changed files with 528 additions and 352 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
*For the Upskirt license, see the files in bundled in upskirt/.*
*For the Sundown license, see the files in bundled in sundown/.*

Copyright (c) 2011 Jukka-Pekka Kekkonen <karatepekka@gmail.com>

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@ include $(GOROOT)/src/Make.inc

TARG = goskirt
CGOFILES = goskirt.go
CGO_OFILES = $(patsubst %.c,%.o,$(wildcard upskirt/*.c))
CGO_OFILES = $(patsubst %.c,%.o,$(wildcard sundown/*.c))
CLEANFILES += $(CGO_OFILES)

include $(GOROOT)/src/Make.pkg
Expand Down
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -2,12 +2,12 @@ Goskirt
=======

Package goskirt provides Go-bindings for the excellent
[Upskirt](https://github.com/tanoku/upskirt)
Markdown parser ["that doesn't suck"](https://github.com/tanoku/upskirt).
[Sundown](https://github.com/tanoku/sundown)
Markdown parser ["that doesn't suck"](https://github.com/tanoku/sundown) (F/K/A Upskirt).

To use goskirt, create a new Goskirt-value with the markdown extensions and
render modes you want. The extensions and render modes are encapsulated in the
struct as bitsets following the schematics of the Upskirt library. The created
struct as bitsets following the schematics of the Sundown library. The created
value contains two methods: WriteHTML and WriteTOC that both parse the data
given in a byte slice and writes the formatted results into the given io.Writer
using the setup encapsuled in the underlaying struct type.
Expand All @@ -23,14 +23,14 @@ Example
)

func main() {
data := []byte("Hello, upskirt!\n===============\n")
data := []byte("Hello, sundown!\n===============\n")

skirt := goskirt.Goskirt{
goskirt.EXT_AUTOLINK | goskirt.EXT_STRIKETHROUGH,
goskirt.HTML_SMARTYPANTS | goskirt.HTML_USE_XHTML,
}

// <h1>Hello, upskirt!</h1>
// <h1>Hello, sundown!</h1>
skirt.WriteHTML(os.Stdout, data)
}

Expand Down Expand Up @@ -69,7 +69,7 @@ Install
License
-------

*For the Upskirt license, see the files in bundled in upskirt/.*
*For the Sundown license, see the files in bundled in sundown/.*

Copyright (c) 2011 Jukka-Pekka Kekkonen <karatepekka@gmail.com>

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Expand Up @@ -83,7 +83,7 @@ func main() {
fmt.Println(err)
os.Exit(1)
}

switch renderer {
case goskirt.HTMLRenderer:
gs.WriteHTML(os.Stdout, data)
Expand Down
9 changes: 5 additions & 4 deletions doc.go
@@ -1,9 +1,10 @@
/*
Package goskirt provides Go-bindings for the excellent Upskirt markdown parser.
Package goskirt provides Go-bindings for the excellent Sundown markdown parser
(F/K/A Upskirt).
To use goskirt, create a new Goskirt-value with the markdown extensions and
render modes you want. The extensions and render modes are encapsulated in the
struct as bitsets following the schematics of the Upskirt library. The created
struct as bitsets following the schematics of the Sundown library. The created
value contains two methods: WriteHTML and WriteTOC that both parse the data
given in a byte slice and writes the formatted results into the given io.Writer
using the setup encapsuled in the underlaying struct type.
Expand All @@ -18,14 +19,14 @@ Usage:
)
func main() {
data := []byte("Hello, upskirt!\n===============\n")
data := []byte("Hello, sundown!\n===============\n")
skirt := goskirt.Goskirt{
goskirt.EXT_AUTOLINK | goskirt.EXT_STRIKETHROUGH,
goskirt.HTML_SMARTYPANTS | goskirt.HTML_USE_XHTML,
}
// <h1>Hello, upskirt!</h1>
// <h1>Hello, sundown!</h1>
skirt.WriteHTML(os.Stdout, data)
}
Expand Down
21 changes: 11 additions & 10 deletions goskirt.go
@@ -1,9 +1,9 @@
package goskirt

/*
#include "upskirt/markdown.h"
#include "upskirt/buffer.h"
#include "upskirt/html.h"
#include "sundown/markdown.h"
#include "sundown/buffer.h"
#include "sundown/html.h"
*/
import "C"

Expand All @@ -25,7 +25,8 @@ const (
EXT_AUTOLINK = C.MKDEXT_AUTOLINK
EXT_STRIKETHROUGH = C.MKDEXT_STRIKETHROUGH
EXT_LAX_HTML_BLOCKS = C.MKDEXT_LAX_HTML_BLOCKS
EXT_SPACE_HEADERS = C.MKDEXT_SPACE_HEADERS // 1 << 6
EXT_SPACE_HEADERS = C.MKDEXT_SPACE_HEADERS
EXT_SUPERSCRIPT = C.MKDEXT_SUPERSCRIPT // 1 << 7
)

// Render modes
Expand Down Expand Up @@ -70,7 +71,8 @@ func (g Goskirt) WriteTOC(w io.Writer, p []byte) (n int, err os.Error) {
func render(w io.Writer, extensions, renderModes, rndr uint, p []byte) (n int, err os.Error) {
var ob *C.struct_buf
var ib C.struct_buf
var renderer C.struct_mkd_renderer
var callbacks C.struct_sd_callbacks
var options C.struct_html_renderopt

ib.data = (*C.char)(unsafe.Pointer(&p[0]))
ib.size = C.size_t(len(p))
Expand All @@ -82,19 +84,18 @@ func render(w io.Writer, extensions, renderModes, rndr uint, p []byte) (n int, e

switch rndr {
case HTMLRenderer:
C.upshtml_renderer(&renderer, C.uint(renderModes&^HTML_SMARTYPANTS))
C.sdhtml_renderer(&callbacks, &options, C.uint(renderModes&^HTML_SMARTYPANTS))
case TOCRenderer:
C.upshtml_toc_renderer(&renderer)
C.sdhtml_toc_renderer(&callbacks, &options)
default:
panic("unknown renderer")
}

C.ups_markdown(ob, &ib, &renderer, C.uint(extensions))
C.upshtml_free_renderer(&renderer)
C.sd_markdown(ob, &ib, C.uint(extensions), &callbacks, unsafe.Pointer(&options))

if renderModes&HTML_SMARTYPANTS > 0 {
sb := C.bufnew(128)
C.upshtml_smartypants(sb, ob)
C.sdhtml_smartypants(sb, ob)
n, err = w.Write((*[1 << 30]byte)(unsafe.Pointer(sb.data))[0:sb.size])
C.bufrelease(sb)
} else {
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions upskirt/autolink.c → sundown/autolink.c
Expand Up @@ -22,7 +22,7 @@
#include <ctype.h>

int
is_safe_link(const char *link, size_t link_len)
sd_autolink_issafe(const char *link, size_t link_len)
{
static const size_t valid_uris_count = 4;
static const char *valid_uris[] = {
Expand Down Expand Up @@ -147,7 +147,7 @@ check_domain(char *data, size_t size)
}

size_t
ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
sd_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
{
size_t link_end;

Expand Down Expand Up @@ -177,7 +177,7 @@ ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset,
}

size_t
ups_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
{
size_t link_end, rewind;
int nb = 0, np = 0;
Expand Down Expand Up @@ -226,7 +226,7 @@ ups_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offse
}

size_t
ups_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
sd_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
{
size_t link_end, rewind = 0, domain_len;

Expand All @@ -236,7 +236,7 @@ ups_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset,
while (rewind < offset && isalpha(data[-rewind - 1]))
rewind++;

if (!is_safe_link(data - rewind, size + rewind))
if (!sd_autolink_issafe(data - rewind, size + rewind))
return 0;
link_end = STRLEN("://");

Expand Down
11 changes: 7 additions & 4 deletions upskirt/autolink.h → sundown/autolink.h
Expand Up @@ -15,18 +15,21 @@
*/

#ifndef UPSKIRT_AUTOLINK_H
#define UPSKIRT_AUTOLINK_H_H
#define UPSKIRT_AUTOLINK_H

#include "buffer.h"

extern int
sd_autolink_issafe(const char *link, size_t link_len);

extern size_t
ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
sd_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);

extern size_t
ups_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);

extern size_t
ups_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
sd_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);

#endif

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a1b8d32

Please sign in to comment.