Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bin/anystyle
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,37 @@ command :parse do |cmd|
end
end


desc 'Parse a single reference'
long_desc %{
This manual page documents the AnyStyle `parse_reference' command.

The input argument will be the reference to be parsed

AnyStyle `parse_reference' supports the following formats:
bib BibTeX (normalized);
csl CSL/JSON (normalized);
json AnyStyle JSON (normalized);
ref One reference per line, suitable for parser input;
txt Same as `ref';
xml XML, suitable for training the parser model.

You can specify multiple output formats, separated by commas.

EXAMPLES
anystyle -f json,xml parse_reference "A. Author, Some title, publisher name, pp103-102, DOI:10.000/xyz"

Parse the input reference and print the result to STDOUT in JSON and XML

}.lstrip

arg :input
command :parse_reference do |cmd|
cmd.action do |opts, params, args|
Commands::ParseReference.new(opts).run(args, params)
end
end

desc 'Check tagged documents or references'
long_desc %{
This manual page documents the AnyStyle `check' command. AnyStyle `check'
Expand Down
1 change: 1 addition & 0 deletions lib/anystyle/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
require 'anystyle/cli/commands/check'
require 'anystyle/cli/commands/find'
require 'anystyle/cli/commands/parse'
require 'anystyle/cli/commands/parse_reference'
require 'anystyle/cli/commands/train'
18 changes: 18 additions & 0 deletions lib/anystyle/cli/commands/parse_reference.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module AnyStyle
module CLI
module Commands
class ParseReference < Base
def run(args, params)
set_output_folder args[1]
ref = args[0]
dataset = parse(ref)
say "Parsing citation: #{ref} ..."
each_format do |fmt|
res = format(dataset, fmt)
STDOUT.puts(res)
end
end
end
end
end
end