module Asciidoctor::Helpers

def rootname filename

Returns the String filename with the file extension removed

# => "part1/chapter1"
Helpers.rootname 'part1/chapter1.adoc'

Examples

filename - The String file name to process; expected to be a posix path

Public: Removes the file extension from filename and returns the result
def rootname filename
  if (last_dot_idx = filename.rindex '.')
    (filename.index '/', last_dot_idx) ? filename : (filename.slice 0, last_dot_idx)
  else
    filename
  end
end