module Dblpbib

Bits of logic

Constants

DESCRIPTION
VERSION

Public Class Methods

scan_keys(document) click to toggle source
# File lib/dblpbib.rb, line 5
def self.scan_keys(document)
        # TODO: Extract the allowed command names, possible make them configurable
        document
                .gsub(/(?<!\\)%.*$/, '')
                .scan(%r{
                        # Command
                        \\(text|auto)?cite(|(al)?[pt]\*?|year(par|\*)?|par\*?|author\*?|text|)
                        # Optionally options
                        (\[[^\]]+\])?
                        # Parameters
                        \{([^\}]+)\}
                }x)
                .map(&:pop)
                .flat_map { |keyset| keyset.split(',') }
                .map(&:strip)
                .keep_if { |key| key.start_with?('DBLP:') }
                .map { |key| key.sub('DBLP:', '') }
                .uniq
end