Skip to content

Commit 60ff915

Browse files
committed
fixed some typos, etc.
1 parent 438c2af commit 60ff915

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

slides_sources/source/exercises/html_renderer.rst

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ But this is not very Pythonic style -- it's OO heavy. Strings for text are so co
347347
348348
So much easier.
349349

350-
To accomplish this, you can update the ``append()`` method to put this wrapper around plain strings when somethign new is added.
350+
To accomplish this, you can update the ``append()`` method to put this wrapper around plain strings when something new is added.
351351

352352

353353
Checking if it's the right type
@@ -402,9 +402,10 @@ check if the passed-in object has a ``render()`` attribute:
402402
self.content.append(TextWrapper(str(content))
403403
404404
405-
Note that I added a ``str()`` call too -- so you can pass in anything -- it it will get string-ified -- this will be ugly for many objects, but will work fine for numbers and other simple objects.
405+
Note that I added a ``str()`` call too -- so you can pass in anything -- it will get stringified -- this will be ugly for many objects, but will work fine for numbers and other simple objects.
406+
407+
This is my favorite. ``html_render_wrap.py`` in Solutions demonstrates some core bits of this approach.
406408
407-
This is my favorite. ``html_render_wrap.py`` in Solutions demonstrates with method.
408409
409410
Duck Typing on the Fly
410411
----------------------
@@ -422,7 +423,7 @@ Again, you could type check -- but I prefer the duck typing approach, and EAFP:
422423
423424
If content is a simple string then it won't have a render method, and an ``AttributeError`` will be raised.
424425
425-
You can catch that, and simply write the content.
426+
You can catch that, and simply write the content directly instead.
426427
427428
.. nextslide::
428429
@@ -442,25 +443,25 @@ If the object doesn't have a ``render`` method, then an AttributeError will be r
442443
443444
Depending on what's broken, it could raise any number of exceptions. Most will not get caught by the except clause, and will halt the program.
444445
445-
But if, just by bad luck, it has an bug that raises an ``AttributeError`` -- then this could catch it, and try to simply write it out instead. So you may get somethign like: ``<html_render.H object at 0x103604400>`` in the middle of your html.
446+
But if, just by bad luck, it has an bug that raises an ``AttributeError`` -- then this could catch it, and try to simply write it out instead. So you may get something like: ``<html_render.H object at 0x103604400>`` in the middle of your html.
446447
447448
**The beauty of testing**
448449
449-
If you have a unit test that calls every render method in your code -- then it should catch that error, and it wil be clear where it is coming from.
450+
If you have a unit test that calls every render method in your code -- then it should catch that error, and in the unit test it will be clear where it is coming from.
450451
451452
452453
HTML Primer
453454
============
454455
455456
.. rst-class:: medium
456457
457-
The very least you need to know about html to do this assigment.
458+
The very least you need to know about html to do this assignment.
458459
459460
.. rst-class:: left
460461
461-
If you are familar with html, then this will all make sense to you. If you have never seen html before, this might be a bit intimidating, but you really don't need to know much to do this assignment.
462+
If you are familiar with html, then this will all make sense to you. If you have never seen html before, this might be a bit intimidating, but you really don't need to know much to do this assignment.
462463
463-
First of all, sample output from each step is provided. So all you really need to do is look at that, and make your code do the same thing. But it does help to know a little bit about what you are doing.
464+
First of all, sample output from each step is provided. So all you really need to do is look at that, and make your code do the same thing. But it does help understand a little bit about what you trying to do.
464465
465466
HTML
466467
----
@@ -487,15 +488,16 @@ Elements
487488
Modern HTML is a particular dialect of XML (eXtensible Markup Language),
488489
which is itself a special case of SGML (Standard Generalized Markup Language)
489490
490-
It inherits from SGML a basic structure: each piece of the document is an element. each element is described by a "tag". Each tag has a different meaning, but they all have the same structure::
491+
It inherits from SGML a basic structure: each piece of the document is an element. Each element is described by a "tag". Each tag has a different meaning, but they all have the same structure::
491492
492493
<some_tag> some content </some_tag>
493494
494-
that is, the tag name is surrounded by < and >, which marks the beginning of
495+
That is, the tag name is surrounded by < and >, which marks the beginning of
495496
the element, and the end of the element is indicated by the same tag with a slash.
496497
497498
The real power is that these elements can be nested arbitrarily deep. In order to keep that all readable, we often want to indent the content inside the tags, so it's clear what belongs with what. That is one of the tricky bits of this assignment.
498499
500+
499501
Basic tags
500502
----------
501503
@@ -516,7 +518,7 @@ In addition to the tag name and the content, extra attributes can be attached to
516518
517519
.. code-block:: html
518520
519-
<p style="text-align: center; font-style: oblique;">
521+
<p style="text-align: center" id="intro">
520522
521523
There can be all sorts of stuff stored in attributes -- some required for specific tags, some extra, like font sizes and colors. Note that since tags can essentially have any attributes, your code will need to support that -- doesn't it kind of look like a dict? And keyword arguments?
522524
@@ -537,6 +539,9 @@ To make a link, you use an "anchor" tag: ``<a>``. It requires attributes to indi
537539
538540
The ``href`` attribute is the link (hyper reference).
539541
542+
lists
543+
-----
544+
540545
To make a bulleted list, you use a <ul> tag (unordered list), and inside that, you put individual list items <li>:
541546
542547
.. code-block:: html
@@ -559,17 +564,3 @@ Section Headers are created with "h" tags: <h1> is the biggest (highest level),
559564
<h2>PythonClass - Class 7 example</h2>
560565
561566
I think that's all you need to know!
562-
563-
564-
565-
566-
567-
568-
569-
570-
571-
572-
573-
574-
575-

0 commit comments

Comments
 (0)