wortsammler 0.0.2 → 0.0.3
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.
- data/.gitignore +1 -0
- data/README.md +44 -1
- data/README.pdf +0 -0
- data/Rakefile +1 -1
- data/changelog.rb.txt +9 -0
- data/lib/wortsammler/class.Traceable.md.rb +7 -7
- data/lib/wortsammler/class.proolib.rb +103 -46
- data/lib/wortsammler/exe.wortsammler.rb +9 -318
- data/lib/wortsammler/version.rb +1 -1
- data/lib/wortsammler.rb +375 -2
- data/resources/default.latex +20 -21
- data/spec/wortsammler_spec.rb +18 -1
- data/testresults/wortsammler_testresults.html +89 -87
- data/testresults/wortsammler_testresults.log +4 -3
- data/wortsammler-gem.sublime-project +8 -0
- data/wortsammler.gemspec +1 -1
- metadata +6 -4
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -110,7 +110,7 @@ The rakefile is in `<folder>/30_Sources/ZSUPP_Tools`
|
|
110
110
|
|
111
111
|
- provide a sublime text package
|
112
112
|
- improve documentation (it is flying around in German and needs to be
|
113
|
-
consolidated)
|
113
|
+
consolidated, please refer to <https://github.com/bwl21/wortsammler/wiki>)
|
114
114
|
- support epub
|
115
115
|
|
116
116
|
## contributing
|
@@ -128,4 +128,47 @@ The rakefile is in `<folder>/30_Sources/ZSUPP_Tools`
|
|
128
128
|
|
129
129
|
- John Mc Farlane for [pandoc][]
|
130
130
|
|
131
|
+
## Installation of the required software
|
132
|
+
|
133
|
+
### Ruby
|
134
|
+
|
135
|
+
Please use Ruby 1.9.3
|
136
|
+
|
137
|
+
- windows
|
138
|
+
- download von [http://rubyinstaller.org/downloads/][]
|
139
|
+
- development kit installieren
|
140
|
+
[DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe][]
|
141
|
+
|
142
|
+
Das braucht man nur, wenn man den Windows-Debugger verwenden
|
143
|
+
muss. In den scripten ist rquire ruby-debug aukommentiert.
|
144
|
+
|
145
|
+
- mac: OSX 10.8 bereits installiert
|
146
|
+
|
147
|
+
### pandoc
|
148
|
+
|
149
|
+
- Download [ttp://code.google.com/p/pandoc/downloads/list][]
|
150
|
+
- Installation [http://rubyinstaller.org/downloads/][1]
|
151
|
+
- Homepage [http://johnmacfarlane.net/pandoc/][pandoc]
|
152
|
+
|
153
|
+
### TeX
|
154
|
+
|
155
|
+
- mac: download [http://tug.org/mactex/][]
|
156
|
+
|
157
|
+
- windows:
|
158
|
+
|
159
|
+
- [http://www.exomatik.net/U-Latex/USBTeXEnglish\#toc1][]
|
160
|
+
- [http://www.miktex.org/2.9/setup][]
|
161
|
+
|
162
|
+
Alternatively you can use
|
163
|
+
|
164
|
+
- [usbtex][]
|
165
|
+
|
131
166
|
[pandoc]: http://johnmacfarlane.net/pandoc/
|
167
|
+
[http://rubyinstaller.org/downloads/]: http://rubyforge.org/frs/%20download.php/76277/rubyinstaller-1.8.7-p370.exe
|
168
|
+
[DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe]: https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
|
169
|
+
[ttp://code.google.com/p/pandoc/downloads/list]: http://code.google.com/p/pandoc/downloads/list
|
170
|
+
[1]: http://rubyinstaller.org/downloads/
|
171
|
+
[http://tug.org/mactex/]: http://tug.org/mactex/
|
172
|
+
[http://www.exomatik.net/U-Latex/USBTeXEnglish\#toc1]: http://www.exomatik.net/U-Latex/USBTeXEnglish#toc1
|
173
|
+
[http://www.miktex.org/2.9/setup]: http://www.miktex.org/2.9/setup
|
174
|
+
[usbtex]: http://www.exomatik.net/U-Latex/USBTeXEnglish
|
data/README.pdf
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ CLEAN << "testproject"
|
|
8
8
|
desc "Run specs"
|
9
9
|
RSpec::Core::RakeTask.new do |t|
|
10
10
|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
11
|
-
t.rspec_opts = ['-
|
11
|
+
t.rspec_opts = ['-fd -fd --out ./testresults/wortsammler_testresults.log -fh --out ./testresults/wortsammler_testresults.html']
|
12
12
|
# Put spec opts in a file named .rspec in root
|
13
13
|
end
|
14
14
|
|
data/changelog.rb.txt
ADDED
@@ -54,13 +54,13 @@ class TraceableSet
|
|
54
54
|
}.join("\n\n")
|
55
55
|
end
|
56
56
|
|
57
|
-
#
|
58
|
-
|
59
|
-
#
|
60
|
-
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
57
|
+
#
|
58
|
+
# This factory method processes all traces in a particular markdown file
|
59
|
+
# and returns a TraceableSet
|
60
|
+
#
|
61
|
+
# @param mdFile [String] name of the markdown File which shall be scanned
|
62
|
+
#
|
63
|
+
# @return [TraceableSet] The set of traceables found in the markdown file
|
64
64
|
def self.processTracesInMdFile(mdFile)
|
65
65
|
|
66
66
|
parser=TraceInMarkdownParser.new
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#
|
2
2
|
# This script converts the trace-References in a markdown file
|
3
3
|
# to hot references.
|
4
4
|
#
|
@@ -18,7 +18,6 @@ require 'nokogiri'
|
|
18
18
|
require "rubyXL"
|
19
19
|
|
20
20
|
|
21
|
-
#require 'ruby-debug' #if not RUBY_PLATFORM=="i386-mingw32"
|
22
21
|
|
23
22
|
# TODO: make these patterns part of the configuration
|
24
23
|
|
@@ -38,7 +37,7 @@ INCLUDE_PDF_PATTERN = /^\s+~~PDF\s+"(.+)" \s+ "(.+)" \s* (\d*) \s* (\d+-\d+)?
|
|
38
37
|
|
39
38
|
INCLUDE_MD_PATTERN = /^\s+~~MD\s+"(.+)" \s+ "(.+)" \s* (\d*) \s* (\d+-\d+)? \s* (clearpage|cleardoublepage)?~~/x
|
40
39
|
|
41
|
-
SNIPPET_PATTERN =
|
40
|
+
SNIPPET_PATTERN = /(\s*)~~SN \s+ (\w+)~~/x
|
42
41
|
|
43
42
|
|
44
43
|
#
|
@@ -206,17 +205,18 @@ end
|
|
206
205
|
#
|
207
206
|
|
208
207
|
class ProoConfig
|
209
|
-
attr_reader :input,
|
210
|
-
:outdir,
|
211
|
-
:outname,
|
212
|
-
:format,
|
213
|
-
:traceSortOrder,
|
214
|
-
:vars,
|
215
|
-
:editions,
|
216
|
-
:snippets,
|
208
|
+
attr_reader :input, # An array with the input filenames
|
209
|
+
:outdir, # directory where to place the output files
|
210
|
+
:outname, # basis to determine the output files
|
211
|
+
:format, # array of output formats
|
212
|
+
:traceSortOrder, # Array of strings to determine the sort ord
|
213
|
+
:vars, # hash of variables for pandoc
|
214
|
+
:editions, # hash of editions for pandoc
|
215
|
+
:snippets, # Array of strings to determine snippet filenames
|
217
216
|
:upstream_tracefiles, # Array of strings to determine upstream tracefile names
|
218
217
|
:downstream_tracefile, # String to save downstram filename
|
219
|
-
:reqtracefile_base,
|
218
|
+
:reqtracefile_base, # string to determine the requirements tracing results
|
219
|
+
:frontmatter, # Array of string to determine input filenames of frontmatter
|
220
220
|
:rootdir, # String directory of the configuration file
|
221
221
|
:stylefiles # Hash of stylefiles path to pandoc latex style file
|
222
222
|
|
@@ -268,6 +268,8 @@ class ProoConfig
|
|
268
268
|
|
269
269
|
@upstream_tracefiles = selectedConfig[:upstream_tracefiles] || nil
|
270
270
|
@upstream_tracefiles = @upstream_tracefiles.map{|file| File.expand_path("#{basePath}/#{file}")} unless @upstream_tracefiles.nil?
|
271
|
+
@frontmatter = selectedConfig[:frontmatter] || nil
|
272
|
+
@frontmatter = selectedConfig[:frontmatter].map{|file| File.expand_path("#{basePath}/#{file}")} unless @frontmatter.nil?
|
271
273
|
@rootdir = basePath
|
272
274
|
|
273
275
|
stylefiles = selectedConfig[:stylefiles] || nil
|
@@ -281,22 +283,21 @@ class ProoConfig
|
|
281
283
|
@stylefiles = stylefiles.map{ |key,value| {key => expand_path.call(value)} }.reduce(:merge)
|
282
284
|
end
|
283
285
|
|
284
|
-
snippets
|
286
|
+
snippets = selectedConfig[:snippets]
|
285
287
|
if snippets.nil?
|
286
288
|
@snippets = nil
|
287
289
|
else
|
288
290
|
@snippets = snippets.map{|file| File.expand_path("#{basePath}/#{file}")}
|
289
291
|
end
|
290
292
|
end
|
291
|
-
|
292
|
-
|
293
293
|
end
|
294
294
|
|
295
295
|
|
296
|
-
|
297
296
|
#
|
298
297
|
# This class provides the major functionalites
|
298
|
+
#
|
299
299
|
# Note that it is called PandocBeautifier for historical reasons
|
300
|
+
#
|
300
301
|
# provides methods to Process a pandoc file
|
301
302
|
#
|
302
303
|
|
@@ -331,7 +332,7 @@ class PandocBeautifier
|
|
331
332
|
# perform the beautify
|
332
333
|
# * process the file with pandoc
|
333
334
|
# * revoke some quotes introduced by pandoc
|
334
|
-
# @param [String] file the name of the file to be
|
335
|
+
# @param [String] file the name of the file to be beautified
|
335
336
|
def beautify(file)
|
336
337
|
|
337
338
|
@log.debug(" Cleaning: \"#{file}\"")
|
@@ -391,13 +392,20 @@ class PandocBeautifier
|
|
391
392
|
def replace_snippets_in_text(text, snippets)
|
392
393
|
changed=false
|
393
394
|
text.gsub!(SNIPPET_PATTERN){|m|
|
394
|
-
|
395
|
-
|
395
|
+
unless $1.nil? then
|
396
|
+
replacetext_raw=snippets[$2.to_sym]
|
397
|
+
leading_whitespace=$1.split("\n",100)
|
398
|
+
leading_lines=leading_whitespace[0..-1].join("\n")
|
399
|
+
leading_spaces=leading_whitespace.last || ""
|
400
|
+
replacetext=leading_lines+replacetext_raw.gsub("\n", "\n#{leading_spaces}")
|
401
|
+
end
|
402
|
+
|
403
|
+
if replacetext_raw
|
396
404
|
changed=true
|
397
|
-
@log.debug("replaced snippet #{$
|
405
|
+
@log.debug("replaced snippet #{$2} with #{replacetext}")
|
398
406
|
else
|
399
407
|
replacetext=m
|
400
|
-
@log.warn("Snippet not found: #{$
|
408
|
+
@log.warn("Snippet not found: #{$2}")
|
401
409
|
end
|
402
410
|
replacetext
|
403
411
|
}
|
@@ -493,9 +501,10 @@ class PandocBeautifier
|
|
493
501
|
# @param [String] output - the the name of the output file
|
494
502
|
def collect_document(input, output)
|
495
503
|
inputs=input.map{|xx| xx.esc.to_osPath }.join(" ") # qoute cond combine the inputs
|
504
|
+
inputname=File.basename(input.first)
|
496
505
|
|
497
506
|
#now combine the input files
|
498
|
-
@log.
|
507
|
+
@log.debug("combining the input files #{inputname} et al")
|
499
508
|
cmd="pandoc -s -S -o #{output} --ascii #{inputs}" # note that inputs is already quoted
|
500
509
|
system(cmd)
|
501
510
|
if $?.success? then
|
@@ -504,10 +513,10 @@ class PandocBeautifier
|
|
504
513
|
end
|
505
514
|
|
506
515
|
#
|
507
|
-
# This loads
|
508
|
-
# @param
|
516
|
+
# This loads snipptes from xlsx file
|
517
|
+
# @param [String] filename of the xlsx file
|
518
|
+
# @return [Hash] a hash with the snippetes
|
509
519
|
#
|
510
|
-
# @return [Hash] a hash with the snippets
|
511
520
|
def load_snippets_from_xlsx(file)
|
512
521
|
temp_filename = "#{@tempdir}/snippett.xlsx"
|
513
522
|
FileUtils::copy(file, temp_filename)
|
@@ -538,6 +547,12 @@ class PandocBeautifier
|
|
538
547
|
|
539
548
|
#
|
540
549
|
# This generates the final document
|
550
|
+
#
|
551
|
+
# It actually does this in two steps:
|
552
|
+
#
|
553
|
+
# 1. process front matter to laTeX
|
554
|
+
# 2. process documents
|
555
|
+
#
|
541
556
|
# @param [Array of String] input the input files to be processed in the given sequence
|
542
557
|
# @param [String] outdir the output directory
|
543
558
|
# @param [String] outname the base name of the output file. It is a basename in case the
|
@@ -547,13 +562,16 @@ class PandocBeautifier
|
|
547
562
|
# @param [Hash] vars - the variables passed to pandoc
|
548
563
|
# @param [Hash] editions - the editions to process; default nil - no edition processing
|
549
564
|
# @param [Array of String] snippetfiles the list of files containing snippets
|
550
|
-
|
551
|
-
|
565
|
+
# @param [String] file path to frontmatter the file to processed as frontmatter
|
566
|
+
# @param [ProoConfig] config - the configuration file to be used
|
567
|
+
def generateDocument(input, outdir, outname, format, vars, editions=nil, snippetfiles=nil, frontmatter=nil, config=nil)
|
552
568
|
|
553
569
|
# combine the input files
|
554
570
|
|
555
|
-
temp_filename
|
571
|
+
temp_filename = "#{@tempdir}/x.md".to_osPath
|
572
|
+
temp_frontmatter = "#{@tempdir}/xfrontmatter.md".to_osPath unless frontmatter.nil?
|
556
573
|
collect_document(input, temp_filename)
|
574
|
+
collect_document(frontmatter, temp_frontmatter) unless frontmatter.nil?
|
557
575
|
|
558
576
|
# process the snippets
|
559
577
|
|
@@ -580,23 +598,43 @@ class PandocBeautifier
|
|
580
598
|
replace_snippets_in_file(temp_filename, snippets)
|
581
599
|
end
|
582
600
|
|
601
|
+
vars_frontmatter=vars.clone
|
602
|
+
vars_frontmatter[:usetoc] = "nousetoc"
|
603
|
+
|
583
604
|
|
584
605
|
if editions.nil?
|
585
606
|
# there are no editions
|
607
|
+
unless frontmatter.nil? then
|
608
|
+
render_document(temp_frontmatter, tempdir, temp_frontmatter, ["frontmatter"], vars_frontmatter)
|
609
|
+
vars[:frontmatter] = "#{tempdir}/#{temp_frontmatter}.latex"
|
610
|
+
end
|
586
611
|
render_document(temp_filename, outdir, outname, format, vars, config)
|
587
612
|
else
|
588
613
|
# process the editions
|
589
614
|
editions.each{|edition_name, properties|
|
590
615
|
edition_out_filename = "#{outname}_#{properties[:filepart]}"
|
616
|
+
edition_temp_frontmatter = "#{@tempdir}/#{edition_out_filename}_frontmatter.md" unless frontmatter.nil?
|
591
617
|
edition_temp_filename = "#{@tempdir}/#{edition_out_filename}.md"
|
592
618
|
vars[:title] = properties[:title]
|
593
619
|
|
594
620
|
if properties[:debug]
|
621
|
+
process_debug_info(temp_frontmatter, edition_temp_frontmatter, edition_name.to_s) unless frontmatter.nil?
|
595
622
|
process_debug_info(temp_filename, edition_temp_filename, edition_name.to_s)
|
596
623
|
lvars=vars.clone
|
597
624
|
lvars[:linenumbers] = "true"
|
625
|
+
unless frontmatter.nil? # frontmatter
|
626
|
+
lvars[:usetoc] = "nousetoc"
|
627
|
+
render_document(edition_temp_frontmatter, @tempdir, "xfrontmatter", ["frontmatter"], lvars)
|
628
|
+
lvars[:usetoc] = vars[:usetoc] || "usetoc"
|
629
|
+
lvars[:frontmatter] = "#{@tempdir}/xfrontmatter.latex"
|
630
|
+
end
|
598
631
|
render_document(edition_temp_filename, outdir, edition_out_filename, ["pdf", "latex"], lvars, config)
|
599
632
|
else
|
633
|
+
unless frontmatter.nil? # frontmatter
|
634
|
+
filter_document_variant(temp_frontmatter, edition_temp_frontmatter, edition_name.to_s)
|
635
|
+
render_document(edition_temp_frontmatter, @tempdir, "xfrontmatter", ["frontmatter"], vars_frontmatter)
|
636
|
+
vars[:frontmatter]="#{@tempdir}/xfrontmatter.latex"
|
637
|
+
end
|
600
638
|
filter_document_variant(temp_filename, edition_temp_filename, edition_name.to_s)
|
601
639
|
render_document(edition_temp_filename, outdir, edition_out_filename, format, vars, config)
|
602
640
|
end
|
@@ -604,13 +642,12 @@ class PandocBeautifier
|
|
604
642
|
end
|
605
643
|
end
|
606
644
|
|
607
|
-
|
608
|
-
|
609
|
-
# render a single file
|
610
|
-
# @param input [String] path to the inputfile
|
611
|
-
# @param outdir [String] path to the output directory
|
612
|
-
# @param format [Array of String] formats
|
613
|
-
#
|
645
|
+
#
|
646
|
+
|
647
|
+
# render a single file
|
648
|
+
# @param input [String] path to the inputfile
|
649
|
+
# @param outdir [String] path to the output directory
|
650
|
+
# @param format [Array of String] formats
|
614
651
|
# @return [nil] no useful return value
|
615
652
|
def render_single_document(input, outdir, format)
|
616
653
|
outname=File.basename(input, ".*")
|
@@ -631,7 +668,6 @@ class PandocBeautifier
|
|
631
668
|
|
632
669
|
def render_document(input, outdir, outname, format, vars, config=nil)
|
633
670
|
|
634
|
-
|
635
671
|
#TODO: Clarify the following
|
636
672
|
# on Windows, Tempdir contains a drive letter. But drive letter
|
637
673
|
# seems not to work in pandoc -> pdf if the path separator ist forward
|
@@ -654,30 +690,51 @@ class PandocBeautifier
|
|
654
690
|
outfileText = "#{outdir}/#{outname}.txt".to_osPath
|
655
691
|
outfileSlide = "#{outdir}/#{outname}.slide.html".to_osPath
|
656
692
|
|
657
|
-
|
658
|
-
|
693
|
+
if vars.has_key? :frontmatter
|
694
|
+
latexTitleInclude = "--include-before-body=#{vars[:frontmatter].esc}"
|
695
|
+
else
|
696
|
+
latexTitleInclude
|
697
|
+
end
|
659
698
|
|
660
699
|
#todo: make config required, so it can be reduced to the else part
|
661
700
|
if config.nil? then
|
662
701
|
latexStyleFile = File.dirname(File.expand_path(__FILE__))+"/../../resources/default.latex"
|
663
702
|
latexStyleFile = File.expand_path(latexStyleFile).to_osPath
|
703
|
+
css_style_file = File.dirname(File.expand_path(__FILE__))+"/../../resources/default.css"
|
704
|
+
css_style_file = File.expand_path(css_style_file).to_osPath
|
664
705
|
else
|
665
706
|
latexStyleFile = config.stylefiles[:latex]
|
707
|
+
css_style_file = config.stylefiles[:css]
|
666
708
|
end
|
667
709
|
|
668
710
|
|
711
|
+
toc = "--toc"
|
712
|
+
toc = "" if vars[:usetoc]=="nousetoc"
|
669
713
|
|
670
|
-
|
714
|
+
begin
|
715
|
+
vars_string=vars.map.map{|key, value| "-V #{key}=#{value.esc}"}.join(" ")
|
716
|
+
rescue
|
717
|
+
require 'pry';binding.pry
|
718
|
+
end
|
671
719
|
|
672
720
|
@log.info("rendering #{outname} as [#{format.join(', ')}]")
|
673
721
|
|
674
|
-
begin
|
722
|
+
begin
|
675
723
|
|
676
724
|
if format.include?("pdf") then
|
677
725
|
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
726
|
+
cmd="pandoc -S #{tempfilePdf.esc} #{toc} --standalone --latex-engine xelatex --number-sections #{vars_string}" +
|
727
|
+
" --template #{latexStyleFile.esc} --ascii -o #{outfilePdf.esc} #{latexTitleInclude}"
|
728
|
+
`#{cmd}`
|
729
|
+
end
|
730
|
+
|
731
|
+
|
732
|
+
|
733
|
+
if format.include?("frontmatter") then
|
734
|
+
|
735
|
+
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
678
736
|
|
679
|
-
cmd="pandoc -S #{tempfilePdf.esc}
|
680
|
-
" --template #{latexStyleFile.esc} --ascii -o #{outfilePdf.esc}"
|
737
|
+
cmd="pandoc -S #{tempfilePdf.esc} --latex-engine xelatex #{vars_string} --ascii -o #{outfileLatex.esc}"
|
681
738
|
`#{cmd}`
|
682
739
|
end
|
683
740
|
|
@@ -685,8 +742,8 @@ class PandocBeautifier
|
|
685
742
|
|
686
743
|
ReferenceTweaker.new("pdf").prepareFile(tempfile, tempfilePdf)
|
687
744
|
|
688
|
-
cmd="pandoc -S #{tempfilePdf.esc}
|
689
|
-
" --template #{latexStyleFile.esc} --ascii -o #{outfileLatex.esc}"
|
745
|
+
cmd="pandoc -S #{tempfilePdf.esc} #{toc} --standalone --latex-engine xelatex --number #{vars_string}" +
|
746
|
+
" --template #{latexStyleFile.esc} --ascii -o #{outfileLatex.esc} #{latexTitleInclude}"
|
690
747
|
`#{cmd}`
|
691
748
|
end
|
692
749
|
|
@@ -704,6 +761,8 @@ class PandocBeautifier
|
|
704
761
|
#todo: handle style file
|
705
762
|
ReferenceTweaker.new("html").prepareFile(tempfile, tempfileHtml)
|
706
763
|
|
764
|
+
cmd="pandoc -S #{tempfileHtml.esc} #{toc} --standalone --self-contained --ascii --number #{vars_string}" +
|
765
|
+
" -o #{outfileDocx.esc}"
|
707
766
|
cmd="pandoc -S #{tempfileHtml.esc} --toc --standalone --self-contained --ascii --number-sections #{vars_string}" +
|
708
767
|
" -o #{outfileDocx.esc}"
|
709
768
|
`#{cmd}`
|
@@ -736,10 +795,8 @@ class PandocBeautifier
|
|
736
795
|
`#{cmd}`
|
737
796
|
end
|
738
797
|
rescue
|
739
|
-
|
740
798
|
@log.error "failed to perform #{cmd}"
|
741
799
|
#TODO make a try catch block kere
|
742
|
-
|
743
800
|
end
|
744
801
|
nil
|
745
802
|
end
|