I'm starting my iPhone programming adventure, with a simple HTML scraping. I'm using the Hpple library to do the job, and I have a question...
Suppose I have the following html to parse...
<div>
<div> A <!-- Comment 1 --></div>
<div> B </div>
<div> C <!-- Comment 2 --></div>
</div>
How can I retrieve the commented parts? They don't show up on the objects... I was checking the docs but there's nothing pointing to that direction.. (also googling "hpple comment" doesn't produce the best results...).
thanks in advance.
Comments are not considered part of the content and are stripped out by pretty much all parsers except humans.
Similarly, you can't ask the parser to tell you how many spaces and newlines are between the first two <div> elements.
Related
I am creating an amp for my webpage. It contains lot of description about places. I want to implement ..show more after 4 lines so that user can see other content also in the mobile first fold (Text is dynamic so can be less than 4 lines also. In that case how can i determine that show more will not come) Is this possible with AMP?? Since I cannot use javascript and css solution is not possible for this, please help me in finding alternatives for the same. I have searched a lot about this but no luck so far. Thanks in advance
You can use an amp-accordion for this:
<p>The first four lines...</p>
<amp-accordion disable-session-states>
<section>
<h4>
<span class="show-more">Show more</span>
</h4>
<p>The remaining text... </p>
</section>
</amp-accordion>
Here is a working example.
I am a bit confused about tag usage in the ionic framework. If you check their docs under CSS components, you'll see they use existing tags (particularly div) with a specific class choice to achieve formatting, just like you'd expect from something like bootstrap. Example:
<div class="bar bar-header bar-light">
<h1 class="title">bar-light</h1>
</div>
If you go by their code samples, however, you see that they use custom ion tags instead. Example:
<ion-header-bar class="bar-assertive">
<h1 class="title">Left Menu</h1>
</ion-header-bar>
The same practice of using custom ion tags is used in their guide as well as a pluralsight tutorial I found on ionic.
So what's going on here? If both approaches accomplish the same thing, which one is considered best practice?
Ionic Framework, as stated in their site, is:
Ionic is both a CSS framework and a Javascript UI library. Many
components need Javascript in order to produce magic, though often
components can easily be used without coding through framework
extensions such as our AngularIonic extensions.
Using CSS Components you're simply applying CSS styling to your HTML page.
When using the Ionic directives you're using a fully-featured JavaScript component and you have access to the APIs provided by the framework.
To better understand the difference you should dig into AngularJs directives.
Take the list for example. You could create a simple list using an HTML ul li:
<ul class="list">
<li class="item">
...
</li>
</ul>
but if you use the directive:
<ion-list>
<ion-item ng-repeat="item in items">
Hello, {{item}}!
</ion-item>
</ion-list>
you have access to the extended features provided by the framework (see the API at the bottom of the page).
I tend to use directives most of the times unless I know I don't want any kind of interaction with the interface.
We have a web application that its UI is based on GWT.
We are pretty satisfied from the technology, but we have one major problem: We get html files from our designer, and it takes a lot of time to integrate them into our GWT code.
Is there a quick way or rules to do that?
For instance, I would like to take the html, put it almost "as is" in a ui.xml file, and then start binding the components to UiBinder fields.
What is the quickest way to do that? What should I do with the CSS and JS files that I get?
I need some guidelines to make this conversion, so it will be quick & easy.
We have the same problem. It might be hard for a designer to get used to GWT widgets. But he'll have to forget about making HTML proof-of-concepts and using GWT directly.
We didn't overcame the difficulty. As a result, many GWT features are under-used (like CSSResources, or GWT-Bootstrap layout capabilities).
I would advise to have him learn the xml of GWT widget libraries.
You can also start by using GWT Designer. This way he can still do the design, learn the XML bit by bit, and you can still work on wiring the components.
Of course it is a slow process. People don't change old habits instantly.
Errai seems to fit your requirements.
Basically is uses regular HTML5 templates, binded to GWT logic.
"Create standard conform HTML5 templates or use existing HTML and CSS files to design your web and mobile applications."
http://errai.github.io/
Here is an example of a sign-in page:
<!DOCTYPE html>
<link rel=stylesheet href="css/TodoList.css">
<div data-field="main">
<h1>Get it done with Errai.</h1>
<div class=form>
<p class=error data-field=loginError>
Login failed. Please check that your email address and password were entered correctly.
</p>
<input type=text data-field=username placeholder="Email">
<input type=password data-field=password placeholder="Password">
<button data-field=loginButton>Sign In</button>
<p>New here? Sign up in seconds!</p>
</div>
</div>
source
(p.s. I've never used it, yet)
How can I validate that all tags have been closed in emacs?
<div>
hi
<div id="2">
hello
<div>
The above being a very simple example of a missing div. How can i see in emacs which html tag is missing?
If it is XHTML, nxml-mode can validate it automatically. That's what I am using. (I.e. I switch to nxml-mode for validation, though I usually use html-mode.)
The Facebook comments count can be done in three different ways: (without directly using JS)
<fb:comments-count href="http://example.com" />
<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com" />
<div class="fb-comments-count" data-href="http://example.com">0</div>
The issue, however, is that doing something like this messes things up:
<p><div class="fb-comments-count" data-href="http://example.com">0</div> comments</p>
...because a <div> is firstly, not valid inside a <p> tag and secondly, looks wrong (though this could be fixed with CSS).
Basically, my question is: is there a way to do the above without using a <div> (a <span> for example), bearing in mind that I want to use the HTML5 method and (if possible!) want to avoid using javascript?
Clarification: I would like to avoid writing extra JS in the page simply because the MVC view currently looks nice and clean and I would prefer to keep it that way. Obviously, I'm still including the Facebook Connect library.
So, one solution would be to use a DIV instead of a P as the outer element.