PHP 8.2.31
Preview: to_bs.rb Size: 1.63 KB
//proc/thread-self/root/opt/alt/ruby25/lib64/ruby/2.5.0/rdoc/markup/to_bs.rb

# frozen_string_literal: true
##
# Outputs RDoc markup with hot backspace action!  You will probably need a
# pager to use this output format.
#
# This formatter won't work on 1.8.6 because it lacks String#chars.

class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc

  ##
  # Returns a new ToBs that is ready for hot backspace action!

  def initialize markup = nil
    super

    @in_b  = false
    @in_em = false
  end

  ##
  # Sets a flag that is picked up by #annotate to do the right thing in
  # #convert_string

  def init_tags
    add_tag :BOLD, '+b', '-b'
    add_tag :EM,   '+_', '-_'
    add_tag :TT,   ''  , ''   # we need in_tt information maintained
  end

  ##
  # Makes heading text bold.

  def accept_heading heading
    use_prefix or @res << ' ' * @indent
    @res << @headings[heading.level][0]
    @in_b = true
    @res << attributes(heading.text)
    @in_b = false
    @res << @headings[heading.level][1]
    @res << "\n"
  end

  ##
  # Turns on or off special handling for +convert_string+

  def annotate tag
    case tag
    when '+b' then @in_b = true
    when '-b' then @in_b = false
    when '+_' then @in_em = true
    when '-_' then @in_em = false
    end
    ''
  end

  ##
  # Calls convert_string on the result of convert_special

  def convert_special special
    convert_string super
  end

  ##
  # Adds bold or underline mixed with backspaces

  def convert_string string
    return string unless @in_b or @in_em
    chars = if @in_b then
              string.chars.map do |char| "#{char}\b#{char}" end
            elsif @in_em then
              string.chars.map do |char| "_\b#{char}" end
            end

    chars.join
  end

end

Directory Contents

Dirs: 0 × Files: 36

Name Size Perms Modified Actions
1.19 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
7.95 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
424 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
500 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
391 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
252 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
3.15 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
5.31 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
16.76 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
446 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.48 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
829 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
906 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
118 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.82 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.71 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
493 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
13.72 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
8.26 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1000 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
315 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
657 B lrw-r--r-- 2021-04-05 11:46:35
Edit Download
2.51 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
2.05 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.63 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
8.62 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
4.33 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
5.45 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.10 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.83 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
3.62 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
6.15 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.68 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.14 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
2.26 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download
1.28 KB lrw-r--r-- 2021-04-05 11:46:35
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).