russross/blackfriday — pull request #86 by dimfeld (2014-05-25 18:32:00+00:00)
Title: Add absolute link transformation and footnote enhancements

To accommodate the extra data needed by these features, I've added new function HtmlRendererWithParameters, which has an added argument of an HtmlRendererParameters structure. This allows API backwards and forwards compatibility as new things are added to this structure.

```go
type HtmlRendererParameters struct {
// Prepend this text to each URL, if the HTML_ABSOLUTE_LINKS option is enabled.
AbsolutePrefix string
// Add this text to ecah footnote anchor, to ensure uniqueness.
FootnoteAnchorPrefix string
// Show this text inside the tag for a footnote return link, if the
// HTML_FOOTNOTE_RETURN_LINKS flag is enabled. If blank, the string
// [return] is used.
FootnoteReturnLinkContents string
}

func HtmlRendererWithParameters(flags int, title string,
css string, renderParameters HtmlRendererParameters) Renderer {
...
}
```

## Absolute link transformation
When the renderer outputs an `a` or `img` tag, relative links have the given prefix added to them. `/abc/` becomes `http://localhost/abc`, for example. This is useful when rendering RSS feeds, for example, where the referenced links will no longer be accessible from their relative paths.

This option is enabled by setting the HTML_ABSOLUTE_LINKS flag and `HtmlRendererParameters.AbsolutePrefix`.

## Footnote Anchor Prefix
Add the given prefix to all generated `fn:` and `fnref:` anchors. Using a different prefix for each rendered document, this allows multiple rendered documents to combined into a single page without conflicting footnote anchors.

This is controlled by setting `HtmlRendererParameters.FootnoteAnchorPrefix` to the desired value.

## Footnote Return Link
Add a link at the end of a footnote to return to the original location. The default text is `[return]` but it can be customized by setting the `HtmlRendererParameters.FootnoteReturnLinkContents` variable. This behavior is enabled by the `HTML_FOOTNOTE_RETURN_LINKS` flag.