citeproc-ruby 1.1.12 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8eb76742a1f8fbb61d0fc3cfc795fc8021aa18163be836521f9cdc051d29ba85
4
- data.tar.gz: e2d4c85246b2075424455b9aa3caa3c65dd99af498e6ca1d396c117c6ca3fe98
3
+ metadata.gz: 014be42d1ff5edb75e72427a8319c67fa9b608abf2723405dff4f796af208aba
4
+ data.tar.gz: 31df98d0db8076dada231773cd635c00d82a809cb44e27ff495954696bc5b99b
5
5
  SHA512:
6
- metadata.gz: f4ae63af0d2ce46e24188eb932532cab5a6a60de44d2bb05d0afda74c6e11379d102de88ed189af4b47038d5670c04fe2b145967e5c2c546b740cc10cc77c8f1
7
- data.tar.gz: 10537164be16f515e9991670a4c4bca6846310bcf39dfd03609731d782be9bbfd0932a99dc682b93c8014589a069a9159c630e15051f00fbf99dae91bf371e8b
6
+ metadata.gz: d990699b91c3f73999a4c6110aa1261e1b78add8e3ed2be5ad72db2f5285a7fc8ab549b58e55824ba38fa47bb5f1057c5e0235337b25b27922a74137ff97a847
7
+ data.tar.gz: 0a5a2481dbca2898accf816703705152f2f9d7880c06e347b29b478177c71ab1cccc3d0608d2618e61008ed8e7a5bba2d08dffb88354c3b1fb41367088de219b
@@ -9,6 +9,7 @@ require 'citeproc/ruby/format'
9
9
 
10
10
  require 'citeproc/ruby/formats/default'
11
11
  require 'citeproc/ruby/formats/html'
12
+ require 'citeproc/ruby/formats/latex'
12
13
 
13
14
  require 'citeproc/ruby/renderer'
14
15
 
@@ -0,0 +1,136 @@
1
+ module CiteProc
2
+ module Ruby
3
+ module Formats
4
+
5
+ class Latex < Format
6
+
7
+ @defaults = {
8
+ :italic => 'emph', # em
9
+ :bold => 'textbf', # strong
10
+ :container => '', # inner container
11
+ :display => '' # display container
12
+ }
13
+
14
+ @vertical_align = Hash.new { |_,k| k }
15
+ @vertical_align['sup'] = 'super'
16
+
17
+ class << self
18
+ attr_reader :defaults
19
+ end
20
+
21
+ attr_reader :config
22
+
23
+ def initialize(config = nil)
24
+ if config.nil?
25
+ @config = Latex.defaults.dup
26
+ else
27
+ @config = Latex.defaults.merge(config)
28
+ end
29
+ end
30
+
31
+ def bibliography(bibliography)
32
+ bibliography.header = "\\begin{enumerate}"
33
+ bibliography.footer = "\\end{enumerate}"
34
+
35
+ bibliography.prefix = "\\item "
36
+ bibliography.suffix = ""
37
+
38
+ bibliography.connector = "\n"
39
+ bibliography
40
+ end
41
+
42
+ def apply_font_style
43
+ if options[:'font-style'] == 'italic'
44
+ output.replace content_tag(config[:italic], output)
45
+ end
46
+ end
47
+
48
+ def apply_font_variant
49
+ end
50
+
51
+ def apply_font_weight
52
+ if options[:'font-weight'] == 'bold'
53
+ output.replace content_tag(config[:bold], output)
54
+ end
55
+ end
56
+
57
+ def apply_text_decoration
58
+ end
59
+
60
+ def apply_vertical_align
61
+ end
62
+
63
+ def apply_display
64
+ output.replace(
65
+ content_tag(config[:display], output)
66
+ )
67
+ end
68
+
69
+ def escape_quotes?
70
+ false
71
+ end
72
+
73
+ protected
74
+
75
+ def finalize!
76
+ # TODO find a better solution for this (strip tags?)
77
+ # For now make sure not to double encode entities
78
+ # by matching spaces before or after.
79
+ output.gsub!(/[$&#^_%~]/) do |c|
80
+ case c
81
+ # TODO: when "\\" then '\backslash{}'
82
+ when "^" then '\^{}'
83
+ when '~' then '\~{}'
84
+ else "\\#{c}"
85
+ end
86
+ end
87
+ end
88
+
89
+ def cleanup!
90
+ super
91
+ end
92
+
93
+ private
94
+
95
+ def content_tag(name, content, options = nil)
96
+ opening_tag(name, options) << content << closing_tag(name)
97
+ end
98
+
99
+ def style_for(options)
100
+ return unless options && !options.empty?
101
+ options.map { |*kv| kv.join(': ') }.join('; ')
102
+ end
103
+
104
+ def attribute_assignments(options)
105
+ return unless options
106
+
107
+ options = options.select { |_, v| !v.nil? }
108
+
109
+ return unless !options.empty?
110
+
111
+ ' ' << options.map { |k, v| [k, v.inspect].join('=') }.join(' ')
112
+ end
113
+
114
+ def opening_tag(name, options = nil)
115
+ if options && options.key?('style')
116
+ options['style'] = style_for(options['style'])
117
+ end
118
+
119
+ if name == ''
120
+ ''
121
+ else
122
+ "\\#{name}{"
123
+ end
124
+ end
125
+
126
+ def closing_tag(name)
127
+ if name == ''
128
+ ''
129
+ else
130
+ '}'
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -1,5 +1,5 @@
1
1
  module CiteProc
2
2
  module Ruby
3
- VERSION = '1.1.12'
3
+ VERSION = '1.1.13'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.12
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citeproc
@@ -67,6 +67,7 @@ files:
67
67
  - lib/citeproc/ruby/format.rb
68
68
  - lib/citeproc/ruby/formats/default.rb
69
69
  - lib/citeproc/ruby/formats/html.rb
70
+ - lib/citeproc/ruby/formats/latex.rb
70
71
  - lib/citeproc/ruby/renderer.rb
71
72
  - lib/citeproc/ruby/renderer/choose.rb
72
73
  - lib/citeproc/ruby/renderer/date.rb
@@ -88,7 +89,7 @@ homepage: https://github.com/inukshuk/citeproc-ruby
88
89
  licenses:
89
90
  - AGPL-3.0
90
91
  metadata: {}
91
- post_install_message:
92
+ post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  requirements: []
106
107
  rubygems_version: 3.1.2
107
- signing_key:
108
+ signing_key:
108
109
  specification_version: 4
109
110
  summary: A Citation Style Language (CSL) cite processor
110
111
  test_files: []