Class: CiteProc::Ruby::Formats::Sort
- Inherits:
-
Text
- Object
- CiteProc::Ruby::Format
- Text
- CiteProc::Ruby::Formats::Sort
- Defined in:
- lib/citeproc/ruby/formats/default.rb
Instance Attribute Summary
Attributes inherited from CiteProc::Ruby::Format
Instance Method Summary collapse
-
#apply(input, node, locale = nil) ⇒ Object
A special format to use when sorting which prevents formatting of extraneous things like quotes.
Methods inherited from CiteProc::Ruby::Format
#apply_display, #apply_prefix, #apply_quotes, #apply_suffix, #apply_text_case, #bibliography, #close_inner_quote, #close_quote, #escape_quotes?, #join, #keys, load, #prefix, #punctuation_in_quotes?, #split_closing_quotes, squeezable, #squeezable?, squeezable?, #squeeze_prefix, #squeeze_suffix, stopword?, #strip, #suffix
Instance Method Details
#apply(input, node, locale = nil) ⇒ Object
A special format to use when sorting which prevents formatting of extraneous things like quotes
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/citeproc/ruby/formats/default.rb', line 23 def apply(input, node, locale = nil) return '' if input.nil? return input if input.empty? || node.nil? return ArgumentError unless node.respond_to?(:formatting_options) @input, @output, @node, @locale = input, input.dup, node, locale setup! # NB: Layout nodes apply formatting to # affixes; all other nodes do not! if node.is_a? CSL::Style::Layout apply_prefix if .key?(:prefix) apply_suffix if .key?(:suffix) end keys.each do |format| if .key?(format) method = "apply_#{format}".tr('-', '_') send method if respond_to?(method) end end unless .empty? output.gsub!(/\.+/, '') if node.strip_periods? #Do not apply quotes when sorting #apply_quotes if node.quotes? && !locale.nil? finalize_content! unless node.is_a? CSL::Style::Layout apply_prefix if .key?(:prefix) apply_suffix if .key?(:suffix) end apply_display if .key?(:display) finalize! output ensure cleanup! end |