vendor/bundle/ruby/2.1.0/gems/org-ruby-0.9.12/lib/org-ruby/parser.rb
def mark_trees_for_export
      marked_any = false
      # cache the tags
      select = export_select_tags
      exclude = export_exclude_tags
      inherit_export_level = nil
      ancestor_stack = []

      # First pass: See if any headlines are explicitly selected
      @headlines.each do |headline|
        ancestor_stack.pop while not ancestor_stack.empty? and headline.level <= ancestor_stack.last.level
        if inherit_export_level and headline.level > inherit_export_level
          headline.export_state = :all
        else
          inherit_export_level = nil
          headline.tags.each do |tag|
            if (select.include? tag) then
              marked_any = true
              headline.export_state = :all
              ancestor_stack.each { |a| a.export_state = :headline_only unless a.export_state == :all }
              inherit_export_level = headline.level
            end
          end
        end
        ancestor_stack.push headline
      end

      # If nothing was selected, then EVERYTHING is selected.
      @headlines.each { |h| h.export_state = :all } unless marked_any

      # Second pass. Look for things that should be excluded, and get rid of them.
      @headlines.each do |headline|
        if inherit_export_level and headline.level > inherit_export_level
          headline.export_state = :exclude
        else
          inherit_export_level = nil
          headline.tags.each do |tag|
            if (exclude.include? tag) then
              headline.export_state = :exclude
              inherit_export_level = headline.level
            end
          end
          if headline.comment_headline?
            headline.export_state = :exclude
            inherit_export_level = headline.level
          end
        end
      end
    end
# Uses export_select_tags and export_exclude_tags to determine
# which parts of the org-file to export.
Uses export_select_tags and export_exclude_tags to determine
which parts of the org-file to export.
Uses export_select_tags and export_exclude_tags to determine which parts of the org - file to export .
def mark_trees_for_export
      marked_any = false
      select = export_select_tags
      exclude = export_exclude_tags
      inherit_export_level = nil
      ancestor_stack = []
      @headlines.each do |headline|
        ancestor_stack.pop while not ancestor_stack.empty? and headline.level <= ancestor_stack.last.level
        if inherit_export_level and headline.level > inherit_export_level
          headline.export_state = :all
        else
          inherit_export_level = nil
          headline.tags.each do |tag|
            if (select.include? tag) then
              marked_any = true
              headline.export_state = :all
              ancestor_stack.each { |a| a.export_state = :headline_only unless a.export_state == :all }
              inherit_export_level = headline.level
            end
          end
        end
        ancestor_stack.push headline
      end
      @headlines.each { |h| h.export_state = :all } unless marked_any
      @headlines.each do |headline|
        if inherit_export_level and headline.level > inherit_export_level
          headline.export_state = :exclude
        else
          inherit_export_level = nil
          headline.tags.each do |tag|
            if (exclude.include? tag) then
              headline.export_state = :exclude
              inherit_export_level = headline.level
            end
          end
          if headline.comment_headline?
            headline.export_state = :exclude
            inherit_export_level = headline.level
          end
        end
      end
    end
def mark_trees_for_export marked_any = false select = export_select_tags exclude = export_exclude_tags inherit_export_level = nil ancestor_stack = [ ] @headlines . each do | headline | ancestor_stack . pop while not ancestor_stack . empty? and headline . level <= ancestor_stack . last . level if inherit_export_level and headline . level > inherit_export_level headline . export_state = :all else inherit_export_level = nil headline . tags . each do | tag | if ( select . include? tag ) then marked_any = true headline . export_state = :all ancestor_stack . each { | a | a . export_state = :headline_only unless a . export_state == :all } inherit_export_level = headline . level end end end ancestor_stack . push headline end @headlines . each { | h | h . export_state = :all } unless marked_any @headlines . each do | headline | if inherit_export_level and headline . level > inherit_export_level headline . export_state = :exclude else inherit_export_level = nil headline . tags . each do | tag | if ( exclude . include? tag ) then headline . export_state = :exclude inherit_export_level = headline . level end end if headline . comment_headline? headline . export_state = :exclude inherit_export_level = headline . level end end end end
Uses export_select_tags and export_exclude_tags to determine
which parts of the org-file to export.
Uses export_select_tags and export_exclude_tags to determine which parts of the org - file to export .
# cache the tags # First pass: See if any headlines are explicitly selected # If nothing was selected, then EVERYTHING is selected. # Second pass. Look for things that should be excluded, and get rid of them.