Skip to content

Commit

Permalink
Switch to DART sass
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Aug 26, 2023
1 parent 1f4c1f5 commit c3d781e
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 101 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _site
gojekyll
gojekyll-race
coverage.out
/Dockerfile
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ _site
/gojekyll
/gojekyll-race
coverage.out

dist/

16 changes: 0 additions & 16 deletions .goreleaser-darwin.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- "amd64"
- "386"
- "arm64"
- "arm"
- "riscv64"
ldflags: -s -w -X gojekyll/cmd.Version={{.Version}} -X gojekyll/cmd.BuildDate={{.Date}}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'

kos:
- repository: danog/gojekyll
tags:
- '{{.Version}}'
- latest
bare: true
preserve_import_paths: false
platforms:
- darwin/amd64
- darwin/arm64
- linux/386
- linux/amd64
- linux/riscv64
- linux/arm
- linux/arm64
- windows/amd64
- windows/arm64
17 changes: 0 additions & 17 deletions .goreleaser.yml

This file was deleted.

17 changes: 5 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
FROM golang:1.8.3-alpine
FROM alpine:latest

ADD . /go/src/github.com/osteele/gojekyll

RUN \
apk add --update gcc g++ git make python py-pip && \
pip install Pygments && \
cd $GOPATH/src/github.com/osteele/gojekyll && \
go get -v && \
make install && \
rm -rf /var/cache/apk/* && \
rm -rf $GOPATH/src/*
RUN apk add libstdc++ libgcc

COPY gojekyll /usr/local/bin/gojekyll

EXPOSE 4000

ENTRYPOINT ["/go/bin/gojekyll"]
ENTRYPOINT ["/usr/local/bin/gojekyll"]

CMD [ "--help" ]
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Gojekyll

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![go badge][go-svg]][go-url]
[![Golangci-lint badge][golangci-lint-svg]][golangci-lint-url]
[![Coveralls badge][coveralls-svg]][coveralls-url]
[![Go Report Card badge][go-report-card-svg]][go-report-card-url]
[![MIT License][license-svg]][license-url]
[![Golangci-lint badge][golangci-lint-svg]][golangci-lint-url]
[![Coveralls badge][coveralls-svg]][coveralls-url]
[![Go Report Card badge][go-report-card-svg]][go-report-card-url]
[![MIT License][license-svg]][license-url]

Gojekyll is a partially-compatible clone of the [Jekyll](https://jekyllrb.com)
static site generator, written in the [Go](https://golang.org) programming
Expand Down Expand Up @@ -57,9 +60,10 @@ gojekyll help build

### Binary Downloads

1. Ubuntu (64-bit) and macOS binaries are available from the [releases
1. Linux, Mac OS and Windows binaries for x86, amd64, armv6/v7, armv8, riscv64 are available from the [releases
page](https://github.com/osteele/gojekyll/releases).
2. [Optional] **Themes**. To use a theme, you need to install Ruby and
2. Download the latest version of [dart-sass](https://github.com/sass/dart-sass/releases) and [add it to your PATH](https://katiek2.github.io/path-doc/), or see the [Sass website](https://katiek2.github.io/path-doc/) for full installation instructions.
3. [Optional] **Themes**. To use a theme, you need to install Ruby and
[bundler](http://bundler.io/). Create a `Gemfile` that lists the theme., and
run `bundle install`. The [Jekyll theme
instructions](https://jekyllrb.com/docs/themes/) provide more detail, and
Expand Down Expand Up @@ -136,12 +140,12 @@ Upstream:

- Markdown:
- `<` and `>` inside markdown is interpreted as HTML. For example, `This is
<b>bold</b>` renders as <b>bold</b>. This behavior matches the [Markdown
<b>bold</b>` renders as <b>bold</b>. This behavior matches the [Markdown
spec](https://daringfireball.net/projects/markdown/syntax#html), but differs
from Jekyll's default Kramdown processor.
- The autogenerated id of a header that includes HTML is computed from the
text of the title, ignoring its attributes. For example, the id of `## Title
(<a href="https://example.com/path/to/details">ref</a>))` is `#title-ref`,
(<a href="https://example.com/path/to/details">ref</a>))` is `#title-ref`,
not `#title-https-example-path-to-details-ref`.
- Autogenerated header ids replace punctuation by the hyphens, rather than the
empty string. For example, the id of `## Either/or` is `#either-or` not
Expand Down Expand Up @@ -190,7 +194,7 @@ Muzukashii:
- [x] `--open-uri`, `--host`, `--port`
- [x] `--incremental`, `–watch`, `--force_polling`
- [ ] `--baseurl`, `--config`
- [ ] `--detach`, `--ssl`-* – not planned
- [ ] `--detach`, `--ssl`-\* – not planned
- [ ] `doctor`, `import`, `new`, `new-theme` – not planned
- [ ] Windows

Expand Down Expand Up @@ -234,20 +238,20 @@ specification. [Contributions of any kind welcome](./CONTRIBUTING.md)!

Gojekyll uses these libraries:

| Package | Author(s) | Usage | License |
| ------------------------------------------------------------------------------ | ------------------------------------------------------ | -------------------------------------- | --------------------------------------- |
| [github.com/jaschaephraim/lrserver](https://github.com/jaschaephraim/lrserver) | Jascha Ephraim | Live Reload | MIT License |
| [github.com/kyokomi/emoji](https://github.com/kyokomi/emoji) | kyokomi | `jemoji` plugin emulation | MIT License |
| [github.com/osteele/liquid](https://github.com/osteele/liquid) | yours truly | Liquid processor | MIT License |
| [github.com/pkg/browser](https://github.com/pkg/browser) | [pkg](https://github.com/pkg) | `serve --open-url` option | BSD 2-clause "Simplified" License |
| [github.com/radovskyb/watcher](https://github.com/radovskyb/watcher) | Benjamin Radovsky | Polling file watch (`--force_polling`) | BSD 3-clause "New" or "Revised" License |
| [github.com/russross/blackfriday](https://github.com/russross/blackfriday) | Russ Ross | Markdown processing | Simplified BSD License |
| [github.com/sass/libsass](https://github.com/sass/libsass) | Listed [here](https://https://github.com/sass/libsass) | C port of the Ruby SASS compiler | MIT License |
| [github.com/tdewolff/minify](https://github.com/tdewolff/minify) | Taco de Wolff | CSS minimization | MIT License |
| [github.com/wellington/go-libsass](https://github.com/wellington/go-libsass) | Drew Wells | Go bindings for **libsass** | ??? |
| [github.com/alecthomas/kingpin/v2](https://github.com/alecthomas/kingpin) | Alec Thomas | command-line arguments | MIT License |
| [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) | Alec Thomas | Syntax highlighter | MIT License |
| [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) | Canonical | YAML support | Apache License 2.0 |
| Package | Author(s) | Usage | License |
| ------------------------------------------------------------------------------ | ------------------------------------------------ | ---------------------------------------------------------- | --------------------------------------- |
| [github.com/jaschaephraim/lrserver](https://github.com/jaschaephraim/lrserver) | Jascha Ephraim | Live Reload | MIT License |
| [github.com/kyokomi/emoji](https://github.com/kyokomi/emoji) | kyokomi | `jemoji` plugin emulation | MIT License |
| [github.com/osteele/liquid](https://github.com/osteele/liquid) | yours truly | Liquid processor | MIT License |
| [github.com/pkg/browser](https://github.com/pkg/browser) | [pkg](https://github.com/pkg) | `serve --open-url` option | BSD 2-clause "Simplified" License |
| [github.com/radovskyb/watcher](https://github.com/radovskyb/watcher) | Benjamin Radovsky | Polling file watch (`--force_polling`) | BSD 3-clause "New" or "Revised" License |
| [github.com/danog/blackfriday](https://github.com/danog/blackfriday) | Russ Ross, Daniil Gentili | Markdown processing | Simplified BSD License |
| [github.com/sass/dart-sass](https://github.com/sass/dart-sass) | Listed [here](https://github.com/sass/dart-sass) | The reference implementation of Sass, written in Dart. | MIT License |
| [github.com/tdewolff/minify](https://github.com/tdewolff/minify) | Taco de Wolff | CSS minimization | MIT License |
| [github.com/bep/godartsass](https://github.com/bep/godartsass) | Drew Wells | Go API backed by the native Dart Sass Embedded executable. | MIT License |
| [github.com/alecthomas/kingpin/v2](https://github.com/alecthomas/kingpin) | Alec Thomas | command-line arguments | MIT License |
| [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) | Alec Thomas | Syntax highlighter | MIT License |
| [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) | Canonical | YAML support | Apache License 2.0 |

In addition, the following pieces of text were taken from Jekyll and its plugins.
They are used under the terms of the MIT License.
Expand All @@ -269,7 +273,7 @@ under the [Creative Commons Attribution-Share Alike 3.0 Unported
license](https://creativecommons.org/licenses/by-sa/3.0/deed.en).

In addition to being totally and obviously inspired by Jekyll and its plugins,
Jekyll's solid *documentation* was indispensible --- especially since I wanted
Jekyll's solid _documentation_ was indispensible --- especially since I wanted
to implement Jekyll as documented, not port its source code. The [Jekyll
docs](https://jekyllrb.com/docs/home/) were always open in at least one tab
during development.
Expand All @@ -291,15 +295,11 @@ MIT

[coveralls-url]: https://coveralls.io/r/osteele/gojekyll
[coveralls-svg]: https://img.shields.io/coveralls/osteele/gojekyll.svg?branch=master

[license-url]: https://github.com/osteele/gojekyll/blob/master/LICENSE
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg

[go-url]: https://github.com/osteele/gojekyll/actions?query=workflow%3A%22Build+Status%22
[go-svg]: https://github.com/osteele/gojekyll/actions/workflows/go.yml/badge.svg

[golangci-lint-url]: https://github.com/osteele/gojekyll/actions?query=workflow%3Agolangci-lint
[golangci-lint-svg]: https://github.com/osteele/gojekyll/actions/workflows/golangci-lint.yml/badge.svg

[go-report-card-url]: https://goreportcard.com/report/github.com/osteele/gojekyll
[go-report-card-svg]: https://goreportcard.com/badge/github.com/osteele/gojekyll
[go-report-card-svg]: https://goreportcard.com/badge/github.com/osteele/gojekyll
21 changes: 8 additions & 13 deletions filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"strings"
"time"

sass "github.com/bep/godartsass/v2"
"github.com/danog/blackfriday/v2"
"github.com/osteele/gojekyll/config"
"github.com/osteele/gojekyll/utils"
"github.com/osteele/liquid"
"github.com/osteele/liquid/evaluator"
"github.com/osteele/liquid/expressions"
libsass "github.com/wellington/go-libsass"
)

// AddJekyllFilters adds the Jekyll filters to the Liquid engine.
Expand Down Expand Up @@ -285,19 +285,14 @@ func whereFilter(array []map[string]interface{}, key string, value interface{})
}

// string filters
var comp, compErr = sass.Start(sass.Options{})

func scssifyFilter(s string) (string, error) {
// this doesn't try to share context or setup with the rendering manager,
// and it doesn't minify
buf := new(bytes.Buffer)
comp, err := libsass.New(buf, bytes.NewBufferString(s))
if err != nil {
return "", err
if compErr != nil {
return "", compErr
}
// err = comp.Option(libsass.WithSyntax(libsass.SassSyntax))
if err != nil {
return "", err
}
err = comp.Run()
return buf.String(), err
res, err := comp.Execute(sass.Args{
Source: s,
})
return res.CSS, err
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.20
require (
github.com/alecthomas/chroma v0.10.0
github.com/alecthomas/kingpin/v2 v2.3.2
github.com/bep/godartsass/v2 v2.0.0
github.com/danog/blackfriday/v2 v2.1.6
github.com/fsnotify/fsnotify v1.6.0
github.com/google/go-github v17.0.0+incompatible
Expand All @@ -17,14 +18,14 @@ require (
github.com/radovskyb/watcher v1.0.7
github.com/stretchr/testify v1.8.4
github.com/tdewolff/minify v2.3.6+incompatible
github.com/wellington/go-libsass v0.9.3-0.20230226164013-e1cda027356e
golang.org/x/net v0.14.0
golang.org/x/oauth2 v0.11.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/cli/safeexec v1.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWr
github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/bep/godartsass/v2 v2.0.0 h1:Ruht+BpBWkpmW+yAM2dkp7RSSeN0VLaTobyW0CiSP3Y=
github.com/bep/godartsass/v2 v2.0.0/go.mod h1:AcP8QgC+OwOXEq6im0WgDRYK7scDsmZCEW62o1prQLo=
github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00=
github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
github.com/danog/blackfriday/v2 v2.1.6 h1:X8eMk7/+AgFxnkINl3k8P2M7k1LrPSrt/GajW7duyMM=
github.com/danog/blackfriday/v2 v2.1.6/go.mod h1:LwBcWUEJB70NEUayhCkcsNRhiIG48Umt9idrfVfygbQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -12,6 +16,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/frankban/quicktest v1.14.2 h1:SPb1KFFmM+ybpEjPUhCCkZOM5xlovT5UbrMvWnXyBns=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand All @@ -35,6 +40,8 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQ
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kyokomi/emoji v2.2.4+incompatible h1:np0woGKwx9LiHAQmwZx79Oc0rHpNw3o+3evou4BEPv4=
github.com/kyokomi/emoji v2.2.4+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand All @@ -54,6 +61,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE=
github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
Expand All @@ -68,8 +76,6 @@ github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxp
github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0=
github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/wellington/go-libsass v0.9.3-0.20230226164013-e1cda027356e h1:jSNg5uEi+AadUqT1f8YRLN/Up0PwUErIxurK45Pm/74=
github.com/wellington/go-libsass v0.9.3-0.20230226164013-e1cda027356e/go.mod h1:C8euON6AYoxBky77yeAp0URarLRy4Kipk65rKDXpHcA=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
Loading

0 comments on commit c3d781e

Please sign in to comment.