Skip to content
Snippets Groups Projects
Commit 7ccbf0c5 authored by Jared Hancock's avatar Jared Hancock
Browse files

html2text: Use [title][1] for footnote references

parent a7cdec44
No related branches found
No related tags found
No related merge requests found
...@@ -218,8 +218,9 @@ class HtmlInlineElement { ...@@ -218,8 +218,9 @@ class HtmlInlineElement {
} }
if ($this->footnotes) { if ($this->footnotes) {
$output .= "\n\n" . str_repeat('-', $width/2) . "\n"; $output .= "\n\n" . str_repeat('-', $width/2) . "\n";
$id = 1;
foreach ($this->footnotes as $name=>$content) foreach ($this->footnotes as $name=>$content)
$output .= "[$name] ".$content."\n"; $output .= sprintf("[%d] %s\n", $id++, $content);
} }
return $output; return $output;
} }
...@@ -277,6 +278,7 @@ class HtmlInlineElement { ...@@ -277,6 +278,7 @@ class HtmlInlineElement {
function addFootNote($name, $content) { function addFootNote($name, $content) {
$this->footnotes[$name] = $content; $this->footnotes[$name] = $content;
return count($this->footnotes);
} }
} }
...@@ -447,8 +449,8 @@ class HtmlAElement extends HtmlInlineElement { ...@@ -447,8 +449,8 @@ class HtmlAElement extends HtmlInlineElement {
$output = (($href != $output) ? "$href " : '') . "<$output>"; $output = (($href != $output) ? "$href " : '') . "<$output>";
} elseif (mb_strwidth($href) > $width / 2) { } elseif (mb_strwidth($href) > $width / 2) {
if ($href != $output) if ($href != $output)
$this->getRoot()->addFootnote($output, $href); $id = $this->getRoot()->addFootnote($output, $href);
$output = "[$output]"; $output = "[$output][$id]";
} elseif ($href != $output) { } elseif ($href != $output) {
$output = "[$output]($href)"; $output = "[$output]($href)";
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment