From 7ccbf0c5201354724d056ab7a7fdb9f9cf85a6c3 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 4 Feb 2014 10:02:10 -0600
Subject: [PATCH] html2text: Use [title][1] for footnote references

---
 include/html2text.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/html2text.php b/include/html2text.php
index c44997614..0e1186991 100644
--- a/include/html2text.php
+++ b/include/html2text.php
@@ -218,8 +218,9 @@ class HtmlInlineElement {
         }
         if ($this->footnotes) {
             $output .= "\n\n" . str_repeat('-', $width/2) . "\n";
+            $id = 1;
             foreach ($this->footnotes as $name=>$content)
-                $output .= "[$name] ".$content."\n";
+                $output .= sprintf("[%d] %s\n", $id++, $content);
         }
         return $output;
     }
@@ -277,6 +278,7 @@ class HtmlInlineElement {
 
     function addFootNote($name, $content) {
         $this->footnotes[$name] = $content;
+        return count($this->footnotes);
     }
 }
 
@@ -447,8 +449,8 @@ class HtmlAElement extends HtmlInlineElement {
             $output = (($href != $output) ? "$href " : '') . "<$output>";
         } elseif (mb_strwidth($href) > $width / 2) {
             if ($href != $output)
-                $this->getRoot()->addFootnote($output, $href);
-            $output = "[$output]";
+                $id = $this->getRoot()->addFootnote($output, $href);
+            $output = "[$output][$id]";
         } elseif ($href != $output) {
             $output = "[$output]($href)";
         }
-- 
GitLab