Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is GONMarkupParser can render an html like this one? #5

Closed
TofPlay opened this issue Aug 26, 2015 · 4 comments
Closed

Is GONMarkupParser can render an html like this one? #5

TofPlay opened this issue Aug 26, 2015 · 4 comments

Comments

@TofPlay
Copy link

TofPlay commented Aug 26, 2015

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>
@nicolasgoutaland
Copy link
Owner

Hi,
unfortunately this is not the purpose of the GONMarkupParser to interpret plain HTML.
It's purpose is to provide a syntaxe to generate NSAttributedString.

Regards,

@TofPlay
Copy link
Author

TofPlay commented Aug 26, 2015

@nicolasgoutaland my html is very simple. No include, no javascript. Just basic embedded css, basic tags, links, images and html5 video. Your component already support basic tags. Links and images are supported by NSAttributedString. I believe that only the video that is not natively supported by NSAttributedString. You are not very far to support my html. 😄

@nicolasgoutaland
Copy link
Owner

You are right, but the parser will never handle CSS, this is not the objective ;)
And video tag is a nonsense in an AttributedString :)

@nicolasgoutaland
Copy link
Owner

To be fair, I think an evolution could be to generate a parser using a given CSS configuration, using the "Style" tag as a special marker, but this will imply to let a markup update its parent object, the parser, which is not a good thing I think.
The current architecture of the Parser won't allow that, and since everything is based on a FIFO list, this won't work.
Perhaps a solution will be to strip the head section from your html, extract the style content and use it as a parameter to build generate a parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants