source: pvrrd/makeTagHTML.php @ 195

Last change on this file since 195 was 195, checked in by jemian, 13 years ago

initial checkin -- need to refactor libxml2 to ElementTree?

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision Url Id
File size: 1.1 KB
Line 
1<?php
2
3//  purpose: formats an HTML (xml-compatible) tag (element).
4
5/*
6########### SVN repository information ###################
7# $Date: 2010-08-02 18:49:17 +0000 (Mon, 02 Aug 2010) $
8# $Author: jemian $
9# $Revision: 195 $
10# $HeadURL$
11# $Id: makeTagHTML.php 195 2010-08-02 18:49:17Z jemian $
12########### SVN repository information ###################
13*/
14
15  //-------------------------------------------------------------
16   
17function makeTagHTML ($fullTag, $content = '', $indent = 1) {
18    $parts = explode (" ", $fullTag);
19    $shortTag = $parts[0];
20    $tag = "<" . $fullTag . ">";
21    if (strlen($content)) {
22      if ($indent) {
23        $tag = $tag . "\n";
24        $indentation = "  ";
25        foreach (explode ("\n", $content) as $line) {
26          // indent each line of the content
27          if (strlen($line)) {
28            // printf ("%5d: <%s>\n", strlen($line), $line);
29            $tag = $tag . $indentation . $line . "\n";
30          }
31        }
32        $tag = $tag . "</" . $shortTag . ">";
33      } else {
34        $tag = $tag . $content . "</" . $shortTag . ">";
35      }
36    } else {
37      // short-form tag
38      $tag = "<" . $fullTag . " />";
39    }
40    return ($tag . "\n");
41  }
Note: See TracBrowser for help on using the repository browser.