Coder Social home page Coder Social logo

Comments (6)

nicolasgoutaland avatar nicolasgoutaland commented on May 27, 2024

Hi,
you have a parameter, _replaceNewLineCharactersFromInputString_ in GONMarkupParser class allowing you to ignore new line characters in your text. Set it to YES, so only <br/> and <p> will generate new line characters, like in pur HTML.

Let me know if it solves your problem.

Regards

from gonmarkupparser.

Ying1986 avatar Ying1986 commented on May 27, 2024

I'm talking about subsequence of <div> array.
On web browser it appear as multi lines (one div appears as one paragraph), but in your library it appear one line.

My html string has many <div> tags while edit rich editor by using https://github.com/cjwirth/RichEditorView.

from gonmarkupparser.

nicolasgoutaland avatar nicolasgoutaland commented on May 27, 2024

Ok. I see. Div isn't natively supported by the library. Its purpose is not to display pur HTML, but to simplfy attributedString generation.
The simplier way is to add a block markup :

    #import "GONMarkupList.h"
    // Custom markup, based on block
    GONMarkupBlock *markupBlock = [GONMarkupBlock blockMarkup:@"div"];
    markupBlock.updatedContentStringBlock = ^(NSString *string, NSMutableDictionary *context, NSDictionary *dicAttributes, NSDictionary *stringAttributes) {
        // If in a list, no new lines
        if ([context objectForKey:GONMarkupList_CONFIGURATIONS_KEY])
            return [[NSAttributedString alloc] initWithString:@"\u2028" attributes:stringAttributes];

            return [[NSAttributedString alloc] initWithString:@"\n" attributes:stringAttributes];
    };

    [_parser addMarkup:markupBlock];

from gonmarkupparser.

Ying1986 avatar Ying1986 commented on May 27, 2024

I can't see anything after add above code.

from gonmarkupparser.

nicolasgoutaland avatar nicolasgoutaland commented on May 27, 2024

Ok I see.
I didn't understood you problem.
Please try with this :

  // Custom markup, based on block
    GONMarkupBlock *markupBlock = [GONMarkupBlock blockMarkup:@"div"];
    markupBlock.suffixStringForContextBlock = ^(NSMutableDictionary *context, NSDictionary *dicAttributes, NSDictionary *stringAttributes) {
        // If in a list, no new lines
        if ([context objectForKey:GONMarkupList_CONFIGURATIONS_KEY])
            return [[NSAttributedString alloc] initWithString:@"\u2028" attributes:stringAttributes];

     return [[NSAttributedString alloc] initWithString:@"\n" attributes:stringAttributes];
    };

    [_parser addMarkup:markupBlock];

This will add a suffix instead of replacing content.

Regards

from gonmarkupparser.

Ying1986 avatar Ying1986 commented on May 27, 2024

After use above _parse there is no any character in UILabel,

Why did you return \n?
Perhaps <div>\n + content <\dev>???

from gonmarkupparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.