Fix for "Footnote titles not translatable #244" by davidlowryduda · Pull Request #247 · trentm/python-markdown2

added 7 commits

December 18, 2016 15:04
As noted in Issue trentm#234

  trentm#234

the metadata extra uses regex that is too greedy and can eat more than
what is intended if links appear in the markdown. This small change
corrects this.

Resolves: trentm#234
The previous commit towards resolving Issue trentm#234 didn't incorporate
previous behavior that fences shouldn't be necessary. First introduced
in Pull Request trentm#215, metadata should be accessible even without
including `---` fences around opening metadata.

This fix now preserves the ability to use either `---` fences (maybe
without a subsequent blank line) or no fences (but with a blank line).

Resolves: trentm#234
As noted in Issue trentm#244, it is not currently possible to customize the
text used in footnotes. It is always "Jump back to footnote <number> in
the text." It may be desirable to provide a programmable way to supply
different text, such as in different languages.

This provides that support when used from within the interpreter. Usage
is

    markdowner = markdown2.Markdown(extras=["footnotes"])
    markdowner.footnote_title = "Retournez vers footnote %d. "
    markdowner.convert(text)

This also adds the ability to change the footnote link text, through

    markdowner.footnote_link_text = "<something>"

because they are very similar.

Resolves: trentm#244

nicholasserra

nicholasserra

nicholasserra

@davidlowryduda

Users no longer need to include html closing tags in custom definitions
for footnote_title or footnote_link_text. And naked except Exception
statements have been replaced with the expected errors. These notes were
made by nicholasserra in Pull Request trentm#247

nicholasserra

@davidlowryduda

It is now possible to provide class variables to the Markdown instance
in the testing library by creating a file.customargs file containing a
dictionary.

For example, one might have have a footnotes_customtitle test, which
could be tested by making the following file.

footnotes_customtitle.customargs
---
{"footnote_title" : "Return to %d above"}
---

When testing footnote_customtitle, the Markdown instance will be passed
the variable, essentially like

```
markdowner = markdown2.Markdown(*opts)
markdowner.footnote_title = "Return to %d above"
text = markdowner.convert(html)
```

This was done to allow tests for trentm#247

@davidlowryduda

There is now a test for custom footnote_titles in the test suite.

Adds tests for: PR trentm#247
Resolves: trentm#244

@davidlowryduda

The behavior of custom footnote text is now implemented in the following
way, as recommended in trentm#247

```
markdown2.markdown(text, extras=["footnotes"],
                   footnote_title="Regresar a %d.")
```

This is in contrast to the previous implementation, which required an
intermediate step defining a class variable. As the interface changed,
it was necessary to rewrite the relevant test, which now defines the
customization in the footnotes_custom.opts file.