Class: Polytexnic::Pipeline
- Inherits:
-
Object
- Object
- Polytexnic::Pipeline
- Includes:
- Postprocessor, Preprocessor, Utils
- Defined in:
- lib/polytexnic.rb
Constant Summary
Constants included from Literal
Literal::CODE_INCLUSION_REGEX, Literal::LANG_REGEX
Instance Attribute Summary collapse
-
#code_cache ⇒ Object
Returns the value of attribute code_cache.
-
#custom_commands ⇒ Object
Returns the value of attribute custom_commands.
-
#highlight_cache ⇒ Object
Returns the value of attribute highlight_cache.
-
#html ⇒ Object
Returns the value of attribute html.
-
#literal_cache ⇒ Object
Returns the value of attribute literal_cache.
-
#maketitle_elements ⇒ Object
Returns the value of attribute maketitle_elements.
-
#math_label_cache ⇒ Object
Returns the value of attribute math_label_cache.
-
#polytex ⇒ Object
Returns the value of attribute polytex.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(source, options = {}) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #to_html ⇒ Object
- #to_latex ⇒ Object
Methods included from Utils
#add_font_info, #cache_hrefs, #debug?, #digest, #escape_backslashes, #framed, #highlight, #highlight_lines, #highlight_source_code, #highlighted_lines, #horrible_backslash_kludge, #linux?, #os_x?, #pipeline_digest, #profiling?, #set_test_mode!, #test?, #tralics, #tralics_commands, #underscore_digest, #xmlelement
Methods included from Postprocessor
Methods included from Polytexnic::Postprocessor::Polytex
#escape_hack, #fix_verbatim_bug, #remove_hypertarget, #write_polytex_code
Methods included from Polytexnic::Postprocessor::Latex
#extra_escape, #replace_hashes
Methods included from Polytexnic::Postprocessor::Html
Methods included from Preprocessor
Methods included from Polytexnic::Preprocessor::Polytex
#cache_code_environments, #cache_image_locations, #cache_latex_literal, #cache_math, #cache_raw_latex, #convert_code_inclusion, #convert_includegraphics, #convert_tt, #restore_hashed_content, #restore_math, #to_polytex
Methods included from Literal
#cache_display_inline_math, #cache_display_math, #cache_inline_math, #cache_literal, #cache_literal_environments, #cache_unicode, #code_salt, #element, #equation_element, #hyperrefs, #literal_types, #math_environments
Methods included from Polytexnic::Preprocessor::Latex
#clean_latex_document, #polish_tables, #process_asides, #to_processed_latex
Methods included from Polytexnic::Preprocessor::Html
Constructor Details
#initialize(source, options = {}) ⇒ Pipeline
Returns a new instance of Pipeline.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/polytexnic.rb', line 35 def initialize(source, = {}) @literal_cache = {} @code_cache = {} @maketitle_elements = {} @highlight_cache_filename = '.highlight_cache' if File.exist?(@highlight_cache_filename) content = File.read(@highlight_cache_filename) .force_encoding('ASCII-8BIT') @highlight_cache = MessagePack.unpack(content) unless content.empty? end @highlight_cache ||= {} @math_label_cache = {} @source_format = [:source] || :polytex @custom_commands = File.read(Polytexnic.style_file) rescue '' @custom_commands += "\n" + ([:custom_commands] || '') @source = source if markdown? preprocess(:polytex) postprocess(:polytex) end @polytex = @source end |
Instance Attribute Details
#code_cache ⇒ Object
Returns the value of attribute code_cache.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def code_cache @code_cache end |
#custom_commands ⇒ Object
Returns the value of attribute custom_commands.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def custom_commands @custom_commands end |
#highlight_cache ⇒ Object
Returns the value of attribute highlight_cache.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def highlight_cache @highlight_cache end |
#html ⇒ Object
Returns the value of attribute html.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def html @html end |
#literal_cache ⇒ Object
Returns the value of attribute literal_cache.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def literal_cache @literal_cache end |
#maketitle_elements ⇒ Object
Returns the value of attribute maketitle_elements.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def maketitle_elements @maketitle_elements end |
#math_label_cache ⇒ Object
Returns the value of attribute math_label_cache.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def math_label_cache @math_label_cache end |
#polytex ⇒ Object
Returns the value of attribute polytex.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def polytex @polytex end |
#xml ⇒ Object
Returns the value of attribute xml.
31 32 33 |
# File 'lib/polytexnic.rb', line 31 def xml @xml end |
Instance Method Details
#to_html ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/polytexnic.rb', line 58 def to_html if profiling? require 'ruby-prof' RubyProf.start end preprocess(:html) postprocess(:html) puts @html if debug? if profiling? result = RubyProf.stop printer = RubyProf::GraphPrinter.new(result) printer.print(STDOUT, {}) end @html.strip end |
#to_latex ⇒ Object
76 77 78 79 80 |
# File 'lib/polytexnic.rb', line 76 def to_latex preprocess(:latex) postprocess(:latex) @latex end |