Skip to content

Instantly share code, notes, and snippets.

@inukshuk
Created May 6, 2014 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inukshuk/eb98ececbec23595a2d5 to your computer and use it in GitHub Desktop.
Save inukshuk/eb98ececbec23595a2d5 to your computer and use it in GitHub Desktop.
Page Range Expander
#!/usr/bin/env ruby
require 'csl/styles'
require 'citeproc/ruby'
r = CiteProc::Ruby::Renderer.new
while input = gets
puts r.format_page_range input, 'expanded'
end
@inukshuk
Copy link
Author

inukshuk commented May 6, 2014

Use it interactively:

$ ./expand_page_ranges.rb
2313-34
2313–2334
13-4
13–14

Or by using a pipe (each page range on a new line): ./expand.rb < page_ranges.txt > expanded_page_ranges.txt

@inukshuk
Copy link
Author

inukshuk commented May 6, 2014

For the script to work, you need to install the gems csl-styles and citeproc-ruby first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment