Quantcast
Channel: the tar pit » patch
Viewing all articles
Browse latest Browse all 2

Update to Hemingway theme for textile

$
0
0

Now that I am uploading my blog directly, I actually needed textile installed. See Textile plugin for WordPress. However, the code didn’t look that good with my Hemingway skin. Here is the snippet from the css to make the code look better.

pre{
  width:95%;
  padding:1em 0;
  overflow:auto;
  color: #444444;
  font-family:'Bitstream Vera Sans Mono','Courier',monospace;
  font-size:105%;
  background-color:#F8F8F8;
  margin-top:0.3em;
  padding:1.2em 0.7em 1.7em 0.7em;
  border:1px solid #E9E9E9;
}

pre > p{
  width:95%;
  padding:1em 0;
  overflow:auto;
  color: #444444;
  font-family:'Bitstream Vera Sans Mono','Courier',monospace;
  font-size:105%;
  background-color:#F8F8F8;
  margin-top: -1.5em;
  margin-bottom: -1.5em;
  line-height: 1.2em;
}

Also I had to patch the code to get lists to work correctly. I went back to the original SVN code (however, I could not take the entire file so I just took the list code). Here it is (sorry it’s not a diff file):

// -------------------------------------------------------------
function lists($text)
{
  return preg_replace_callback("/^([#*]+$this->c .*)$(?![^#*])/smU", array(&$this, "fList"), $text);
}

// -------------------------------------------------------------
function fList($m)
{
  $text = preg_split('/\n(?=[*#])/m', $m[0]);
  foreach($text as $nr => $line) {
    $nextline = isset($text[$nr+1]) ? $text[$nr+1] : false;
    if (preg_match("/^([#*]+)($this->a$this->c) (.*)$/s", $line, $m)) {
      list(, $tl, $atts, $content) = $m;
      $nl = '';
      if (preg_match("/^([#*]+)\s.*/", $nextline, $nm))
        $nl = $nm[1];
      if (!isset($lists[$tl])) {
        $lists[$tl] = true;
        $atts = $this->pba($atts);
        $line = "\t<" . $this->lT($tl) . "l$atts>\n\t\t<li>" . rtrim($content);
      } else {
        $line = "\t\t<li>" . rtrim($content);
      }

      if(strlen($nl) <= strlen($tl)) $line .= "</li>";
      foreach(array_reverse($lists) as $k => $v) {
        if(strlen($k) > strlen($nl)) {
          $line .= "\n\t</" . $this->lT($k) . "l>";
          if(strlen($k) > 1)
            $line .= "</li>";
          unset($lists[$k]);
        }
      }
    }
    else {
      $line .= "\n";
    }
    $out[] = $line;
  }
  return $this->doTagBr('li', join("\n", $out));
}

Jobs still to be done on this code. I don’t think it deals with the <pre> tag correctly. It doesn’t escape HTML code and it inserts <p> and <br/> tags. I think that preformattted text should just be left alone! It maybe in the latest release that I have patched across. That’s another days work.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images