glyph 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +80 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/bin/glyph +7 -0
- data/book/config.yml +5 -0
- data/book/document.glyph +55 -0
- data/book/images/glyph.png +0 -0
- data/book/images/glyph.svg +351 -0
- data/book/lib/macros/reference.rb +98 -0
- data/book/output/html/glyph.html +1809 -0
- data/book/output/html/images/glyph.png +0 -0
- data/book/output/html/images/glyph.svg +351 -0
- data/book/output/pdf/glyph.pdf +4277 -0
- data/book/snippets.yml +13 -0
- data/book/styles/css3.css +220 -0
- data/book/styles/default.css +190 -0
- data/book/text/authoring.textile +351 -0
- data/book/text/extending.textile +148 -0
- data/book/text/getting_started.textile +152 -0
- data/book/text/introduction.textile +88 -0
- data/book/text/ref_commands.textile +74 -0
- data/book/text/ref_config.textile +0 -0
- data/book/text/ref_macros.textile +256 -0
- data/book/text/troubleshooting.textile +118 -0
- data/config.yml +63 -0
- data/document.glyph +29 -0
- data/glyph.gemspec +138 -0
- data/lib/glyph.rb +128 -0
- data/lib/glyph/commands.rb +124 -0
- data/lib/glyph/config.rb +152 -0
- data/lib/glyph/document.rb +145 -0
- data/lib/glyph/glyph_language.rb +530 -0
- data/lib/glyph/glyph_language.treetop +27 -0
- data/lib/glyph/interpreter.rb +84 -0
- data/lib/glyph/macro.rb +69 -0
- data/lib/glyph/node.rb +126 -0
- data/lib/glyph/system_extensions.rb +77 -0
- data/macros/common.rb +66 -0
- data/macros/filters.rb +69 -0
- data/macros/html/block.rb +119 -0
- data/macros/html/inline.rb +43 -0
- data/macros/html/structure.rb +138 -0
- data/spec/files/container.textile +5 -0
- data/spec/files/document.glyph +2 -0
- data/spec/files/document_with_toc.glyph +3 -0
- data/spec/files/included.textile +4 -0
- data/spec/files/ligature.jpg +449 -0
- data/spec/files/markdown.markdown +8 -0
- data/spec/files/test.sass +2 -0
- data/spec/lib/commands_spec.rb +83 -0
- data/spec/lib/config_spec.rb +79 -0
- data/spec/lib/document_spec.rb +100 -0
- data/spec/lib/glyph_spec.rb +76 -0
- data/spec/lib/interpreter_spec.rb +90 -0
- data/spec/lib/macro_spec.rb +60 -0
- data/spec/lib/node_spec.rb +76 -0
- data/spec/macros/filters_spec.rb +42 -0
- data/spec/macros/macros_spec.rb +159 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/tasks/generate_spec.rb +31 -0
- data/spec/tasks/load_spec.rb +37 -0
- data/spec/tasks/project_spec.rb +41 -0
- data/styles/css3.css +220 -0
- data/styles/default.css +190 -0
- data/tasks/generate.rake +57 -0
- data/tasks/load.rake +55 -0
- data/tasks/project.rake +33 -0
- metadata +192 -0
data/tasks/generate.rake
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
namespace :generate do
|
4
|
+
|
5
|
+
desc "Process source"
|
6
|
+
task :document => ["load:all"] do
|
7
|
+
info "Parsing '#{cfg('document.source')}'..."
|
8
|
+
text = file_load Glyph::PROJECT/cfg('document.source')
|
9
|
+
interpreter = Glyph::Interpreter.new text, :source => "file: #{cfg('document.source')}"
|
10
|
+
info "Processing..."
|
11
|
+
interpreter.process
|
12
|
+
info "Post-processing..."
|
13
|
+
interpreter.postprocess
|
14
|
+
Glyph::DOCUMENT = interpreter.document
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Create a standalone html file"
|
18
|
+
task :html => :document do
|
19
|
+
info "Generating HTML file..."
|
20
|
+
out = Glyph::PROJECT/"output/html"
|
21
|
+
out.mkpath
|
22
|
+
file = "#{cfg('document.filename')}.html"
|
23
|
+
file_write out/file, Glyph::DOCUMENT.output
|
24
|
+
info "'#{cfg('document.filename')}.html' generated successfully."
|
25
|
+
images = Glyph::PROJECT/'output/html/images'
|
26
|
+
images.mkpath
|
27
|
+
(Glyph::PROJECT/'images').find do |i|
|
28
|
+
if i.file? then
|
29
|
+
dest = "#{Glyph::PROJECT/'output/html/images'}/#{i.relative_path_from(Glyph::PROJECT/'images')}"
|
30
|
+
Pathname.new(dest).parent.mkpath
|
31
|
+
file_copy i.to_s, dest
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Create a pdf file"
|
37
|
+
task :pdf => :html do
|
38
|
+
info "Generating PDF file..."
|
39
|
+
out = Glyph::PROJECT/"output/pdf"
|
40
|
+
out.mkpath
|
41
|
+
file = cfg('document.filename')
|
42
|
+
case cfg('pdf_renderer')
|
43
|
+
when 'prince' then
|
44
|
+
ENV['PATH'] += ";#{ENV['ProgramFiles']}\\Prince\\Engine\\bin" if RUBY_PLATFORM.match /mswin/
|
45
|
+
res = system "prince #{Glyph::PROJECT/"output/html/#{file}.html"} -o #{out/"#{file}.pdf"}"
|
46
|
+
if res then
|
47
|
+
info "'#{file}.pdf' generated successfully."
|
48
|
+
else
|
49
|
+
warning "An error occurred while generating #{file}.pdf"
|
50
|
+
end
|
51
|
+
# TODO: support other PDF renderers
|
52
|
+
else
|
53
|
+
warning "Glyph cannot generate PDF. Please specify a valid pdf_renderer setting."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/tasks/load.rake
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
namespace :load do
|
4
|
+
|
5
|
+
desc "Load all files"
|
6
|
+
task :all => [:config, :snippets, :macros] do
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Load snippets"
|
10
|
+
task :snippets do
|
11
|
+
raise RuntimeError, "The current directory is not a valid Glyph project" unless Glyph.project?
|
12
|
+
info "Loading snippets..."
|
13
|
+
snippets = yaml_load Glyph::PROJECT/'snippets.yml'
|
14
|
+
raise RuntimeError, "Invalid snippets file" unless snippets.blank? || snippets.is_a?(Hash)
|
15
|
+
Glyph::SNIPPETS.replace snippets
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Load macros"
|
19
|
+
task :macros do
|
20
|
+
raise RuntimeError, "The current directory is not a valid Glyph project" unless Glyph.project?
|
21
|
+
info "Loading macros..."
|
22
|
+
load_macros = lambda do |macro_base|
|
23
|
+
macro_base.children.each do |c|
|
24
|
+
Glyph.instance_eval file_load(c) unless c.directory?
|
25
|
+
end
|
26
|
+
macro_dir = macro_base/cfg("filters.target").to_s
|
27
|
+
if macro_dir.exist? then
|
28
|
+
macro_dir.children.each do |f|
|
29
|
+
Glyph.instance_eval file_load(f)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
load_macros.call Glyph::HOME/"macros"
|
34
|
+
load_macros.call Glyph::PROJECT/"lib/macros" rescue nil
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Load configuration files"
|
38
|
+
task :config do
|
39
|
+
raise RuntimeError, "The current directory is not a valid Glyph project" unless Glyph.project?
|
40
|
+
# Save overrides set by commands...
|
41
|
+
overrides = Glyph::PROJECT_CONFIG.dup
|
42
|
+
Glyph::PROJECT_CONFIG.read
|
43
|
+
Glyph::PROJECT_CONFIG.merge! overrides
|
44
|
+
Glyph::SYSTEM_CONFIG.read
|
45
|
+
Glyph::GLOBAL_CONFIG.read
|
46
|
+
Glyph.reset_config
|
47
|
+
Glyph.config_override("structure.headers",
|
48
|
+
[:section] +
|
49
|
+
cfg('structure.frontmatter') +
|
50
|
+
cfg('structure.backmatter') +
|
51
|
+
cfg('structure.bodymatter') -
|
52
|
+
cfg('structure.hidden'))
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/tasks/project.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
namespace :project do
|
4
|
+
|
5
|
+
desc "Create a new Glyph project"
|
6
|
+
task :create, [:dir] do |t, args|
|
7
|
+
dir = Pathname.new args[:dir]
|
8
|
+
raise ArgumentError, "Directory #{dir} does not exist." unless dir.exist?
|
9
|
+
raise ArgumentError, "Directory #{dir} is not empty." unless dir.children.blank?
|
10
|
+
# Create subdirectories
|
11
|
+
subdirs = ['lib/tasks', 'lib/macros', 'lib/macros/html', 'lib', 'text', 'output', 'images', 'styles']
|
12
|
+
subdirs.each {|d| (dir/d).mkpath }
|
13
|
+
# Create snippets
|
14
|
+
yaml_dump Glyph::PROJECT/'snippets.yml', {:test => "This is a \nTest snippet"}
|
15
|
+
# Create files
|
16
|
+
file_copy Glyph::HOME/'document.glyph', Glyph::PROJECT/'document.glyph'
|
17
|
+
config = yaml_load Glyph::HOME/'config.yml'
|
18
|
+
config[:document][:filename] = dir.basename.to_s
|
19
|
+
config[:document][:author] = ENV['USER'] || ENV['USERNAME']
|
20
|
+
yaml_dump Glyph::PROJECT/'config.yml', config
|
21
|
+
info "Project '#{dir.basename}' created successfully."
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Add a new text file to the project"
|
25
|
+
task :add, [:file] do |t, args|
|
26
|
+
Glyph.enable 'project:add'
|
27
|
+
file = Glyph::PROJECT/"text/#{args[:file]}"
|
28
|
+
file.parent.mkpath
|
29
|
+
raise ArgumentError, "File '#{args[:file]}' already exists." if file.exist?
|
30
|
+
File.new(file.to_s, "w").close
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glyph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabio Cevasco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-04-09 00:00:00 +02:00
|
13
|
+
default_executable: glyph
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: gli
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.3.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: extlib
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.12
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: treetop
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.4.3
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rake
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.7
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: yard
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
description: Glyph is a framework for structured document authoring.
|
76
|
+
email: h3rald@h3rald.com
|
77
|
+
executables:
|
78
|
+
- glyph
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- README.textile
|
83
|
+
files:
|
84
|
+
- README.textile
|
85
|
+
- Rakefile
|
86
|
+
- VERSION
|
87
|
+
- bin/glyph
|
88
|
+
- book/config.yml
|
89
|
+
- book/document.glyph
|
90
|
+
- book/images/glyph.png
|
91
|
+
- book/images/glyph.svg
|
92
|
+
- book/lib/macros/reference.rb
|
93
|
+
- book/output/html/glyph.html
|
94
|
+
- book/output/html/images/glyph.png
|
95
|
+
- book/output/html/images/glyph.svg
|
96
|
+
- book/output/pdf/glyph.pdf
|
97
|
+
- book/snippets.yml
|
98
|
+
- book/styles/css3.css
|
99
|
+
- book/styles/default.css
|
100
|
+
- book/text/authoring.textile
|
101
|
+
- book/text/extending.textile
|
102
|
+
- book/text/getting_started.textile
|
103
|
+
- book/text/introduction.textile
|
104
|
+
- book/text/ref_commands.textile
|
105
|
+
- book/text/ref_config.textile
|
106
|
+
- book/text/ref_macros.textile
|
107
|
+
- book/text/troubleshooting.textile
|
108
|
+
- config.yml
|
109
|
+
- document.glyph
|
110
|
+
- glyph.gemspec
|
111
|
+
- lib/glyph.rb
|
112
|
+
- lib/glyph/commands.rb
|
113
|
+
- lib/glyph/config.rb
|
114
|
+
- lib/glyph/document.rb
|
115
|
+
- lib/glyph/glyph_language.rb
|
116
|
+
- lib/glyph/glyph_language.treetop
|
117
|
+
- lib/glyph/interpreter.rb
|
118
|
+
- lib/glyph/macro.rb
|
119
|
+
- lib/glyph/node.rb
|
120
|
+
- lib/glyph/system_extensions.rb
|
121
|
+
- macros/common.rb
|
122
|
+
- macros/filters.rb
|
123
|
+
- macros/html/block.rb
|
124
|
+
- macros/html/inline.rb
|
125
|
+
- macros/html/structure.rb
|
126
|
+
- spec/files/container.textile
|
127
|
+
- spec/files/document.glyph
|
128
|
+
- spec/files/document_with_toc.glyph
|
129
|
+
- spec/files/included.textile
|
130
|
+
- spec/files/ligature.jpg
|
131
|
+
- spec/files/markdown.markdown
|
132
|
+
- spec/files/test.sass
|
133
|
+
- spec/lib/commands_spec.rb
|
134
|
+
- spec/lib/config_spec.rb
|
135
|
+
- spec/lib/document_spec.rb
|
136
|
+
- spec/lib/glyph_spec.rb
|
137
|
+
- spec/lib/interpreter_spec.rb
|
138
|
+
- spec/lib/macro_spec.rb
|
139
|
+
- spec/lib/node_spec.rb
|
140
|
+
- spec/macros/filters_spec.rb
|
141
|
+
- spec/macros/macros_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
- spec/tasks/generate_spec.rb
|
144
|
+
- spec/tasks/load_spec.rb
|
145
|
+
- spec/tasks/project_spec.rb
|
146
|
+
- styles/css3.css
|
147
|
+
- styles/default.css
|
148
|
+
- tasks/generate.rake
|
149
|
+
- tasks/load.rake
|
150
|
+
- tasks/project.rake
|
151
|
+
has_rdoc: true
|
152
|
+
homepage: http://www.h3rald.com/glyph/
|
153
|
+
licenses: []
|
154
|
+
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options:
|
157
|
+
- --charset=UTF-8
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: "0"
|
165
|
+
version:
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: "0"
|
171
|
+
version:
|
172
|
+
requirements: []
|
173
|
+
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 1.3.5
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Glyph -- A Ruby-powered Document Authoring Framework
|
179
|
+
test_files:
|
180
|
+
- spec/macros/filters_spec.rb
|
181
|
+
- spec/macros/macros_spec.rb
|
182
|
+
- spec/lib/interpreter_spec.rb
|
183
|
+
- spec/lib/commands_spec.rb
|
184
|
+
- spec/lib/node_spec.rb
|
185
|
+
- spec/lib/macro_spec.rb
|
186
|
+
- spec/lib/config_spec.rb
|
187
|
+
- spec/lib/glyph_spec.rb
|
188
|
+
- spec/lib/document_spec.rb
|
189
|
+
- spec/tasks/load_spec.rb
|
190
|
+
- spec/tasks/generate_spec.rb
|
191
|
+
- spec/tasks/project_spec.rb
|
192
|
+
- spec/spec_helper.rb
|