Coder Social home page Coder Social logo

gonmarkupparser's Issues

Markup Missing.

Hi, i just wanted to tell you that 'Strong' Markup is missing, i already added on my copy of this Lib, but you should consider it for further releases.

extract attributes RegExp question

Another question about extract attributes regexp in code below:

([^\\s=]+)\\s*=\\s*('(\\\\'|[^']*')|\"(\\\\\"|[^\"])*\")

why not is below:

([^\\s=]+)\\s*=\\s*('(\\\\'|[^'])*'|\"(\\\\\"|[^\"])*\")

Possible Scale Issue (Compiler warning at the least)

In class GONMarkupImage.m (line 22), the screen scale is stored in a variable. The very next line, the scale is hardcoded to 2.

The fact that initial value of scale is never used is causing a compiler warning, but I would assume that the hardcoded scale of 2 was not intentional as scales of 1 and 3 are also possible (with 3 becoming more popular as newer devices are released).

Code crashes on certain invalid HTML string

The code crashes when attempting to parse the following string:
@"<br>><<body>This is expected string<font color=\">Color</xxxx></body><"

I know it is invalid, but it should recover gracefully.
Error thrown:

caught "NSRangeException", "*** -[__NSCFConstantString substringToIndex:]: Index 18446744073709551615 out of bounds; string length 0"

Link support

Hi,

I'm having trouble with your recent link support code. The demo doesn't appear to work on either of my test devices - An iOS 7 iPhone 5 and an iOS 8 iPhone 4S. The links are rendered but not selectable and the delegate is never called.

I've had slightly more luck porting the code into my own App - it seem to work on the iOS 8 device but the links are rendered but not selectable on my iOS 7 device.

Any ideas why that might be?

Is it support for iOS 6?

I can not find any API for iOS 7 and later, but the cocoapods said it is for iOS 7 and later.

Is it support for iOS 6?

Calculate Height Markedup Text

I have to find the height of below mention string.
<b><font color='#565E6F'>Apollo Munich - Dengue Care<\/font><\/b><br><font color='#565E6F'>&emsp; Sum Insured : <\/font><b><font color='#565E6F'>&#8377; 50 K<\/font><\/b><br><font color='#565E6F'>&emsp; Premium : <\/font><b><font color='#565E6F'><b><font color='#565E6F'>&#8377;<\/font><\/b> 511<\/font><\/b><br><font color='#565E6F'>&emsp; Members : <\/font><b><font color='#565E6F'>All Members<\/font><\/b>

Parsing tag with attribute

I try to parse <span class="keyword"> and <span class="string">.
This is my setup:
[[GONMarkupParserManager sharedParser] addMarkup:[GONMarkupSimple simpleMarkup:@"<span class=\"string\">" style:@{ NSFontAttributeName: [UIFont fontWithName:@"Menlo-Regular" size:fontSize], NSForegroundColorAttributeName: [UIColor redColor] } mergingStrategy:GONMarkupSimpleMergingStrategyMergeAll]];

I've also tried:
[[GONMarkupParserManager sharedParser] addMarkup:[GONMarkupSimple simpleMarkup:@"span class=\"string\"" style:@{ NSFontAttributeName: [UIFont fontWithName:@"Menlo-Regular" size:fontSize], NSForegroundColorAttributeName: [UIColor redColor] } mergingStrategy:GONMarkupSimpleMergingStrategyMergeAll]];

In both cases, I receive MarkupParser : No markup found for tag . Of course, I can add span as a tag, but I need to differentiate strings and keywords.

Do you have a solution for this problem?

Btw: Great parser! 🙌

Adding line on UITextView

Hi @nicolasgoutaland ,

I'm looking for a function to insert text on a UITextView.
for example:
textView.insert("<strong>house</strong>")
textView.insert("<blue>car</car>")
This way I'm adding text dynamically istead of converting the whole text.
image

There is a way to do that? I only saw .setMarkedUpText(String) function.
I'm looking for something like .insertMarkedUpText(String).

I hope support <image src='icon.png'></> ! TKS!!!

Modify

the following:

- (NSAttributedString *)computeFinalExtractedString:(NSString *)inputString
{
    GONMarkup *currentMarker = [_markupsStack lastObject];
    if (currentMarker && ![currentMarker isKindOfClass:[NSNull class]])
    {
        NSString *string = [currentMarker updatedContentString:inputString
                                                       context:_currentContext
                                                    attributes:[self attributesForCurrentTag]];
        if ([string isKindOfClass:[NSString class]]) {
            return [[NSAttributedString alloc] initWithString:string
                                                   attributes:[self currentConfiguration]];
        }else if ([string isKindOfClass:[NSAttributedString class]]){
            return (NSAttributedString*)string;
        }

    }
    return [[NSAttributedString alloc] initWithString:inputString attributes:[self currentConfiguration]];
}

Add Class

the following:

@implementation GONImageMarkup
+ (instancetype)imageMarkup
{
    return [self markupForTag:@"image"];
}

- (id)updatedContentString:(NSString *)string context:(NSMutableDictionary *)context attributes:(NSDictionary *)dicAttributes
{
    UIImage *image = [UIImage imageNamed:[dicAttributes objectForKey:@"src"]];
    if (image)
    {
        // 添加表情
        NSTextAttachment *attch = [[NSTextAttachment alloc] init];
        // 表情图片
        attch.image = image;
        // 设置图片大小
        attch.bounds = CGRectMake(0, 0, image.size.width/2, image.size.height/2);
        NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
        return string;
    }
    return string;
}

#pragma mark - Style
- (void)openingMarkupFound:(NSString *)tag configuration:(NSMutableDictionary *)configurationDictionary context:(NSMutableDictionary *)context attributes:(NSDictionary *)dicAttributes
{

}


@end

<p> is not getting replaced

Hello, I am trying a following code but still I am getting<p>in my label text

let parser = GONMarkupParser.defaultMarkupParser()
parser.replaceNewLineCharactersFromInputString = true
parser.attributedStringFromString(html)

How to support image from remote-service?

How to support image from remote-service?
<img src="http://h.hiphotos.baidu.com/image/h%3D200/sign=e72c850a09f3d7ca13f63876c21fbe3c/a2cc7cd98d1001e9460fd63bbd0e7bec54e797d7.jpg" />

Method accepting NSError** should have a non-void return value to indicate whether or not an error occurred warnings

LLVM/Clang warnings when compiling due to methods that accept NSError** not returning a BOOL value to indicate if there was an error.

File with error: GONMarkupParser.m

Methods with error:

  • (void)handleClosingTag:(NSString )tag error:(NSError *)error (line 426)
  • (void)handleOpeningTag:(NSString )tag error:(NSError *)error (line 504)
  • (void)generateError:(NSError **)error tag:(NSString *)tag (line 567)

Don't mind creating a PR if requested.

Autoclosing tag parsing flow control design question?

I have one question about autocloing tag parsing flow control while I reading the source code recently.

In parseString:error: method, to determine the tag is autoclosing, then parse it seperately.

Why not replacing the autoclosing tag with the opening and closing tag pair before call parseString:error: method. If this, the parsing flow control will become more consistent.

Question modification

Hi,

Is it possible to support, for example:
<custom size = 20> and <custom size = "20">

Thanks

Is GONMarkupParser can render an html like this one?

Hi,
Is GONMarkupParser can render an html like this one?

<html>
    <head>
        <style>
        h2 {
        font-family: 'OpenSans';
        font-size: 19;
        }

        p {
        font-family: 'OpenSans';
        font-size: 14;
        }

        u {
        font-family: 'OpenSans';
        font-size: 14;
        text-decoration: 'underline';
        }

        em {
        font-family: 'OpenSans-Italic';
        font-size: 14;
        }

        code {
        font-family: 'OpenSans-Light';
        font-size: 14;
        }

        h3 {
        font-family: 'OpenSans';
        font-size: 16;
        }

        div {
        font-family: 'OpenSans';
        font-size: 14;
        }

        span {
        font-family: 'OpenSans';
        font-size: 14;
        }

        h1 {
        font-family: 'OpenSans';
        font-size: 21;
        }

        b {
        font-family: 'OpenSans-Bold';
        font-size: 14;
        }
        </style>
    </head>
    <body>
        <h1>Titre 1</h1>
        <h2>Titre 2</h2>
        <h3>Titre 3</h3>
        <p>
            <strong>gras</strong><br/>
            <em>italic</em><br/>
            <u>underscore</u>
        </p>
        <p><code>ruby
            require 'redcarpet'
            markdown = Redcarpet.new("Hello World!")
            puts markdown.to_html
        </code></p>
        <p>This is a text</p>
        <p>An image</p>
        <p>
            <a href="http://www.houstonpettalk.com/wp-content/uploads/2009/04/grass.jpg"><img src="http://www.houstonpettalk.com/wp-content/uploads/2009/04/grass.jpg" height="156" width="218" alt="grass.jpg" /></a>
        </p>
        <p>A video</p>
        <video height="150" width="218" controls>
            <source src="http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4" type="video/mp4"> Your browser does not support the video tag.
        </video>
    </body>
</html>

Bug?

Hi,

I test your library, but I have a problem with this :
Title<small><right>Name</right>/small>
Alignment don't work.

Any idea?

Thanks

I can't compile with this libaray.

I have added this library, but I can' compile it as following error log.

/.../Pods/GONMarkupParser/Classes/GONMarkupColor.m:10:9: 'NSString+Color/NSString+Color.h' file not found

I'm using Cocoapods 1.0.

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.