deplate 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +26 -0
- data/CHANGES.TXT +177 -0
- data/LICENSE.TXT +340 -0
- data/NEWS.TXT +29 -0
- data/README.TXT +86 -0
- data/TODO.TXT +202 -0
- data/VERSION.TXT +1 -0
- data/bin/deplate +3 -0
- data/bin/deplate.bat +2 -0
- data/etc/deplate.ini +361 -0
- data/lib/deplate.rb +31 -0
- data/lib/deplate/abstract-class.rb +30 -0
- data/lib/deplate/builtin.rb +11 -0
- data/lib/deplate/cache.rb +59 -0
- data/lib/deplate/commands.rb +693 -0
- data/lib/deplate/common.rb +335 -0
- data/lib/deplate/converter.rb +99 -0
- data/lib/deplate/core.rb +2705 -0
- data/lib/deplate/css/article.css +545 -0
- data/lib/deplate/css/deplate.css +699 -0
- data/lib/deplate/css/heading-navbar.css +29 -0
- data/lib/deplate/css/layout-deplate-print.css +540 -0
- data/lib/deplate/css/layout-deplate.css +764 -0
- data/lib/deplate/css/sans-serif.css +160 -0
- data/lib/deplate/css/serif-e.css +170 -0
- data/lib/deplate/css/serif-rel.css +121 -0
- data/lib/deplate/css/serif.css +190 -0
- data/lib/deplate/css/slides.css +11 -0
- data/lib/deplate/css/tabbar-left.css +91 -0
- data/lib/deplate/css/tabbar-right-ie.css +14 -0
- data/lib/deplate/css/tabbar-right.css +118 -0
- data/lib/deplate/css/tabbar-top.css +64 -0
- data/lib/deplate/css/tabbar.css +81 -0
- data/lib/deplate/css/text-sans-serif.css +154 -0
- data/lib/deplate/css/text-serif.css +175 -0
- data/lib/deplate/define.rb +439 -0
- data/lib/deplate/docbook.rb +738 -0
- data/lib/deplate/elements.rb +1355 -0
- data/lib/deplate/etc.rb +199 -0
- data/lib/deplate/external.rb +135 -0
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +21 -0
- data/lib/deplate/fmt/dbk-article.rb +46 -0
- data/lib/deplate/fmt/dbk-book.rb +46 -0
- data/lib/deplate/fmt/dbk-ref.rb +105 -0
- data/lib/deplate/fmt/dbk-slides.rb +47 -0
- data/lib/deplate/fmt/dbk-snippet.rb +21 -0
- data/lib/deplate/fmt/html-snippet.rb +21 -0
- data/lib/deplate/fmt/html.rb +1696 -0
- data/lib/deplate/fmt/htmlsite.rb +419 -0
- data/lib/deplate/fmt/htmlslides.rb +21 -0
- data/lib/deplate/fmt/htmlwebsite.rb +70 -0
- data/lib/deplate/fmt/latex-snippet.rb +22 -0
- data/lib/deplate/fmt/latex.rb +1242 -0
- data/lib/deplate/fmt/php.rb +19 -0
- data/lib/deplate/fmt/phpsite.rb +19 -0
- data/lib/deplate/fmt/plain.rb +598 -0
- data/lib/deplate/fmt/template.rb +34 -0
- data/lib/deplate/fmt/xhtml10t.rb +41 -0
- data/lib/deplate/formatter-snippet.rb +17 -0
- data/lib/deplate/formatter.rb +1210 -0
- data/lib/deplate/input.rb +492 -0
- data/lib/deplate/input/deplate-headings.rb +48 -0
- data/lib/deplate/input/deplate-restricted.rb +70 -0
- data/lib/deplate/input/deplate.rb +28 -0
- data/lib/deplate/input/rdoc.rb +277 -0
- data/lib/deplate/input/template.rb +29 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +15 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +15 -0
- data/lib/deplate/lib/tabmenu.js +146 -0
- data/lib/deplate/locale/de.latin1 +708 -0
- data/lib/deplate/locale/ru.koi8-r +48 -0
- data/lib/deplate/locale/zh_cn.gb2312 +35 -0
- data/lib/deplate/macros.rb +639 -0
- data/lib/deplate/messages.rb +120 -0
- data/lib/deplate/metadata.rb +77 -0
- data/lib/deplate/metadata/marshal.rb +24 -0
- data/lib/deplate/metadata/xml.rb +42 -0
- data/lib/deplate/metadata/yaml.rb +26 -0
- data/lib/deplate/mod/anyword.rb +56 -0
- data/lib/deplate/mod/babelfish.rb +27 -0
- data/lib/deplate/mod/code-gvim.rb +52 -0
- data/lib/deplate/mod/code-highlight.rb +91 -0
- data/lib/deplate/mod/colored-log.rb +17 -0
- data/lib/deplate/mod/de.rb +19 -0
- data/lib/deplate/mod/en.rb +17 -0
- data/lib/deplate/mod/endnotes.rb +60 -0
- data/lib/deplate/mod/fr.rb +46 -0
- data/lib/deplate/mod/html-asciimath.rb +40 -0
- data/lib/deplate/mod/html-deplate-button.rb +15 -0
- data/lib/deplate/mod/html-headings-navbar.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +47 -0
- data/lib/deplate/mod/html-sidebar.rb +232 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +32 -0
- data/lib/deplate/mod/iconv.rb +35 -0
- data/lib/deplate/mod/imgurl.rb +30 -0
- data/lib/deplate/mod/inlatex-compound.rb +69 -0
- data/lib/deplate/mod/koma.rb +109 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +38 -0
- data/lib/deplate/mod/latex-styles.rb +461 -0
- data/lib/deplate/mod/latex-verbatim-small.rb +29 -0
- data/lib/deplate/mod/makefile.rb +194 -0
- data/lib/deplate/mod/mark-external-urls.rb +38 -0
- data/lib/deplate/mod/markup-1-warn.rb +37 -0
- data/lib/deplate/mod/markup-1.rb +41 -0
- data/lib/deplate/mod/navbar-png.rb +33 -0
- data/lib/deplate/mod/noindent.rb +32 -0
- data/lib/deplate/mod/numpara.rb +40 -0
- data/lib/deplate/mod/particle-math.rb +34 -0
- data/lib/deplate/mod/php-extra.rb +44 -0
- data/lib/deplate/mod/pstoedit.rb +71 -0
- data/lib/deplate/mod/recode.rb +57 -0
- data/lib/deplate/mod/ru_koi8-r.rb +20 -0
- data/lib/deplate/mod/smiley.rb +50 -0
- data/lib/deplate/mod/soffice.rb +23 -0
- data/lib/deplate/mod/symbols-latin1.rb +58 -0
- data/lib/deplate/mod/symbols-od-utf-8.rb +16 -0
- data/lib/deplate/mod/symbols-plain.rb +58 -0
- data/lib/deplate/mod/symbols-sgml.rb +97 -0
- data/lib/deplate/mod/symbols-utf-8.rb +81 -0
- data/lib/deplate/mod/symbols-xml.rb +34 -0
- data/lib/deplate/mod/syntax-region-alt.rb +37 -0
- data/lib/deplate/mod/utf8.rb +49 -0
- data/lib/deplate/mod/validate-html.rb +35 -0
- data/lib/deplate/mod/xmlrpc.rb +233 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +108 -0
- data/lib/deplate/mod/zh-cn.rb +59 -0
- data/lib/deplate/once-method.rb +44 -0
- data/lib/deplate/output.rb +249 -0
- data/lib/deplate/particles.rb +815 -0
- data/lib/deplate/regions.rb +1076 -0
- data/lib/deplate/structured.rb +763 -0
- data/lib/deplate/template.rb +430 -0
- data/lib/deplate/templates/html-doc.html +28 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +37 -0
- data/lib/deplate/templates/html-left-tabbar.html +31 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +43 -0
- data/lib/deplate/templates/html-tabbar-right.html +23 -0
- data/lib/deplate/templates/html-tabbar-top.html +43 -0
- data/lib/deplate/templates/html-tabbar.html +31 -0
- data/lib/deplate/wiki-markup.rb +117 -0
- data/lib/deplate/xml.rb +109 -0
- data/lib/deplate/zh-cn.rb +59 -0
- data/lib/ps2ppm.rb +239 -0
- data/man/man1/deplate.1 +692 -0
- metadata +210 -0
data/lib/deplate.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# deplate.rb -- Convert wiki-like plain text pseudo markup to something else
|
3
|
+
# @Author: Thomas Link (samul AT web.de)
|
4
|
+
# @Website: http://deplate.sf.net/
|
5
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
6
|
+
# @Created: 24-Feb-2004.
|
7
|
+
# @Last Change: 16-Okt-2005.
|
8
|
+
|
9
|
+
require 'profile' if ARGV[0] == '--profile'
|
10
|
+
|
11
|
+
require 'deplate/core'
|
12
|
+
require 'deplate/input'
|
13
|
+
require 'deplate/output'
|
14
|
+
require 'deplate/cache'
|
15
|
+
require 'deplate/common'
|
16
|
+
require 'deplate/etc'
|
17
|
+
require 'deplate/elements'
|
18
|
+
require 'deplate/regions'
|
19
|
+
require 'deplate/commands'
|
20
|
+
require 'deplate/macros'
|
21
|
+
require 'deplate/particles'
|
22
|
+
require 'deplate/define'
|
23
|
+
require 'deplate/template'
|
24
|
+
require 'deplate/external'
|
25
|
+
require 'deplate/metadata'
|
26
|
+
|
27
|
+
if __FILE__ == $0
|
28
|
+
require 'deplate/builtin'
|
29
|
+
Deplate::Core.deplate
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# DefAbstract.rb
|
2
|
+
# @Created: 18-M�r-2004.
|
3
|
+
# @Last Change: 23-Okt-2005.
|
4
|
+
# @Revision: 0.10
|
5
|
+
#
|
6
|
+
# Description:
|
7
|
+
# From: http://groups.google.at/groups?hl=de&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&selm=20030821221909.53f3274a.rpav%40mephle.com&rnum=38
|
8
|
+
# Von:Ryan Pavlik (rpav@mephle.com)
|
9
|
+
# Betrifft:Re: Class variables - a surprising result
|
10
|
+
# Newsgroups:comp.lang.ruby
|
11
|
+
# Datum:2003-08-21 22:20:26 PST
|
12
|
+
|
13
|
+
class SubclassResponsibility < Exception; end
|
14
|
+
|
15
|
+
class Module
|
16
|
+
def def_abstract(*args)
|
17
|
+
for sym in args
|
18
|
+
module_eval <<-CODE
|
19
|
+
def #{sym}(*args)
|
20
|
+
raise SubclassResponsibility
|
21
|
+
end
|
22
|
+
CODE
|
23
|
+
end
|
24
|
+
end #m:def_abstract
|
25
|
+
end #c:Module
|
26
|
+
|
27
|
+
# class B
|
28
|
+
# def_abstract :foo, :bar
|
29
|
+
# end
|
30
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# builtin.rb
|
2
|
+
# @Author: Thomas Link (samul AT web.de)
|
3
|
+
# @Website: http://deplate.sf.net/
|
4
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
+
# @Created: 05-Jun-2004.
|
6
|
+
# @Last Change: 23-Okt-2005.
|
7
|
+
# @Revision: 0.4
|
8
|
+
#
|
9
|
+
# Description:
|
10
|
+
# Dummy file
|
11
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# cache.rb
|
2
|
+
# @Author: Thomas Link (samul AT web.de)
|
3
|
+
# @Website: http://deplate.sf.net/
|
4
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
+
# @Created: 21-Aug-2005.
|
6
|
+
# @Last Change: 23-Okt-2005.
|
7
|
+
# @Revision: 0.25
|
8
|
+
|
9
|
+
# = Description
|
10
|
+
# This class provides a cache for dynamically generated classes.
|
11
|
+
class Deplate::Cache
|
12
|
+
@@custom_particles = {}
|
13
|
+
|
14
|
+
attr_reader :cls
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def particle(deplate, body, args)
|
18
|
+
register = args[:register]
|
19
|
+
new(@@custom_particles, Deplate::Particle, deplate, body, args) do |cls|
|
20
|
+
if register
|
21
|
+
args[:id] = body
|
22
|
+
deplate.register_particle(cls, args)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(cache, super_class, deplate, body, args={})
|
29
|
+
@deplate = deplate
|
30
|
+
@cache = cache
|
31
|
+
specific = args[:specific]
|
32
|
+
retrieve_particle(body, specific)
|
33
|
+
unless @cls
|
34
|
+
@cls = Class.new(super_class)
|
35
|
+
@cls.class_eval(body)
|
36
|
+
store_particle(body, specific)
|
37
|
+
end
|
38
|
+
if @cls and block_given?
|
39
|
+
yield(@cls)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def retrieve_particle(body, specific=false)
|
44
|
+
fmt = get_formatter_name(specific)
|
45
|
+
particles = @cache[fmt] ||= {}
|
46
|
+
@cls = particles[body]
|
47
|
+
end
|
48
|
+
|
49
|
+
def store_particle(body, specific=false)
|
50
|
+
fmt = get_formatter_name(specific)
|
51
|
+
particles = @cache[fmt] ||= {}
|
52
|
+
particles[body] = @cls
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_formatter_name(specific)
|
56
|
+
return specific ? @deplate.formatter.formatter_name : :general
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,693 @@
|
|
1
|
+
# commands.rb
|
2
|
+
# @Author: Thomas Link (samul AT web.de)
|
3
|
+
# @Website: http://deplate.sf.net/
|
4
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
+
# @Created: 08-Mai-2004.
|
6
|
+
# @Last Change: 02-Nov-2005.
|
7
|
+
# @Revision: 0.932
|
8
|
+
|
9
|
+
# Description:
|
10
|
+
#
|
11
|
+
# Usage:
|
12
|
+
#
|
13
|
+
# TODO:
|
14
|
+
#
|
15
|
+
# CHANGES:
|
16
|
+
#
|
17
|
+
|
18
|
+
module Deplate::Names
|
19
|
+
def name_match_sf(text)
|
20
|
+
m = /^\s*(.+?),\s*(.+?)\s*$/.match(text)
|
21
|
+
return m ? {:firstname => m[2], :surname => m[1]} : nil
|
22
|
+
end
|
23
|
+
module_function :name_match_sf
|
24
|
+
|
25
|
+
def name_match_fs(text)
|
26
|
+
m = /^\s*(\S+(\s+\S+)*?)\s+(\S+)\s*$/.match(text)
|
27
|
+
return m ? {:firstname => m[1], :surname => m[3]} : nil
|
28
|
+
end
|
29
|
+
module_function :name_match_fs
|
30
|
+
end
|
31
|
+
|
32
|
+
class Deplate::Command < Deplate::Element
|
33
|
+
include Deplate::Names
|
34
|
+
|
35
|
+
@@commands = {}
|
36
|
+
|
37
|
+
class << self
|
38
|
+
# attr_reader :commands
|
39
|
+
def commands
|
40
|
+
@@commands
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_variables(hash, opts, args)
|
44
|
+
if args
|
45
|
+
d = args["date"]
|
46
|
+
args["date"] = get_date(d, args) if d
|
47
|
+
if opts["add"]
|
48
|
+
if opts["add"].kind_of?(String)
|
49
|
+
sep = opts["add"]
|
50
|
+
else
|
51
|
+
sep = " "
|
52
|
+
end
|
53
|
+
args.each_pair do |k,v|
|
54
|
+
if hash[k]
|
55
|
+
v = hash[k] + sep + v
|
56
|
+
end
|
57
|
+
hash[k] = v
|
58
|
+
end
|
59
|
+
else
|
60
|
+
hash.update(args)
|
61
|
+
end
|
62
|
+
else
|
63
|
+
Deplate::Core.log(["No arguments", opts], :error, src)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def setup(args, cmd)
|
69
|
+
@multiliner = false
|
70
|
+
@collapse = false
|
71
|
+
@name = cmd
|
72
|
+
@accum = [@text]
|
73
|
+
@can_be_labelled = false
|
74
|
+
@args.update(args)
|
75
|
+
setup_command
|
76
|
+
update_args
|
77
|
+
end
|
78
|
+
|
79
|
+
def setup_command
|
80
|
+
end
|
81
|
+
|
82
|
+
def finish
|
83
|
+
@elt = [ @accum.join(" ") ]
|
84
|
+
return self
|
85
|
+
end
|
86
|
+
|
87
|
+
def process
|
88
|
+
process_etc
|
89
|
+
@elt = @elt.join("\n")
|
90
|
+
return self
|
91
|
+
end
|
92
|
+
|
93
|
+
def format_special
|
94
|
+
format_unknown(self)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
class Deplate::Command::CAP < Deplate::Command
|
100
|
+
@@commands["CAP"] = self
|
101
|
+
@@commands["CAPTION"] = self
|
102
|
+
|
103
|
+
class << self
|
104
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
105
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
106
|
+
elt = deplate.parse_with_source(src, text, false)
|
107
|
+
last = array.last
|
108
|
+
if last.caption
|
109
|
+
Deplate::Core.log('Element already has a caption', :error, src)
|
110
|
+
else
|
111
|
+
last.level_as_string = deplate.get_current_heading
|
112
|
+
last.caption = Deplate::CaptionDef.new(elt, args)
|
113
|
+
last.register_caption
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
class Deplate::Command::LANG < Deplate::Command
|
121
|
+
@@commands["LANG"] = self
|
122
|
+
@@commands["LANGUAGE"] = self
|
123
|
+
|
124
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
125
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
126
|
+
deplate.set_lang(text)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
class Deplate::Command::INC < Deplate::Command
|
132
|
+
@@commands["INC"] = self
|
133
|
+
@@commands["INCLUDE"] = self
|
134
|
+
|
135
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
136
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
137
|
+
formatter_name = deplate.formatter.formatter_name
|
138
|
+
doc = args['doc'] || args['var'] || args['val']
|
139
|
+
if args.has_key?('file')
|
140
|
+
if text
|
141
|
+
Deplate::Core.log(['Conflicting arguments', 'file > @anonymous'], :error, src)
|
142
|
+
end
|
143
|
+
text = args['file']
|
144
|
+
end
|
145
|
+
|
146
|
+
embeddedTextRx = args['embeddedTextRx']
|
147
|
+
embeddedTextRx_orig = deplate.variables['embeddedTextRx']
|
148
|
+
deplate.variables['embeddedTextRx'] = embeddedTextRx if embeddedTextRx
|
149
|
+
|
150
|
+
embeddedVerbatim = args['embeddedVerbatim']
|
151
|
+
embeddedVerbatim_orig = deplate.variables['embeddedVerbatim']
|
152
|
+
deplate.variables['embeddedVerbatim'] = embeddedVerbatim if embeddedVerbatim
|
153
|
+
|
154
|
+
syntax = args['codeSyntax'] || args['syntax']
|
155
|
+
syntax_orig = deplate.variables['codeSyntax']
|
156
|
+
deplate.variables['codeSyntax'] = syntax if syntax
|
157
|
+
|
158
|
+
input_format = args['inputFormat']
|
159
|
+
pif = deplate.push_input_format(input_format)
|
160
|
+
|
161
|
+
begin
|
162
|
+
if doc
|
163
|
+
strings = deplate.variables[doc]
|
164
|
+
if strings
|
165
|
+
deplate.include_stringarray(strings, array, nil, src.file)
|
166
|
+
else
|
167
|
+
Deplate::Core.log(["Unknown doc variable", doc], :error, src)
|
168
|
+
end
|
169
|
+
elsif !text or text == ''
|
170
|
+
Deplate::Core.log(["Malformed command", cmd, text], :error, src)
|
171
|
+
else
|
172
|
+
pwd = File.dirname(deplate.current_source || "")
|
173
|
+
dirs = [
|
174
|
+
File.join(pwd, "deplate.rc", formatter_name, text),
|
175
|
+
File.join(pwd, "deplate.rc", text),
|
176
|
+
File.join(pwd, text),
|
177
|
+
]
|
178
|
+
dirs += Deplate::Core.library_directories("lib", formatter_name, text)
|
179
|
+
dirs += Deplate::Core.library_directories("lib", text)
|
180
|
+
dirs += Deplate::Core.library_directories(text)
|
181
|
+
# dirs = [
|
182
|
+
# File.join(pwd, "deplate.rc", formatter_name, text),
|
183
|
+
# File.join(pwd, "deplate.rc", text),
|
184
|
+
# File.join(pwd, text),
|
185
|
+
# File.join(Deplate::Core::CfgDir, "lib", formatter_name, text),
|
186
|
+
# File.join(Deplate::Core::CfgDir, "lib", text),
|
187
|
+
# File.join(Deplate::Core::CfgDir, text),
|
188
|
+
# File.join(Deplate::Core::LibDir, "lib", formatter_name, text),
|
189
|
+
# File.join(Deplate::Core::LibDir, "lib", text),
|
190
|
+
# File.join(Deplate::Core::DataDir, "lib", formatter_name, text),
|
191
|
+
# File.join(Deplate::Core::DataDir, "lib", text),
|
192
|
+
# ]
|
193
|
+
for fn in dirs
|
194
|
+
if !File.directory?(fn) and File.exists?(fn)
|
195
|
+
deplate.include_file(array, fn)
|
196
|
+
return
|
197
|
+
end
|
198
|
+
end
|
199
|
+
Deplate::Core.log(["File not found", text], :error, src)
|
200
|
+
end
|
201
|
+
ensure
|
202
|
+
deplate.variables['embeddedTextRx'] = embeddedTextRx_orig if embeddedTextRx
|
203
|
+
deplate.variables['embeddedVerbatim'] = embeddedVerbatim_orig if embeddedVerbatim
|
204
|
+
deplate.variables['codeSyntax'] = syntax_orig if syntax
|
205
|
+
deplate.pop_input_format(input_format) if pif
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
class Deplate::Command::DOC < Deplate::Command
|
212
|
+
@@commands["DOC"] = self
|
213
|
+
@@commands["VAR"] = self
|
214
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
215
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
216
|
+
opts, text = deplate.input.parse_args(text, nil, false)
|
217
|
+
for k, v in opts
|
218
|
+
deplate.register_metadata(src,
|
219
|
+
"type" => "variable",
|
220
|
+
"name" => k,
|
221
|
+
"value" => v
|
222
|
+
)
|
223
|
+
end
|
224
|
+
update_variables(deplate.variables, args, opts)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
class Deplate::Command::OPT < Deplate::Command
|
230
|
+
@@commands["OPT"] = self
|
231
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
232
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
233
|
+
elt = array.last
|
234
|
+
if elt
|
235
|
+
opts, text = deplate.input.parse_args(text, nil, false)
|
236
|
+
deplate.register_id(opts, elt)
|
237
|
+
update_variables(elt.args, args, opts)
|
238
|
+
elt.update_args
|
239
|
+
else
|
240
|
+
Deplate::Core.log(["No element given", match[0]], :error, src)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
class Deplate::Command::PUT < Deplate::Command
|
247
|
+
@@commands["PUT"] = self
|
248
|
+
@@commands["CLIP"] = self
|
249
|
+
@@commands["SET"] = self
|
250
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
251
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
252
|
+
id = args["id"]
|
253
|
+
if id
|
254
|
+
text = deplate.parse_with_source(src, text, false)
|
255
|
+
deplate.set_clip(id, Deplate::Element::Clip.new(text, deplate, src))
|
256
|
+
else
|
257
|
+
Deplate::Core.log(["No clip-id given", text], :error, src)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
|
263
|
+
class Deplate::Command::GET < Deplate::Command
|
264
|
+
@@commands["GET"] = self
|
265
|
+
@formatter = :format_GET
|
266
|
+
|
267
|
+
def setup_command
|
268
|
+
@id = @args["id"] || @accum[0]
|
269
|
+
end
|
270
|
+
|
271
|
+
def process
|
272
|
+
@elt = @deplate.get_clip(@id)
|
273
|
+
if @elt
|
274
|
+
return self
|
275
|
+
else
|
276
|
+
log(["GET: Clip not found", @id], :error)
|
277
|
+
return nil
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
class Deplate::Command::XARG < Deplate::Command
|
284
|
+
@@commands["XARG"] = self
|
285
|
+
@@commands["XVAL"] = self
|
286
|
+
|
287
|
+
def setup_command
|
288
|
+
id = args["id"] || @accum[0]
|
289
|
+
@elt = @deplate.variables[id]
|
290
|
+
if @elt
|
291
|
+
@elt = @elt.split(/[\n\r]/).each {|l| l.chomp!}
|
292
|
+
else
|
293
|
+
log(["Unknown variable", id, @name], :error)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def format_special
|
298
|
+
@elt
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
class Deplate::Command::ARG < Deplate::Command
|
304
|
+
@@commands["ARG"] = self
|
305
|
+
@@commands["VAL"] = self
|
306
|
+
|
307
|
+
class << self
|
308
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
309
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
310
|
+
id = args["id"] || text
|
311
|
+
val = deplate.variables[id]
|
312
|
+
if val
|
313
|
+
acc = val.split(/[\n\r]/)
|
314
|
+
acc.each {|l| l.chomp!}
|
315
|
+
d = deplate.options.master ? deplate.options.master : deplate
|
316
|
+
d.include_stringarray(acc, array, src.begin, src.file)
|
317
|
+
else
|
318
|
+
Deplate::Core.log(["Unknown variable", id, cmd], :error, src)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
class Deplate::Command::BIB < Deplate::Command
|
326
|
+
@@commands["BIB"] = self
|
327
|
+
class << self
|
328
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
329
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
330
|
+
bibs = text.strip.split(/\s*\|\s*/)
|
331
|
+
deplate.options.bib += bibs
|
332
|
+
deplate.formatter.read_bib(bibs)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
class Deplate::Command::TITLE < Deplate::Command
|
339
|
+
@@commands["TITLE"] = self
|
340
|
+
@@commands["TI"] = self
|
341
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
342
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
343
|
+
c = deplate.parse_with_source(src, text, false)
|
344
|
+
deplate.set_clip("title", Deplate::Element::Clip.new(c, deplate, src))
|
345
|
+
deplate.register_metadata(src,
|
346
|
+
"type" => "metadata",
|
347
|
+
"name" => "title",
|
348
|
+
"value" => text
|
349
|
+
)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
class Deplate::Command::AUTHOR < Deplate::Command
|
355
|
+
@@commands["AUTHOR"] = self
|
356
|
+
@@commands["AU"] = self
|
357
|
+
class << self
|
358
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
359
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
360
|
+
deplate.options.author ||= []
|
361
|
+
for this in text.split(/([;\/]|\s+(&|and))\s+/)
|
362
|
+
unless this =~ /^\s*([;\/&]|and)\s*$/
|
363
|
+
author = Deplate::Names.name_match_sf(this) ||
|
364
|
+
Deplate::Names.name_match_fs(this) || {}
|
365
|
+
sn = args["surname"]
|
366
|
+
author[:surname] = sn if sn
|
367
|
+
fn = args["firstname"]
|
368
|
+
author[:firstname] = fn if fn
|
369
|
+
if this.empty?
|
370
|
+
author[:name] = args["name"] || "%s %s" % [args["firstname"], args["surname"]]
|
371
|
+
else
|
372
|
+
author[:name] = this
|
373
|
+
end
|
374
|
+
author[:note] = args["note"]
|
375
|
+
deplate.options.author << author
|
376
|
+
end
|
377
|
+
end
|
378
|
+
sep = deplate.variables["authorSep"] || "; "
|
379
|
+
authors = deplate.options.author.collect {|h| h[:name]}
|
380
|
+
authors = authors.join(sep)
|
381
|
+
parsed = deplate.parse_with_source(src, authors, false)
|
382
|
+
deplate.set_clip("author", Deplate::Element::Clip.new(parsed, deplate, src))
|
383
|
+
deplate.register_metadata(src,
|
384
|
+
"type" => "metadata",
|
385
|
+
"name" => "author",
|
386
|
+
"value" => authors
|
387
|
+
)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
|
393
|
+
class Deplate::Command::AUTHORNOTE < Deplate::Command
|
394
|
+
@@commands["AUTHORNOTE"] = self
|
395
|
+
@@commands["AN"] = self
|
396
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
397
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
398
|
+
unless text.empty?
|
399
|
+
author = deplate.options.author.last
|
400
|
+
if author
|
401
|
+
author[:note] = text
|
402
|
+
end
|
403
|
+
end
|
404
|
+
ans = deplate.options.author.collect {|h| h[:note]}
|
405
|
+
sep = deplate.variables["authorSep"] || "; "
|
406
|
+
ans = ans.join(sep)
|
407
|
+
parsed = deplate.parse_with_source(src, ans, false)
|
408
|
+
deplate.set_clip("authornote", Deplate::Element::Clip.new(parsed, deplate, src))
|
409
|
+
deplate.register_metadata(src,
|
410
|
+
"type" => "metadata",
|
411
|
+
"name" => "authornote",
|
412
|
+
"value" => ans
|
413
|
+
)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
|
418
|
+
class Deplate::Command::DATE < Deplate::Command
|
419
|
+
@@commands["DATE"] = self
|
420
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
421
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
422
|
+
d = get_date(text, args)
|
423
|
+
c = deplate.parse_with_source(src, d, false)
|
424
|
+
deplate.set_clip(cmd.downcase, Deplate::Element::Clip.new(c, deplate, src))
|
425
|
+
deplate.register_metadata(src,
|
426
|
+
'type' => 'metadata',
|
427
|
+
'name' => 'date',
|
428
|
+
'value' => d
|
429
|
+
)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
class Deplate::Command::IMG < Deplate::Command
|
435
|
+
@@commands['IMG'] = self
|
436
|
+
@@commands['IMAGE'] = self
|
437
|
+
@@commands['FIG'] = self
|
438
|
+
@@commands['FIGURE'] = self
|
439
|
+
@formatter = :format_IMG
|
440
|
+
|
441
|
+
def register_caption
|
442
|
+
register_figure
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
|
447
|
+
class Deplate::Command::MAKETITLE < Deplate::Command
|
448
|
+
@@commands['MAKETITLE'] = self
|
449
|
+
@formatter = :format_title
|
450
|
+
end
|
451
|
+
|
452
|
+
|
453
|
+
class Deplate::Command::MAKEBIB < Deplate::Command
|
454
|
+
@@commands['MAKEBIB'] = self
|
455
|
+
@formatter = :format_MAKEBIB
|
456
|
+
end
|
457
|
+
|
458
|
+
|
459
|
+
class Deplate::Command::LIST < Deplate::Command
|
460
|
+
@@commands['LIST'] = self
|
461
|
+
@formatter = :format_LIST
|
462
|
+
end
|
463
|
+
|
464
|
+
|
465
|
+
class Deplate::Command::TABLE < Deplate::Command
|
466
|
+
@@commands['TABLE'] = self
|
467
|
+
def setup_command
|
468
|
+
if File.exist?(@text)
|
469
|
+
File.open(@text) {|io| @accum = io.read.split(/[\r\n]+/)}
|
470
|
+
else
|
471
|
+
log(['File not found', @text], :error)
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def finish
|
476
|
+
return Deplate::Regions::Table.make_char_separated(self, @accum, @args['sep'])
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
|
481
|
+
class Deplate::Command::IDX < Deplate::Command
|
482
|
+
@@commands['IDX'] = self
|
483
|
+
@formatter = :format_IDX
|
484
|
+
|
485
|
+
class << self
|
486
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
487
|
+
i = -1
|
488
|
+
while array[i] and array[i].kind_of?(Deplate::Element::Whitespace)
|
489
|
+
i -= 1
|
490
|
+
end
|
491
|
+
e = array[i]
|
492
|
+
if e
|
493
|
+
out = get_indices(e, deplate, args, text, src)
|
494
|
+
pseudocontainer = Deplate::PseudoContainer.new(deplate, :args => args)
|
495
|
+
e.postponed_preformat << Proc.new do |container|
|
496
|
+
out.collect! do |idx|
|
497
|
+
deplate.formatter.format_particle(:format_index, pseudocontainer, idx)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
e.postponed_format << Proc.new do |container|
|
501
|
+
out.delete('')
|
502
|
+
out.compact!
|
503
|
+
container.output(out.join) unless out.empty?
|
504
|
+
end
|
505
|
+
else
|
506
|
+
array << self.new(deplate, src, text, match, args, cmd)
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
def get_indices(container, deplate, args, text, source)
|
511
|
+
accum = []
|
512
|
+
auto = args['auto']
|
513
|
+
auto = deplate.variables['autoindex'] if auto.nil?
|
514
|
+
for i in text.split(/\s*;\s*/)
|
515
|
+
idx = deplate.add_index(nil, i, deplate.get_current_heading)
|
516
|
+
Deplate::Particle.auto_indexing(deplate, idx) if auto
|
517
|
+
accum << idx
|
518
|
+
container.add_metadata(source,
|
519
|
+
'type' => 'index',
|
520
|
+
'name' => idx.name,
|
521
|
+
'label' => idx.label
|
522
|
+
)
|
523
|
+
end
|
524
|
+
return accum
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
def setup_command
|
529
|
+
@accum = Deplate::Command::IDX.get_indices(self, @deplate, @args, @text, @source)
|
530
|
+
end
|
531
|
+
|
532
|
+
def finish
|
533
|
+
return self
|
534
|
+
end
|
535
|
+
|
536
|
+
def process
|
537
|
+
@accum.collect! do |idx|
|
538
|
+
deplate.formatter.format_particle(:format_index, self, idx)
|
539
|
+
end
|
540
|
+
@accum.delete("")
|
541
|
+
@accum.compact!
|
542
|
+
@elt = [ @accum.join ]
|
543
|
+
super
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
|
548
|
+
class Deplate::Command::AUTOIDX < Deplate::Command
|
549
|
+
@@commands["AUTOIDX"] = self
|
550
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
551
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
552
|
+
hd = deplate.get_current_heading
|
553
|
+
for i in text.split(/\s*;\s*/)
|
554
|
+
Deplate::Particle.auto_indexing(deplate, deplate.add_index(nil, i, hd))
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
|
560
|
+
class Deplate::Command::NOIDX < Deplate::Command
|
561
|
+
@@commands["NOIDX"] = self
|
562
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
563
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
564
|
+
for i in text.split(/\s*;\s*/)
|
565
|
+
deplate.remove_index(self, i)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
class Deplate::Command::DONTIDX < Deplate::Command
|
572
|
+
@@commands["DONTIDX"] = self
|
573
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
574
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
575
|
+
deplate.options.dont_index += text.split(/\s*;\s*/)
|
576
|
+
end
|
577
|
+
end
|
578
|
+
|
579
|
+
|
580
|
+
class Deplate::Command::WITH < Deplate::Command
|
581
|
+
@@commands["WITH"] = self
|
582
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
583
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
584
|
+
file = args["file"]
|
585
|
+
body = nil
|
586
|
+
if file
|
587
|
+
File.open(file) {|io| body = io.readlines}
|
588
|
+
else
|
589
|
+
arg = args["arg"]
|
590
|
+
if arg
|
591
|
+
body = deplate.variables[arg].split(/[\n\r]/)
|
592
|
+
end
|
593
|
+
end
|
594
|
+
if body
|
595
|
+
body.each {|l| l.chomp!}
|
596
|
+
sep = "-=deplate=-%.10f-=end=-" % Time.new.to_f
|
597
|
+
acc = ["#%s <<%s" % [text, sep], *body] << sep
|
598
|
+
deplate.include_stringarray(acc, array, src.begin, src.file)
|
599
|
+
else
|
600
|
+
Deplate::Core.log(["No input! Skip", text], :error, src)
|
601
|
+
end
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
|
606
|
+
class Deplate::Command::ABBREV < Deplate::Command
|
607
|
+
@@commands["ABBREV"] = self
|
608
|
+
@@abbrevn = 0
|
609
|
+
|
610
|
+
def self.accumulate(src, array, deplate, text, match, args, cmd)
|
611
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
612
|
+
rx = nil
|
613
|
+
tx = nil
|
614
|
+
cmd = nil
|
615
|
+
catch(:exit) do
|
616
|
+
w = args["word"] || args["w"] || args["wd"]
|
617
|
+
if w
|
618
|
+
rx = Regexp.new(%{\\b%s\\b} % Regexp.escape(w))
|
619
|
+
tx = "%{#{text}}"
|
620
|
+
throw :exit
|
621
|
+
end
|
622
|
+
s = args["symbol"] || args["sym"]
|
623
|
+
if s
|
624
|
+
rx = Regexp.new(%{`%s} % Regexp.escape(s))
|
625
|
+
tx = "%{#{text}}"
|
626
|
+
throw :exit
|
627
|
+
end
|
628
|
+
r = args["regexp"] || args["rx"]
|
629
|
+
if r
|
630
|
+
rx = Regexp.new(r)
|
631
|
+
tx = %{@match[0].gsub(/#{r}/, %{#{text}})}
|
632
|
+
throw :exit
|
633
|
+
end
|
634
|
+
end
|
635
|
+
if rx
|
636
|
+
if args["plain"]
|
637
|
+
cmd = %{@deplate.formatter.plain_text(#{tx})}
|
638
|
+
specific = false
|
639
|
+
elsif args["native"] or args["ins"]
|
640
|
+
cmd = tx
|
641
|
+
specific = true
|
642
|
+
else
|
643
|
+
cmd = %{@deplate.parse_and_format(@container, #{tx}, false)}
|
644
|
+
specific = false
|
645
|
+
end
|
646
|
+
body = <<-EOR
|
647
|
+
@rx = /^#{rx}/
|
648
|
+
def setup
|
649
|
+
@elt = #{cmd}
|
650
|
+
end
|
651
|
+
EOR
|
652
|
+
cls = Deplate::Cache.particle(deplate, body,
|
653
|
+
:register => true,
|
654
|
+
:specific => specific
|
655
|
+
)
|
656
|
+
else
|
657
|
+
Deplate::Core.log(["No pattern specified", args], :error, src)
|
658
|
+
end
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
662
|
+
|
663
|
+
class Deplate::Command::MODULE < Deplate::Command
|
664
|
+
@@commands["MODULE"] = self
|
665
|
+
@@commands["MOD"] = self
|
666
|
+
class << self
|
667
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
668
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
669
|
+
deplate.require_module(text)
|
670
|
+
deplate.call_methods_matching(deplate, /^hook_late_require_/)
|
671
|
+
# deplate.initialize_particles(false, :always => true)
|
672
|
+
end
|
673
|
+
end
|
674
|
+
end
|
675
|
+
|
676
|
+
|
677
|
+
class Deplate::Command::LTX < Deplate::Command
|
678
|
+
@@commands["LTX"] = self
|
679
|
+
@@commands["INLATEX"] = self
|
680
|
+
class << self
|
681
|
+
def accumulate(src, array, deplate, text, match, args, cmd)
|
682
|
+
Deplate::Core.log("%s: %s" % [cmd, text], :debug)
|
683
|
+
m = []
|
684
|
+
m[Deplate::Element::Region.rxi_name] = 'Ltx'
|
685
|
+
m[Deplate::Element::Region.rxi_args] = match[2]
|
686
|
+
m[Deplate::Element::Region.rxi_endrx] = Regexp.escape('_$%{}%$_')
|
687
|
+
m[Deplate::Element::Region.rxi_indent] = ''
|
688
|
+
text += "\n_$%{}%$_"
|
689
|
+
Deplate::Element::Region.accumulate(src, array, deplate, text, m)
|
690
|
+
end
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|