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.
-
#language_labels ⇒ Object
Returns the value of attribute language_labels.
-
#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?, #os_x_newer?, #os_x_older?, #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, #remove_kramdown_comments, #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_error, #code_language, #code_salt, #element, #equation_element, #hyperrefs, #include_code, #literal_types, #math_environments
Methods included from Polytexnic::Preprocessor::Latex
#clean_latex_document, #convert_gifs, #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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/polytexnic.rb', line 39 def initialize(source, = {}) @literal_cache = [:literal_cache] || {} @code_cache = {} @maketitle_elements = {} @language_labels = if (labels = [:language_labels]).nil? default_language_labels else default_language_labels.merge(labels) end @highlight_cache_filename = '.highlight_cache' if File.exist?(@highlight_cache_filename) content = File.read(@highlight_cache_filename) .force_encoding('ASCII-8BIT') begin @highlight_cache = MessagePack.unpack(content) unless content.empty? rescue MessagePack::UnpackError FileUtils.rm @highlight_cache_filename end end @highlight_cache ||= {} @math_label_cache = {} @source_format = [:source] || :polytex @custom_commands = File.read(Polytexnic.core_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.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def code_cache @code_cache end |
#custom_commands ⇒ Object
Returns the value of attribute custom_commands.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def custom_commands @custom_commands end |
#highlight_cache ⇒ Object
Returns the value of attribute highlight_cache.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def highlight_cache @highlight_cache end |
#html ⇒ Object
Returns the value of attribute html.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def html @html end |
#language_labels ⇒ Object
Returns the value of attribute language_labels.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def language_labels @language_labels end |
#literal_cache ⇒ Object
Returns the value of attribute literal_cache.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def literal_cache @literal_cache end |
#maketitle_elements ⇒ Object
Returns the value of attribute maketitle_elements.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def maketitle_elements @maketitle_elements end |
#math_label_cache ⇒ Object
Returns the value of attribute math_label_cache.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def math_label_cache @math_label_cache end |
#polytex ⇒ Object
Returns the value of attribute polytex.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def polytex @polytex end |
#xml ⇒ Object
Returns the value of attribute xml.
35 36 37 |
# File 'lib/polytexnic.rb', line 35 def xml @xml end |
Instance Method Details
#to_html ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/polytexnic.rb', line 71 def to_html if profiling? require 'ruby-prof' RubyProf.start end preprocess(:html) puts "\nafter preprocess:\n#{@xml}" if debug? postprocess(:html) puts "\nafter postprocess:\n#{@html}" if debug? if profiling? result = RubyProf.stop printer = RubyProf::GraphPrinter.new(result) printer.print(STDOUT, {}) end @html.strip end |
#to_latex ⇒ Object
90 91 92 93 94 |
# File 'lib/polytexnic.rb', line 90 def to_latex preprocess(:latex) postprocess(:latex) @latex end |