instance method join_children

Ruby on Rails edge

Since edge Private — implementation detail, not part of the public API

Signature

join_children(child_values)

No documentation comment.

Parameters

child_values req
Source
# File actiontext/lib/action_text/markdown_conversion.rb, line 336
      def join_children(child_values)
        merged = []

        child_values.each do |value|
          # Merge adjacent bold/italic runs which Lexxy emits
          if value.is_a?(Array) && (value[0] == :bold || value[0] == :italic)
            if merged.last.is_a?(Array) && merged.last[0] == value[0]
              merged.last[1] = merged.last[1] + value[1]
            else
              merged << [ value[0], value[1] ]
            end
          else
            merged << value
          end
        end

        parts = merged.map { |v| stringify(v) }
        result = +""
        parts.each do |part|
          # A block child has to begin its own block. Renderers disagree about whether a fence or
          # a list may interrupt a paragraph, and one that says no releases the content the fence
          # was holding, so separate with a blank line rather than a single newline.
          if !result.empty? && part.end_with?("\n\n")
            result << "\n" until result.end_with?("\n\n")
          end
          result << part
        end
        result
      end

Defined in actiontext/lib/action_text/markdown_conversion.rb line 336 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionText::MarkdownConversion

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close