Class: Docgenerator::Elements::Href

Inherits:
Docgenerator::Element show all
Defined in:
lib/docgenerator/elements.rb

Overview

Internal reference The href-parameter is expected with a leading # (HTML) The corresponding label should be defined in the same document/file.

For external links use :href.

Constant Summary

Constants inherited from Docgenerator::Element

Docgenerator::Element::SUPPORTED_TARGETS

Constants included from Docgenerator

ATTR_LANG, CSS_BORDER, CSS_COLORS, CSS_WIDTH, DOCGENERATOR_DEFAULT_LOGGER, DOCGENERATOR_LOGGER, Docgenerator::ENDTAG, HTML_ATTR_ALIGN, HTML_ATTR_ALL, HTML_ATTR_CORE, HTML_ATTR_EVENTS, HTML_ATTR_I18N, HTML_ATTR_VALIGN, VERSION

Instance Attribute Summary

Attributes inherited from Docgenerator::Element

#attr, #content, #log

Instance Method Summary collapse

Methods inherited from Docgenerator::Element

#<<, #CR, #Cr, #[], add, add_attribute, add_attributes, add_context_output, add_creole_output, add_html_output, add_html_tag, add_id, add_latex_output, add_output, add_text_output, add_wiki_output, attributes, #cR, #content?, #cr, create, create_convert_to_code, #delete, #element_ids, element_ids, #empty?, get, get_attribute_list, has_no_content, #htmltag, #ids, inherited, #initialize, #insert, #insertafter, #insertbefore, #inspect, #inspect_creation_caller, #linebreak, overview, #prepare_tracing_info, #restrict_to, #texkeyval, #texoptional, #to_context, #to_doc, #to_html, #to_s, trace=

Methods included from Docgenerator

#set_option_defaults, set_option_defaults, trace_off, trace_on, trace_on?

Constructor Details

This class inherits a constructor from Docgenerator::Element

Instance Method Details

#to_creole(options = {}) ⇒ Object



753
754
755
# File 'lib/docgenerator/elements.rb', line 753

def to_creole( options = {} )
  "[[#{@attr[:href].to_s}|#{@content.to_doc(:creole, options)}]]"
end

#to_latex(options = {}) ⇒ Object



756
757
758
759
760
761
762
763
764
765
766
767
# File 'lib/docgenerator/elements.rb', line 756

def to_latex( options = {} )
  cmd = linebreak(@crbefore)
  reference = @attr[:href].to_s
  if reference.sub!(/\A\#/, '')  #Internal reference

    cmd << "\\hyperlink{#{reference}}{#{@content.to_doc(:latex, options)}}"
  else  #external reference

    #reference may not contain unmasked % or #

    cmd << "\\href{#{reference}}{#{@content.to_doc(:latex, options)}}"
  end
  cmd << linebreak(@crafter)
  cmd
end

#to_text(options = {}) ⇒ Object



768
769
770
771
772
773
774
775
# File 'lib/docgenerator/elements.rb', line 768

def to_text( options = {} )
  if @attr[:href].to_s  == @content
    @content.to_doc(:text, options)
  else
    #~ "<#{@attr[:href].to_s} #{@content}>"  --> Problem: Wird gerne als komplette URL interpreitert

    "#{@content.to_doc(:text, options)} (#{@attr[:href].to_s})"
  end
end

#to_wiki(options = {}) ⇒ Object



750
751
752
# File 'lib/docgenerator/elements.rb', line 750

def to_wiki( options = {} )
  "[#{@attr[:href].to_s} #{@content.to_doc(:wiki, options)}]"
end