Class: Qiita::Markdown::Filters::Truncate
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Qiita::Markdown::Filters::Truncate
- Defined in:
- lib/qiita/markdown/filters/truncate.rb
Overview
A filter for truncating a document without breaking the document structure.
You can pass ‘:length` and `:omission` option to :truncate context.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ length: 100, omission: "…".freeze, }.freeze
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/qiita/markdown/filters/truncate.rb', line 17 def call @current_length = 0 @previous_char_was_blank = false traverse(doc) do |node| if exceeded? node.remove elsif node.text? process_text_node(node) end end doc end |