WordPress Tips 2
April 15, 2008
Continuing from yesterdays tips I have a few tips that can help bloggers begin.
Purty Colors
Ok this is is more like for the coder blogger. Why have dull black text white back predefined html? Hmmm? Do your scripts just look plain dull? Well why not whip them into shape with TOhtml? What is that you say? TOhtml is a vim plugin that converts highlight syntaxing done in vim to HTML. Pretty cool you say? huh? How much? Well loyal listeners we’re dropping it’s average retail price for you and each new TOhtml you’ll get is ABSOLUTELY FREE!!! naw, you say! too good?! Where do I get it? Well faithful reader we’ll be glad to tell you that TOhtml comes bundled in every vim package.
Using TOhtml is as simple just typing “:TOhtml” at the vim prompt. TOhtml doesn’t print the best html though and often I find that I don’t want the TOhtml to create a separate page but rather as a segment in this blog so I created script that does this:
#!/bin/bash # vm2html-segment # # Create HTML formatted text suitable for displaying syntax highlighting # in a blog post, or possibly some forums. FILENAME=$1 #vim -f +"syn on" +"let html_no_pre = 1" +'let html_use_encoding = "utf8"' +"let use_xhtml = 1" +"let html_number_lines = 0" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" $FILENAME vim -f +"syntax on" \ +"colorscheme simple256" \ +"let html_no_pre = 1" \ +"let html_number_lines = 0" \ +"TOhtml" \ +"x" \ +"q" $FILENAME # Just need the colored syntax, deleting the HTML page information. sed -i '1,/body bgcolor=/d' $FILENAME.html # Adding preformatting first <pre> tag sed -i '1 i <pre>' $FILENAME.html # Line breaks no longer need to be defined with preformatted text. sed -i 's|<br>||g' $FILENAME.html # Remove the closing HTML tags. sed -i 's~</body[^>]*>~~g' $FILENAME.html sed -i 's~</html[^>]*>~~g' $FILENAME.html # Add the closing preformatting tag sed -i '$ a </pre>' $FILENAME.html
Post Ownership
Being blog-rolled is when a post the owner has written appears to belong to someone else because it has been reprinted. I use the creative commons attribution license here so my content is free distributable as long as there is reference to the original work but I have discovered that search engines can misinterpret the original owner of the post. Google has a fail-safe that can tell ownership of a post by that post linking to itself. I have created a script that can makes this simple:
#!/bin/bash # vm2html-segment # # Create HTML formatted text suitable for displaying syntax highlighting # in a blog post, or possibly some forums. FILENAME=$1 #vim -f +"syn on" +"let html_no_pre = 1" +'let html_use_encoding = "utf8"' +"let use_xhtml = 1" +"let html_number_lines = 0" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" $FILENAME vim -f +"syntax on" \ +"colorscheme simple256" \ +"let html_no_pre = 1" \ +"let html_number_lines = 0" \ +"TOhtml" \ +"x" \ +"q" $FILENAME # Just need the colored syntax, deleting the HTML page information. sed -i '1,/body bgcolor=/d' $FILENAME.html # Adding preformatting first <pre> tag sed -i '1 i <pre>' $FILENAME.html # Line breaks no longer need to be defined with preformatted text. sed -i 's|<br>||g' $FILENAME.html # Remove the closing HTML tags. sed -i 's~</body[^>]*>~~g' $FILENAME.html sed -i 's~</html[^>]*>~~g' $FILENAME.html # Add the closing preformatting tag sed -i '$ a </pre>' $FILENAME.html
Type “wordpress-link title of post” and paste in blog. This creates an invisible link and will not be seen.
Style Sheet
Commercial wordpress users will need to pay a few dollars to be able to create a custom style sheet. Some style sheet attributes can be added though within the html tags. For instance, I like padding around images:
<img src="http://linuxtidbits.files.wordpress.com/2008/03/link-saturday.png" style="margin:0 10px 5px 0;" align="left" alt="Links Saturday" / >
WordPress RSS Feeds
A final note on WordPress RSS feeds. WordPress RSS feeds do the odd behavior of subsituting the username for the title of the feed. Changing to an ATOM feed can fix this but if you’re stuck with a news aggregator site that refuses feed changes the title can be changed by defining the name (alt tag) of the last image of the post:
<img src="http://linuxtidbits.files.wordpress.com/2008/04/wordpress-icon-128.jpg" style="border-width:0;" align="left" alt="WordPress Tips 2" />
Hope this makes blogging better! ![]()
Entry Filed under: Linux. .




Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed