-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3f9818
commit 2d8abf9
Showing
7 changed files
with
221 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# gulp-google-webfonts | ||
|
||
A gulp plugin to download Google webfonts and generate a stylesheet for them. | ||
|
||
# Example #1 | ||
: example1/ | ||
|
||
## Input | ||
|
||
### fonts.list | ||
|
||
< fonts.list | ||
|
||
### gulpfile.js | ||
|
||
< gulpfile.js | ||
|
||
## Output | ||
|
||
$ gulp fonts | ||
gulp fonts | ||
|
||
### out/fonts/ | ||
|
||
| ls -1 out/fonts/ | ||
|
||
### out/fonts/fonts.css | ||
|
||
< out/fonts/fonts.css | ||
|
||
# Options | ||
|
||
The googleWebFonts object can take the following options: | ||
|
||
* fontsDir - The path the output fonts should be under. (Note: the path is relative to `gulp.dest`) | ||
* cssDir - The path the output css should be under. (Note: the path is relative to `gulp.dest`) | ||
* cssFilename - The filename of the output css file. | ||
|
||
# Example #2 | ||
$ cd $root/example2/ | ||
|
||
## Input (other inputs same as example #1) | ||
|
||
### gulpfile.js | ||
|
||
< gulpfile.js | ||
|
||
## Output | ||
|
||
$ gulp fonts | ||
gulp fonts | ||
|
||
### out/ | ||
: example2/out/ | ||
|
||
| find fonts/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "example1", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "gulpfile.js", | ||
"scripts": { | ||
"test": "gulp" | ||
}, | ||
"author": "Mark K Cowan", | ||
"license": "ISC", | ||
"dependencies": { | ||
"gulp-google-webfonts": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "example2", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "gulpfile.js", | ||
"scripts": { | ||
"test": "gulp" | ||
}, | ||
"author": "Mark K Cowan", | ||
"license": "ISC", | ||
"dependencies": { | ||
"gulp-google-webfonts": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
# Literal markdown, by Mark K Cowan mark@battlesnake.co.uk | ||
# | ||
# Special lines are lines beginning with: | ||
# : [dir] - enter directory [dir], relative to LMD file | ||
# < [file] - read contents of [file] and tab-indent it into MD file | ||
# | [shell_cmd] - execute [shell_cmd] and tab-indent outputs into MD file | ||
# $ [shell_cmd] - execute [shell_cmd] and direct outputs to STDERR | ||
# | ||
# Special lines must not be indented, the first character on the line must be | ||
# the special character. | ||
|
||
set -euo pipefail | ||
|
||
if [ "${1:---help}" == "--help" ]; then | ||
printf -- "Syntax: make-docs.sh <docfile>.lmd\n\n" | ||
printf -- "Write output to <docfile>.md\n\n" | ||
false | ||
fi | ||
|
||
declare -r root="$(realpath "$(dirname "$1")")" | ||
declare -r in="$(basename "$1")" | ||
declare -r out="${in%.lmd}.md" | ||
|
||
cd "${root}" | ||
|
||
function indent { | ||
local line | ||
while read line; do | ||
printf -- "\t%s\n" "${line}" | ||
done | ||
} | ||
|
||
function enter_dir { | ||
local -r dir="$1" | ||
cd "${root}/${dir}" | ||
} | ||
|
||
function read_in { | ||
local -r file="$1" | ||
printf >&2 -- "Read '%s' from '%s'\n" "${file}" "${PWD}" | ||
<"${file}" indent | ||
} | ||
|
||
function pipe_in { | ||
local -ra args=( $@ ) | ||
printf >&2 -- "Pipe in" | ||
printf >&2 -- " '%s'" "${args[@]}" | ||
printf >&2 -- " from '%s'\n" "${PWD}" | ||
"${args[@]}" | indent | ||
} | ||
|
||
function map_line { | ||
local -r line="$1" | ||
|
||
local -r first="${line:0:1}" | ||
local -r rest="$(echo "${line:1}" | sed -e 's/^\s*//')" | ||
|
||
case "${first}" in | ||
":") enter_dir "${rest}";; | ||
"<") read_in "${rest}";; | ||
"|") pipe_in "${rest}";; | ||
"$") >&2 eval "${rest}";; | ||
*) printf -- "%s\n" "${line}";; | ||
esac | ||
} | ||
|
||
while IFS='' read __line; do | ||
|
||
map_line "${__line}" | ||
|
||
done < "${in}" > "${out}" |