my code didnt break and try to fill every line - html

i try to launch my code to crete a simple elearning website which use pymongo as database. i write the codes in google docs before it save it in pymongo.
the main problem is, my code didnt break(br) like it use to and even trying to fill all line. this only occur to short code but doesnt do the same with long one. it happen sometimes but i cant seems to get it fix. i did try to remove the css to see if the problem is from there but same thing happens. i dont know what seems to be the problem.
<h4>i love food</h4>
<p>there are many food i like.</p>
<p>the food are as follow:</p>
<ul>
<li>chicken</li>
<li>fish</li>
<li>nugget</li>
</ul><br>
<p>all from above is my favourite</p>
<h4>MA 7 & EMA 26</h4><br>
here are a simple code similar to mine. but the problem is the code stacks.
result :
i love food
there are many food like.
the food are as follow: .chicken all from above is my favourite
.fish
.nugget
MA 7 & EMA 26
as you can see, some stack and some dont. im preatty sure is not the code. but cant think of another problem.

Your code works fine !
https://jsfiddle.net/zvdqk0mr/
Use <div class="clear"> </div> and CSS .clear{clear:both;}
instead of <br> if you facing this line break issue
https://jsfiddle.net/zvdqk0mr/1/

Related

How to add a text in every line with an existing texts using regex in Notepad++?

Is it possible to add a text or HTML tags after each line with an existing text in Notepad++?
For example, this text:
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[COMPANY]</a></p>
Alexander Hamilton (Alexander Hamilton)
We are waiting in the wings for you (waiting in the wings for you)
You could never back down
You never learned to take your time!
Oh, Alexander Hamilton (Alexander Hamilton)
When America sings for you
Will they know what you overcame?
Will they know you rewrote the game?
The world will never be the same, oh
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[BURR, MEN, & COMPANY]</a></p>
The ship is in the harbor now
See if you can spot him
Just you wait
Another immigrant
Comin’ up from the bottom
Just you wait
His enemies destroyed his rep
America forgot him
The goal is to make the text above be like this: (adding the break tags)
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[COMPANY]</a></p>
Alexander Hamilton (Alexander Hamilton)</br>
We are waiting in the wings for you (waiting in the wings for you)</br>
You could never back down</br>
You never learned to take your time!</br>
Oh, Alexander Hamilton (Alexander Hamilton)</br>
When America sings for you</br>
Will they know what you overcame?</br>
Will they know you rewrote the game?</br>
The world will never be the same, oh</br>
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[BURR, MEN, & COMPANY]</a></p>
The ship is in the harbor now</br>
See if you can spot him</br>
Just you wait</br>
Another immigrant</br>
Comin’ up from the bottom</br>
Just you wait</br>
His enemies destroyed his rep</br>
America forgot him</br>
I was using <pre></pre> earlier, but noticed a horizontal scroll has appeared after text wrapping and cannot make it disappear, therefore, I'm discarding it and will opt to use <br> tags.
The problem I have is there's no "common denominator" for each line that I can use to add the <br> tags. Therefore, I'm hoping there could be a regex trick to do this, like detecting an empty space after each line?
It doesn't have to be done in one go, I'm just hoping there is a quicker way to this.
A side question: Is there a a way to add an id or class to each line of these plain texts without adding <a> or <p> tags?
Lots of thanks in advance!
Use
$(?<=.)(?<!>)
Replace with <br/>.
See proof. $(?<=.)(?<!>) will match any end-of-line position that has a character other than line break characters before it and no > character afer.

Pre Tag in HTML

So I am just learning to HTML , as I wanted to become a web developer.
I used the <pre> tag for the proper alignment in my code.
But the alignment seems to come little fuzzy.
But the output of 3 and 4 i.e Reason to live and Happiness are not properly align with respect to the above quotes.
<p>For me you are:</p>
<pre>
1.Love
2.Life
3.Reason to Live
4.Happiness
</pre>
I've tested your code and it seems to line up fine, you could always put the content in a list like the below:
<ol>
<li>Love</li>
<li>Life</li>
<li>Reason to Live</li>
<li>Happiness</li>
</ol>
If this isn't what you need, please could you show us how it appears for you?
I have tested your code, it works fine
You can share how it appears in your machine.

CSS Selectors for Scrapy Web Scraping

I'm currently trying to scrape all the malls listed on the website
https://web.archive.org/web/20151112172204/http://www.simon.com/mall
using Python and Scrapy. I can't figure out how to extract the text "Anchorage 5th Avenue Mall".
<div class="st-country-padding">
<h4><a class="no-underline" href="/web/20151112172204/http://www.simon.com/search/alaska%2b(ak)" title="View Malls In Alaska">Alaska</a></h4>
<div>
Anchorage:
Anchorage 5th Avenue Mall
</div>
</div>
I've tried a number of differnet attempts including
response.css("a::attr(title)").extract()
But doesn't give me what I'm looking for.
Note that Anchorage is just the name of the first mall so I can't call that directly because there are 200 or so different malls
::attr(title) gives you the value of the title attribute. What you want is the text, so you need to use ::text instead.
Also, there doesn't appear to be a good way to identify the a element you want since it doesn't have anything that distinguishes it from the others, so a bit of pathing is necessary. Let me know if this works for you:
response.css(".st-country-padding > div > a:last-of-type::text").extract()

Syntactic sugar in html/xhtml

I'm currently writing html/xhtml by hand, and that's fine to me, but I would like to ease things a little bit, especially for writing footnotes.
Today, here is how I write footnotes:
<p>Here is a footnote<a id="ref1b" href="#ref1">[1]</a>.</p>
<!-- And at the end of the document -->
<div class="footnotes">
<h2>Notes</h2>
<p id="ref1">[1] But this one isn't very helpful.
<!-- Let's add a go-back-to-the-text arrow -->
↩
</p>
</div>
The idea would be to make things automatic, and potentially done on the client side (by the browser), so that I could write something like that:
<p>Here is a footnote<ref id="1"/>.</p>
<!-- And at the end of the document -->
<div class="footnotes">
<h2>Notes</h2>
<ref-def id="1">But this one isn't very helpful.</ref-def>
</div>
So ref and ref-def would simply be evaluated on the fly by the browser.
Is this possible only using html/xhtml and css?
For completeness purpose. As of today there is a footnote tag in HTML.
https://www.w3.org/MarkUp/html3/footnotes.html
How it is presented to clients is left to implementors. Yo can use more html or css for a better formatting.
<DL>
<DT>Hamlet: <DD>You should not have believed me, for virtue cannot so inoculate our old stock but we shall relish of it. I loved you not.
<DT>Ophelia: <DD> I was the more deceived.
<DT>Hamlet: <DD>Get thee to a nunnery. Why wouldst thou be a breeder of sinners? I am myself indifferent honest ...
</DL>
<fn id=fn1><i>inoculate</i> - graft</fn>
<fn id=fn2><i>relish of it</i> - smack of it (our old sinful nature)</fn>
<fn id=fn3><i>indifferent honest</i> - moderately virtuous</fn>
the way you're doing this now has the advantage of being accessible and standards compliant - it will work with any browser - even with javascript disabled. Also search engines will be able to make sense out of this.
So there are some benefits in doing it this way.
if you decided to go for a shorter alternative, then there's plenty of jQuery plugins that will make your task more comfortable. e.g. look at https://github.com/nicholascloud/footnote.js
If you go for that approach please also note, that your site speed will suffer as users will have to download plenty of javascript to get your footnotes working.

Do you use any tools for rapid html/css development?

I just heard about zen-coding, which basically is just a script that generates markup based on a css-esque selector, ex:
div#foo > p*6
generates
<div id="foo">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
Edit: Here's a more advanced example..
And PS - I'm not even going through any API, I'm totally guessing based on my CSS selector knowledge, this is very easy and intuitive for me.
ul#nav > li[id] * 6 > a
Generates
<ul id="nav">
<li id="">
</li>
<li id="">
</li>
<li id="">
</li>
<li id="">
</li>
<li id="">
</li>
<li id="">
</li>
</ul>
when you hit a shortcut such as Ctrl-E. Very very useful if you do a lot of front end development. I had the idea of the exact opposite, a CSS selector generator which basically parses markup and generates selectors so one can go in a tool such as Firebug and rapidly see live changes on the dot, I just never bothered to actually finish the script I had started.
It's currently supported in TextMate, Dreamweaver, Aptana, NetBeans, unfortunately not vim/emacs however there is a fork named sparkup which works on vim ( I use that now ).
I'm wondering if anyone has come across such plugins or tools in the past - I'm aware that there are snippet scripts in Vim/Textmate/Emacs and other powerful editors, just curious of what else is out there in the wild.
Hm. I write a lot of HTML and CSS every day and I am not excited. The paragraph you mention I write in five seconds, and six times Ctrl+C and Ctrl+V. Granted, there may be scenarios when a meta language will save more time but I have never felt the need for one. When there are really massive amounts of HTML - or SQL, or arrays - to produce, I will write a small PHP or VB script for the task. I wouldn't want another meta-language to produce something in another language.
Maybe useful for others but not for me.
If discussion about the general usefulness was what you were looking for. Reading your post a second time, I'm not that sure any more. Anyway. :)
If you are developing rails, check out Sass and Haml
Sass can do use variables and do basic math:
// Sass
!blue = #3bbfce
!margin = 16px
.content_navigation
border-color = !blue
color = !blue - #111
.border
padding = !margin / 2
margin = !margin / 2
border-color = !blue
renders:
/* CSS */
.content_navigation {
border-color: #3bbfce;
color: #2aaebd;
}
.border {
padding: 8px;
margin: 8px;
border-color: #3bbfce;
}
Haml uses indentation instead of divs and matches the css # and . system for labeling classes and divs:
#profile
.left.column
#date= print_date
#address= current_user.address
.right.column
#email= current_user.email
#bio= current_user.bio
renders to:
<div id="profile">
<div class="left column">
<div id="date"><%= print_date %></div>
<div id="address"><%= current_user.address %></div>
</div>
<div class="right column">
<div id="email"><%= current_user.email %></div>
<div id="bio"><%= current_user.bio %></div>
</div>
</div>
I'm really amazed that you guys are having this conversation.
I've been doing Web Development for 4 years and I can not remember the last time that I've had to write something like
<li>some text</li>
more then once in single instance.
The most html that I would write in any given point is something like
<ul>
<?php foreach ( $menu as $item ) : ?>
<li><?php echo $item->title ?></li>
<?php endforeach; ?>
</ul>
Needless to say, I really don't see the point in learning a tool to speed up writing of stastic HTML. It's like getting a bigger shovel, you're only going to dig yourself into a bigger whole.
I think you should be asking yourself, how can I eliminate the amount of static html that I generate?
The answer to that question is to use CMSs like Joomla, Drupal or Wordpress.
If you absolutely have to write static html sites, then look at something like Sphinx.
Sphinx completely eliminates the need to write HTML and it allows you to create static sites with multiple pages without ever writing a single hard coded html link.
Sphinx uses reStructuredText markup. I will show you how you would generate your code in reStructuredText.
- `Joomla`_
- `Drupal`_
- `Wordpres`_
- `Sphinx`_
_ :doc:`Some intermal Page <internal/file>`
.. _Joomla: http://joomla.org
.. _Drupal: http://drupal.org
.. _Wordpress: http://wordpress.org
.. _Sphinx: https://www.sphinx-doc.org
I tried to show how this would work with reStructuredText, the example that you have doesn't exactly make sense in Sphinx context because you would never create a tags without providing links to them. But you get an idea I hope.
The Blueprint CSS framework has a Rapid HTML/CSS Development-like tagline:
Spend your time innovating, not replicating.