diff --git delicious.inc delicious.inc
index 4c5f996..041ba4b 100644
--- delicious.inc
+++ delicious.inc
@@ -185,14 +185,24 @@ function _delicious_term_link(&$node) {
   }
 }
 
-//
-// smart-tagging support
-//
-function _delicious_tag_string($text, $tags, $username) {
-
-  if (!$tags) {
-    return $text;
-  }
+/**
+ * Core smart-tagging functionality.
+ *
+ * Scans given text for delicious tags and places links to delicious next to them.
+ * It can be optionally provided with a set of html tags to skip. e.g. <code>.
+ *
+ * @param $text string
+ *   Input text.
+ * @param $delicous_tags
+ *   Delicious tags to scan for.
+ * @param $username
+ *   Username to point the tags links to. e.g. delicious.com/<username>/tag
+ * @param $skip_tags
+ *   Array of html tags to exclude from scanning.
+ * @return
+ *   Text with links to given username's delicous tags.
+ */
+function _delicious_tag_string($text, $delicious_tags, $username, $skip_tags = array()) {
   // Match absolute URLs.
   $url_regex = '((http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://)([a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+*~#&=/;-]))';
   // Match e-mail addresses.
@@ -200,29 +210,32 @@ function _delicious_tag_string($text, $tags, $username) {
   // Match www domains/addresses.
   $www_regex = '(www\.[a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+~#\&=/;-])';
 
-  // Replace all URLs, Domains, and e-mail address with tokens.
+  // Skip given tags
+  if (!empty($skip_tags)) {
+    $skip_tags_regex = '(<('. implode('|', $skip_tags) .')[^>]*>.*?</\2>)';
+  }
+
+  // First preg_match: Replace all URLs, Domains, and e-mail address with tokens.
+  // Second preg_match: Replace all chunks of tags to skip with tokens.
   $replacements = array();
-  while (preg_match("`($url_regex|$mail_regex|$www_regex)`i", $text, $matches)) {
+  while ((!empty($skip_tags) && preg_match("`$skip_tags_regex`is", $text, $matches)) || preg_match("`($url_regex|$mail_regex|$www_regex)`i", $text, $matches)) {
     $token = '__delicious_processing_'. md5($matches[1]);
     $replacements[$token] = $matches[1];
     $text = str_replace($matches[1], $token, $text);
   } 
   // error, it must start with a tag... :-(
-  foreach ($tags as $tag) { 
-    if (!empty($tag) && $tag != ' ') {
-      $path = DELICIOUS_BASE_URL . urlencode($username) .'/'. urlencode($tag);
-      $modulepath = drupal_get_path('module', 'delicious');
-      $delicious_icon = theme('image', $modulepath .'/deliciousIcon.gif', '', t('Browse @username\'s delicious \'@tag\' tagged links', array('@username' => $username, '@tag' => $tag), '', array('class' => 'delicious-icon')));
-	  $delicious_link = l($delicious_icon, $path, array('html' => TRUE));
-	 
-
-      $tag = preg_quote($tag);
-      if (!preg_match('/<.+>/', $text)) {
-        $text = preg_replace('/(\b'. $tag .'\b)/i', '$1'. $delicious_link, $text);
-      }
-      else {
-        $text = preg_replace('/(?<=>)([^<]+)?(\b'. $tag .'\b)/i', '$1$2'. $delicious_link, $text);
-      }
+  foreach ($delicious_tags as $delicious_tag) {
+    $path = DELICIOUS_BASE_URL . urlencode($username) .'/'. urlencode($delicious_tag);
+    $modulepath = drupal_get_path('module', 'delicious');
+    $delicious_icon = theme('image', $modulepath .'/deliciousIcon.gif', '', t('Browse @username\'s delicious \'@tag\' tagged links', array('@username' => $username, '@tag' => $delicious_tag), '', array('class' => 'delicious-icon')));
+    $delicious_link = l($delicious_icon, $path, array('html' => TRUE));
+
+    $tag = preg_quote($tag);
+    if (!preg_match('/<.+>/', $text)) {
+      $text = preg_replace('/(\b'. $delicious_tag .'\b)/i', '$1'. $delicious_link, $text);
+    }
+    else {
+      $text = preg_replace('/(?<=>)([^<]+)?(\b'. $delicious_tag .'\b)/i', '$1$2'. $delicious_link, $text);
     }
   }
   // Restore all URLs, Domains, and e-mail addresses.
@@ -232,15 +245,31 @@ function _delicious_tag_string($text, $tags, $username) {
   return $text;
 }
 
-//
-// support function for tagged text
-//
+/**
+ * Adds links to delicious tags found in given text.
+ *
+ * @param $text
+ *   Input text.
+ * @param $name
+ *   Delicious username to use for building tag links URLs.
+ * @return
+ *   Text with links to given username's delicous tags.  
+ */
 function _delicious_tag_text($text, $name) {
   $result = db_query("SELECT distinct(name) FROM {delicious_tag}");
   while ($tag = db_fetch_object($result)) {
-    $tags[] = $tag->name;
+    if ($tag = trim($tag->name)) {
+      $tags[] = $tag;
+    }
+  }
+
+  if (empty($tags)) {
+    return $text;
   }
-  return _delicious_tag_string($text, $tags, $name);
+
+  $skip_tags = preg_split('/\s+|<|>/', variable_get('delicious_tagging_skip_tags', '<a> <pre> <code> <script>'), -1, PREG_SPLIT_NO_EMPTY);
+
+  return _delicious_tag_string($text, $tags, $name, $skip_tags);
 }
 
 //
diff --git delicious.module delicious.module
index 75ad0a7..a32f0e7 100644
--- delicious.module
+++ delicious.module
@@ -57,13 +57,6 @@ function delicious_admin_settings() {
     '#default_value' => variable_get("delicious_crosslink", 0),
     '#description' => t("Enable a link to a del.icio.us tag corresponding to the node's first term."),
   );
-  $form["delicious_tagging"] = array(
-    '#type' => 'checkbox',
-    '#title' => t("Enable del.icio.us \"smart tagging\""),
-    '#return_value' => 1,
-    '#default_value' => variable_get("delicious_tagging", 1),
-    '#description' => t("Words in node bodies matching del.icio.us tags will be linked to del.icio.us."),
-  );
   $form['delicious_node_types'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Node Types'),
@@ -71,6 +64,24 @@ function delicious_admin_settings() {
     '#options' => $node_types,
     '#description' => t('SELECT all node types that allow crosslinking and/or smarttagging.'),
   );
+  $form['delicious_tagging'] = array(
+    '#title' => t('Smart tagging'),
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+  );
+  $form['delicious_tagging']['delicious_tagging'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Enable del.icio.us \"smart tagging\""),
+    '#return_value' => 1,
+    '#default_value' => variable_get("delicious_tagging", 1),
+    '#description' => t("Words in node bodies matching del.icio.us tags will be linked to del.icio.us."),
+  );
+  $form['delicious_tagging']['delicious_tagging_skip_tags'] = array(
+    '#type' => 'textfield',
+    '#title' => t('HTML tags to skip'),
+    '#default_value' => variable_get('delicious_tagging_skip_tags', '<a> <pre> <code> <script>'),
+    '#description' => t('Space separated list of HTML tags that smart tagging should skip when matching delicious tags in nodes. Examples are tags which contain code or content that would be harmed if smart tagging links where inserted in between.'),
+  );
   return system_settings_form($form);
 }
 
@@ -185,12 +196,12 @@ function delicious_nodeapi(&$node, $op, $arg = 0) {
           $uname = db_result(db_query("SELECT user FROM {delicious_user} WHERE uid = %d", $node->uid));
         }
         if ($uname) {
-		  if (!empty($node->body)) {
-		    $node->body = _delicious_tag_text($node->body, $uname);
-		  }
-		  if (!empty($node->teaser)) {
-		    $node->teaser = _delicious_tag_text($node->teaser, $uname);
-		  }
+          if (!empty($node->body)) {
+            $node->body = _delicious_tag_text($node->body, $uname);
+          }
+          if (!empty($node->teaser)) {
+            $node->teaser = _delicious_tag_text($node->teaser, $uname);
+          }
         }
       }
     break;
