markwon-core/src/main/java/ru/noties/markwon/SpannableBuilder.java
@NonNull
    public SpannableStringBuilder spannableStringBuilder() {

        // okay, in order to not allow external modification and keep our spans order
        // we should not return our builder
        //
        // plus, if this method was called -> all spans would be applied, which potentially
        // breaks the order that we intend to use
        // so, we will defensively copy builder

        // as we do not expose builder and do no apply spans to it, we are safe to NOT to convert to String

        final SpannableStringBuilderReversed reversed = new SpannableStringBuilderReversed(builder);

        // NB, as e are using Deque -> iteration will be started with last element
        // so, spans will be appearing in the for loop in reverse order
        for (Span span : spans) {
            reversed.setSpan(span.what, span.start, span.end, span.flags);
        }

        return reversed;
    }
@NonNull
    public SpannableStringBuilder spannableStringBuilder() {

        // okay, in order to not allow external modification and keep our spans order
        // we should not return our builder
        //
        // plus, if this method was called -> all spans would be applied, which potentially
        // breaks the order that we intend to use
        // so, we will defensively copy builder

        // as we do not expose builder and do no apply spans to it, we are safe to NOT to convert to String

        final SpannableStringBuilderReversed reversed = new SpannableStringBuilderReversed(builder);

        // NB, as e are using Deque -> iteration will be started with last element
        // so, spans will be appearing in the for loop in reverse order
        for (Span span : spans) {
            reversed.setSpan(span.what, span.start, span.end, span.flags);
        }

        return reversed;
    }
@ NonNull public SpannableStringBuilder spannableStringBuilder ( ) { // okay, in order to not allow external modification and keep our spans order // we should not return our builder // // plus, if this method was called -> all spans would be applied, which potentially // breaks the order that we intend to use // so, we will defensively copy builder // as we do not expose builder and do no apply spans to it, we are safe to NOT to convert to String final SpannableStringBuilderReversed reversed = new SpannableStringBuilderReversed ( builder ) ; // NB, as e are using Deque -> iteration will be started with last element // so, spans will be appearing in the for loop in reverse order for ( Span span : spans ) { reversed . setSpan ( span . what , span . start , span . end , span . flags ) ; } return reversed ; }
Simple method to create a SpannableStringBuilder, which is created anyway. Unlike {@link #text()}
method which returns the same SpannableStringBuilder there is no need to cast the resulting
CharSequence and makes the thing more explicit

@since 2.0.0
Simple method to create a SpannableStringBuilder which is created anyway . Unlike { @link #text () } method which returns the same SpannableStringBuilder there is no need to cast the resulting CharSequence and makes the thing more explicit