verkilo 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ % \newlength\drop
2
+ % \renewcommand*{\maketitle}{
3
+ % \thispagestyle{empty}
4
+ % \begingroup
5
+ % \setlength\drop{0.2\textheight}
6
+ % % ------------------------------------------------
7
+ % % r.1 - Half-Title - Recto
8
+ % \thispagestyle{empty}
9
+ % \begin{center}
10
+ % \vspace*{\drop}
11
+ % {\LARGE \textbf{$title$}}
12
+ % \end{center}
13
+ % \clearpage
14
+ %
15
+ % % ------------------------------------------------
16
+ % % r.2 - Series Title Page - Verso
17
+ % \newpage
18
+ % \thispagestyle{empty}
19
+ % \emph{ }\newline
20
+ % $if(other-titles)$
21
+ % \begin{center}
22
+ % \textbf{Also by $author$}
23
+ %
24
+ % $for(other-titles)$
25
+ % $other-titles$\newline
26
+ % $endfor$
27
+ % \end{center}
28
+ % $endif$
29
+ % \clearpage
30
+ %
31
+ % % ------------------------------------------------
32
+ % % r.3 Titlepage - Recto
33
+ % \thispagestyle{empty}
34
+ % \begin{center}
35
+ % \vspace*{\drop}
36
+ % {\Huge \textsf{$title$}}
37
+ %
38
+ % $if(subtitle)$
39
+ % \vspace*{3mm}
40
+ % {\Large\itshape $subtitle$}
41
+ % $endif$
42
+ %
43
+ % \vspace*{7mm}
44
+ % \line(1,0){150}
45
+ % \vspace*{7mm}
46
+ %
47
+ % {\large $author$}
48
+ %
49
+ % \vspace*{2\drop}
50
+ % $if(imprint)$
51
+ % \includegraphics[width=26mm]{$imprint$}\\[0cm]
52
+ % \vspace*{7mm}
53
+ % $endif$
54
+ % \end{center}
55
+ % \clearpage
56
+ % \thispagestyle{empty}
57
+ % \newpage
58
+ % \endgroup
59
+ % }
@@ -0,0 +1,247 @@
1
+ local authors = {}
2
+
3
+ local function is_tex(format)
4
+ return format == 'latex' or format == 'tex' or format == 'context'
5
+ end
6
+
7
+ local function is_html (format)
8
+ return format == 'html' or format == 'html4' or format == 'html5'
9
+ end
10
+
11
+ local function is_wordprocessing (format)
12
+ return format == 'docx' or format == 'odt'
13
+ end
14
+
15
+ header_track_changes = [[
16
+
17
+ \makeatletter
18
+ \PassOptionsToPackage{textsize=scriptsize}{todonotes}
19
+ \PassOptionsToPackage{markup=underlined,authormarkup=none,commentmarkup=todo}{changes}
20
+ \usepackage{changes}
21
+ \@ifpackagelater{changes}{2018/11/03}{%
22
+ }{%
23
+ \usepackage{todonotes}
24
+ \setremarkmarkup{\todo[color=Changes@Color#1!20]{\sffamily\textbf{#1:}~#2}}
25
+ }%
26
+ \makeatother
27
+ \definecolor{auth1}{HTML}{4477AA}
28
+ \definecolor{auth2}{HTML}{117733}
29
+ \definecolor{auth3}{HTML}{999933}
30
+ \definecolor{auth4}{HTML}{CC6677}
31
+ \definecolor{auth5}{HTML}{AA4499}
32
+ \definecolor{auth6}{HTML}{332288}
33
+ \setlength{\marginparwidth}{3cm}
34
+ \newcommand{\note}[2][]{\added[#1,remark={#2}]{}}
35
+ \newcommand\hlnotesingle{%
36
+ \bgroup
37
+ \expandafter\def\csname sout\space\endcsname{\bgroup \ULdepth =-.8ex \ULset}%
38
+ \markoverwith{\textcolor{yellow}{\rule[-.5ex]{.1pt}{2.5ex}}}%
39
+ \ULon}
40
+ \newcommand\hlnote[1]{\let\helpcmd\hlnotesingle\parhelp#1\par\relax\relax}
41
+ \long\def\parhelp#1\par#2\relax{%
42
+ \helpcmd{#1}\ifx\relax#2\else\par\parhelp#2\relax\fi%
43
+ }
44
+
45
+ \makeatletter
46
+ \newcommand\ifmoving{%
47
+ \ifx\protect\@unexpandable@protect
48
+ \expandafter\@firstoftwo
49
+ \else
50
+ \expandafter\@secondoftwo
51
+ \fi
52
+ }
53
+
54
+ \newcommand{\gobbletwo}[2][]{\@bsphack\@esphack}
55
+ \newcommand{\gobbleone}[1][]{\@bsphack\@esphack}
56
+
57
+ \let\oldadded\added
58
+ \let\olddeleted\deleted
59
+ \let\oldhlnote\hlnote
60
+ \let\oldnote\note
61
+ \renewcommand{\added}{\ifmoving{\gobbleone}{\oldadded}}
62
+ \renewcommand{\deleted}{\ifmoving{\gobbletwo}{\olddeleted}}
63
+ \renewcommand{\hlnote}{\ifmoving{}{\oldhlnote}}
64
+ \renewcommand{\note}{\ifmoving{\gobbletwo}{\oldnote}}
65
+ \makeatother
66
+ ]]
67
+
68
+ local function initials(s)
69
+ local ignore = { -- list of words to ignore
70
+ ['dr'] = true, ['mr'] = true, ['ms'] = true, ['mrs'] = true, ['prof'] = true,
71
+ ['mx'] = true, ['sir'] = true,
72
+ }
73
+
74
+ local ans = {}
75
+ for w in s:gmatch '[%w\']+' do
76
+ if not ignore[w:lower()] then ans[#ans+1] = w:sub(1,1):upper() end
77
+ end
78
+ return table.concat(ans)
79
+ end
80
+
81
+ relinerHtml = {
82
+ Str = function (s)
83
+ if s.text == "¶" then
84
+ return pandoc.Str('
')
85
+ end
86
+ end
87
+ }
88
+
89
+ relinerTex = {
90
+ Str = function (s)
91
+ if s.text == "¶" then
92
+ return pandoc.Str('\\newline')
93
+ end
94
+ end
95
+ }
96
+
97
+ reliner = {
98
+ Str = function (s)
99
+ if s.text == "¶" then
100
+ return pandoc.LineBreak()
101
+ end
102
+ end
103
+ }
104
+
105
+ function SpanReliner(elem)
106
+ local classes = elem.classes or elem.attr.classes
107
+ if classes:includes("comment-start") then
108
+ return pandoc.walk_inline(elem, reliner)
109
+ end
110
+ end
111
+
112
+ local toTex = {["comment-start"] = "\\note", insertion = "\\added", deletion = "\\deleted"}
113
+
114
+ local function TrackingSpanToTex(elem)
115
+ if toTex[elem.classes[1]] ~= nil then
116
+ local author = elem.attributes.author
117
+ local inits = author:find' ' and initials(author) or author
118
+ authors[inits] = author
119
+ local s = toTex[elem.classes[1]] .. '[id=' .. inits .. ']{'
120
+ if elem.classes:includes("comment-start") then
121
+ s = s .. pandoc.utils.stringify(pandoc.walk_inline(elem, relinerTex)) .. '}\\hlnote{'
122
+ else
123
+ s = s .. pandoc.utils.stringify(elem.content) .. '}'
124
+ end
125
+ return pandoc.RawInline('latex', s)
126
+ elseif elem.classes:includes("comment-end") then
127
+ return pandoc.RawInline('latex', '}')
128
+ end
129
+ end
130
+
131
+ local function pairsByKeys(t, f)
132
+ local a = {}
133
+ for n in pairs(t) do table.insert(a, n) end
134
+ table.sort(a, f)
135
+ local i = 0
136
+ local iter = function ()
137
+ i = i + 1
138
+ return a[i], t[a[i]]
139
+ end
140
+ return iter
141
+ end
142
+
143
+ --- Add packages to the header includes.
144
+ local function add_track_changes(meta)
145
+ local header_includes
146
+ if meta['header-includes'] and meta['header-includes'].t == 'MetaList' then
147
+ header_includes = meta['header-includes']
148
+ else
149
+ header_includes = pandoc.MetaList{meta['header-includes']}
150
+ end
151
+ header_includes[#header_includes + 1] =
152
+ pandoc.MetaBlocks{pandoc.RawBlock('latex', header_track_changes)}
153
+ local a = 1
154
+ for key,value in pairsByKeys(authors) do -- sorted author list; otherwise make test may fail
155
+ header_includes[#header_includes + 1] =
156
+ pandoc.MetaBlocks{pandoc.RawBlock('latex', '\\definechangesauthor[name={' .. value .. '}, color=auth' .. a .. ']{' .. key .. '}')}
157
+ a = a + 1
158
+ end
159
+ meta['header-includes'] = header_includes
160
+ return meta
161
+ end
162
+
163
+ local toHtml = {["comment-start"] = "mark", insertion = "ins", deletion = "del"}
164
+
165
+ local function TrackingSpanToHtml(elem)
166
+ if toHtml[elem.classes[1]] ~= nil then
167
+ local author = elem.attributes.author
168
+ local inits = author:find' ' and initials(author) or author
169
+ authors[inits] = author
170
+ local s = '<' .. toHtml[elem.classes[1]]
171
+ for k,v in pairs(elem.attributes) do
172
+ local hattr = k
173
+ if hattr ~= 'date' then hattr = 'data-' .. hattr end
174
+ s = s .. ' ' .. hattr .. '="' .. v .. '"'
175
+ end
176
+ if elem.classes:includes("comment-start") then
177
+ if elem.identifier then
178
+ s = s .. ' data-id="' .. elem.identifier .. '"'
179
+ end
180
+ s = s .. ' title="' .. pandoc.utils.stringify(pandoc.walk_inline(elem, relinerHtml)) .. '">'
181
+ else
182
+ s = s .. '>' .. pandoc.utils.stringify(elem.content) .. '</' .. toHtml[elem.classes[1]] .. '>'
183
+ end
184
+ return pandoc.RawInline('html', s)
185
+ elseif elem.classes:includes("comment-end") then
186
+ return pandoc.RawInline('html', '</mark>')
187
+ end
188
+ end
189
+
190
+ local function SpanAcceptChanges(elem)
191
+ if elem.classes:includes("comment-start") or elem.classes:includes("comment-end") then
192
+ return {}
193
+ elseif elem.classes:includes("insertion") then
194
+ return elem.content
195
+ elseif elem.classes:includes("deletion") then
196
+ return {}
197
+ end
198
+ end
199
+
200
+ local function SpanRejectChanges(elem)
201
+ if elem.classes:includes("comment-start") or elem.classes:includes("comment-end") then
202
+ return {}
203
+ elseif elem.classes:includes("insertion") then
204
+ return {}
205
+ elseif elem.classes:includes("deletion") then
206
+ return elem.content
207
+ end
208
+ end
209
+
210
+ function Pandoc(doc)
211
+ local meta = doc.meta
212
+ local trackChangesOptions = {all = 'AllChanges', accept = 'AcceptChanges', reject = 'RejectChanges' }
213
+ local tc = meta and meta['trackChanges']
214
+ tc = type(meta['trackChanges']) == 'table' and pandoc.utils.stringify(meta['trackChanges']) or meta['trackChanges'] or 'accept'
215
+ local trackChanges = PANDOC_READER_OPTIONS and PANDOC_READER_OPTIONS.trackChanges or trackChangesOptions[tc]
216
+ meta.trackChanges = nil -- remove it from the matadata
217
+
218
+ local M = {}
219
+ if trackChanges == 'AllChanges' then
220
+ if is_html(FORMAT) then
221
+ M[#M + 1] = {
222
+ Span = TrackingSpanToHtml
223
+ }
224
+ elseif is_tex(FORMAT) then
225
+ M[#M + 1] = {
226
+ Span = TrackingSpanToTex,
227
+ }
228
+ elseif is_wordprocessing(FORMAT) then
229
+ M[#M + 1] = { Span = SpanReliner }
230
+ end
231
+ elseif trackChanges == 'RejectChanges' then
232
+ M[#M + 1] = { Span = SpanRejectChanges }
233
+ else -- otherwise assumes AcceptChanges
234
+ M[#M + 1] = { Span = SpanAcceptChanges }
235
+ end
236
+
237
+ if #M then
238
+ local blocks = doc.blocks
239
+ for i = 1, #M do
240
+ blocks = pandoc.walk_block(pandoc.Div(blocks), M[i]).content
241
+ end
242
+ if trackChanges == 'AllChanges' and is_tex(FORMAT) then
243
+ meta = add_track_changes(meta)
244
+ end
245
+ return pandoc.Pandoc(blocks, meta)
246
+ end
247
+ end
@@ -0,0 +1,7 @@
1
+ /* add custom CSS */
2
+ span.smee {
3
+ font-family: monospace;
4
+ }
5
+ span.smee:before {
6
+ content: '$ ';
7
+ }
@@ -0,0 +1,5 @@
1
+ $if(titleblock)$
2
+ $titleblock$
3
+ $else$
4
+ --- {}
5
+ $endif$
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "verkilo/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "verkilo"
8
+ spec.version = Verkilo::VERSION
9
+ spec.authors = ["Ben W"]
10
+ spec.email = ["merovex@gmail.com"]
11
+
12
+ spec.summary = %q{Sustainable publishing with Markdown and Pandoc}
13
+ spec.description = %q{Sustainable publishing with Markdown and Pandoc}
14
+ spec.homepage = "https://verkilo.com"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/verkilo/verkilo"
24
+ spec.metadata["changelog_uri"] = "https://github.com/verkilo/verkilo/CHANGELOG.md"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "bin"
36
+ spec.executables = ["verkilo"]
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.17"
40
+ spec.add_development_dependency "rake", "~> 12.3.3", '>= 12.3.3'
41
+ spec.add_dependency "thor", '~> 0'
42
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: verkilo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Ben W
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 12.3.3
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 12.3.3
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 12.3.3
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 12.3.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: thor
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: Sustainable publishing with Markdown and Pandoc
62
+ email:
63
+ - merovex@gmail.com
64
+ executables:
65
+ - verkilo
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - ".gitignore"
70
+ - CODE_OF_CONDUCT.md
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - bin/console
77
+ - bin/setup
78
+ - bin/verkilo
79
+ - lib/verkilo.rb
80
+ - lib/verkilo/book.rb
81
+ - lib/verkilo/cli.rb
82
+ - lib/verkilo/log.rb
83
+ - lib/verkilo/shelf.rb
84
+ - lib/verkilo/version.rb
85
+ - resources/.keep
86
+ - resources/default.tex
87
+ - resources/epub.html
88
+ - resources/frontmatter.tex
89
+ - resources/hi-dates.tex
90
+ - resources/hi-fancypagebreak.tex
91
+ - resources/hi-fonts.tex
92
+ - resources/hi-title.tex
93
+ - resources/latex.lua
94
+ - resources/metadata.yml
95
+ - resources/packages.tex
96
+ - resources/pdf-old.tex
97
+ - resources/reference.docx
98
+ - resources/style.css
99
+ - resources/template.tex
100
+ - resources/title.tex
101
+ - resources/track-changes.lua
102
+ - resources/user.css
103
+ - resources/yaml.md
104
+ - verkilo.gemspec
105
+ homepage: https://verkilo.com
106
+ licenses:
107
+ - MIT
108
+ metadata:
109
+ homepage_uri: https://verkilo.com
110
+ source_code_uri: https://github.com/verkilo/verkilo
111
+ changelog_uri: https://github.com/verkilo/verkilo/CHANGELOG.md
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.6.14
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Sustainable publishing with Markdown and Pandoc
132
+ test_files: []