Sha256: 41de9dbb195706ee97f2f989c5117fcb5bfecf4bb7b5d92db175207e3c38c999

Contents?: true

Size: 1013 Bytes

Versions: 4

Compression:

Stored size: 1013 Bytes

Contents

class String
  def to_permalink
    str = ActiveSupport::Multibyte::Chars.new(self.dup)
    str = str.normalize(:kd).gsub(/[^\x00-\x7F]/,'').to_s
    str.gsub!(/[^-\w\d]+/xim, "-")
    str.gsub!(/-+/xm, "-")
    str.gsub!(/^-?(.*?)-?$/, '\1')
    str.downcase!
    str
  end
  def fix_scenebreaks
    str = ActiveSupport::Multibyte::Chars.new(self.dup)
    str.gsub(/\\begin{center}.*?\\rule{3in}{0.4pt}.*?\\end{center}/m,'\pfbreak')
    # str.gsub('\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}','\pfbreak')
  end
  def sectionize
    str = ActiveSupport::Multibyte::Chars.new(self.dup)
    "<div class='section'>#{str}</div>"
  end
  # def to_latex(headers=nil)
  #   headers = %w{chapter section subsection subsubsection paragraph subparagraph} if headers.nil?
  # 	require 'kramdown'
  # 	s = Kramdown::Document.new(self.dup, :latex_headers => headers).to_latex
  #   s << "\\pbreak{}"
  # end
  # def to_html
  # 	require 'kramdown'
  # 	Kramdown::Document.new(self.dup).to_html
  # end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
verku-0.16.8 lib/verku/extensions/string.rb
verku-0.16.7 lib/verku/extensions/string.rb
verku-0.16.6 lib/verku/extensions/string.rb
verku-0.16.5 lib/verku/extensions/string.rb