Class: Qiita::Markdown::Filters::SyntaxHighlight
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Qiita::Markdown::Filters::SyntaxHighlight
- Defined in:
- lib/qiita/markdown/filters/syntax_highlight.rb
Defined Under Namespace
Classes: Highlighter
Constant Summary collapse
- DEFAULT_LANGUAGE =
"text"
- DEFAULT_TIMEOUT =
Float::INFINITY
- DEFAULT_OPTION =
"html_legacy"
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/qiita/markdown/filters/syntax_highlight.rb', line 9 def call elapsed = 0 timeout_fallback_language = nil doc.search("pre").each do |node| elapsed += measure_time do Highlighter.call( default_language: default_language, node: node, specific_language: timeout_fallback_language, ) end if elapsed >= timeout timeout_fallback_language = DEFAULT_LANGUAGE result[:syntax_highlight_timed_out] = true end end doc end |