ruby/blog/update_post.rb
# Modifies line in place during the first pass through a file, and writes
# extra output to buffer if necessary.
#
# line should not be written to buffer directly.
Modifies line in place during the first pass through a file, and writes
extra output to buffer if necessary.

line should not be written to buffer directly.
Modifies line in place during the first pass through a file and writes extra output to buffer if necessary . line should not be written to buffer directly .
def parse_line_first_pass(line, buffer)
    if @in_toc
      if line == "\n"
        @in_toc = false
      else
        @existing_headlines.push line[0..-1]
      end
    elsif line.start_with? TABLE_OF_CONTENTS
      @in_toc = true
      first_headline = line[TABLE_OF_CONTENTS.length..-1]
      @existing_headlines.push first_headline if not first_headline.empty?
    elsif match = line.match(HEADLINE)
      id, text = match[1], match[2]
      text.gsub!(REF, '')
      text.gsub!(NEW_NOTE, '')
      text.gsub!(/\[?"([^"]+)":[^ ]+\]?/, '\1')
      if text.match(/["\[\]]/)
        $stderr.puts("Malformed link or footnote in section headline: " +
                     "#{text}\n")
        exit 1
      end
      @headlines.push "\"#{text}\":##{id}\n"
    end
  end
def parse_line_first_pass ( line , buffer ) if @in_toc if line == "\n" @in_toc = false else @existing_headlines . push line [ 0 .. - 1 ] end elsif line . start_with? TABLE_OF_CONTENTS @in_toc = true first_headline = line [ TABLE_OF_CONTENTS . length .. - 1 ] @existing_headlines . push first_headline if not first_headline . empty? elsif match = line . match ( HEADLINE ) id , text = match [ 1 ] , match [ 2 ] text . gsub! ( REF , '' ) text . gsub! ( NEW_NOTE , '' ) text . gsub! ( / \[ ?"([^"]+)":[^ ]+ \] ? / , '\1' ) if text . match ( / [" \[ \] ] / ) $stderr . puts ( "Malformed link or footnote in section headline: " + "#{text}\n" ) exit 1 end @headlines . push "\"#{text}\":##{id}\n" end end
Modifies line in place during the first pass through a file, and writes
extra output to buffer if necessary.
Modifies line in place during the first pass through a file and writes extra output to buffer if necessary .
# If quotation marks or brackets still appear, we're in trouble.
line
<not_specific>
buffer
<not_specific>