Commit graph

24 commits

Author SHA1 Message Date
Eric Holscher
04580aeb19
Merge pull request #166 from gibfahn/allow_overwriting_link_schemes
Add `accepted_url_schemes` option to allow toplevel refs
2019-08-09 11:18:54 -07:00
Gibson Fahnestock
0e96d97ef0
Add known_url_schemes option to allow toplevel refs
Fixes: https://github.com/readthedocs/recommonmark/issues/165
2019-07-29 11:40:21 +01:00
Raptor
357a732caf Process linebreaks and convert them to br element. 2019-06-30 13:44:30 +02:00
Eric Holscher
f748692b1d
Merge pull request #158 from gibfahn/fix_refs_with_spaces
Remove URL quoting from refs before passing to Sphinx
2019-06-14 07:08:35 -07:00
Gibson Fahnestock
ec0ada952d
Remove URL quoting from refs before passing to Sphinx
Sphinx allows refs with spaces etc, and in fact autogenerates them with
the command [`autosectionlabel`][].

So if you put a:

```markdown
[Link 1](<some ref>)
[Link 2](<https://foo.com/bar baz>)
```

Then the links will be `some%20ref` and `https://foo.com/bar%20baz`.

We want to keep the URL quoting for external references, but if we're
passing it as `:any:` to Sphinx we need to unquote so Sphinx can find
the correct reference, the `<some ref>` should map to:

```rst
:ref:`some ref`
```

[`autosectionlabel`](https://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html)

Fixes: https://github.com/rtfd/recommonmark/issues/155
2019-05-23 16:01:37 +02:00
Daniel Andersson
816fc608e6 Add test cases for quotes in alt texts 2019-04-07 00:16:58 +02:00
Daniel Andersson
059e95d6f3 Use image description text as "alt", drop title
The current RecommonMark specification on images [0] says that:

    ![foo](/url "title")

should render as

    <p><img src="/url" alt="foo" title="title" /></p>

which means that "foo" should be the `alt` attribute, and "title" should
be the `title` attribute.

Currently, `recommonmark` will:

1. set the `alt` attribute to "title"
2. render "foo" as literal text following the image element.

Neither yields results in line with the RecommonMark standard, resulting
in the following when transformed to HTML:

    <p><img src="/url" alt="title" />foo</p>

While it might be surprising that `alt` is set to "title", the more
pressing issue is how the alt text becomes literal text within the
paragraph, typically not rendering well.

This commit instead makes `recommonmark`:

1. set the `alt` attribute to "foo"
2. drop "title" altogether since the `title` attribute is not supported
   in Docutils [1].

1 coincides with the specification, and 2 is in my mind the least
surprising solution within the capabilities of Docutils. The HTML will
now be:

    <p><img src="/url" alt="foo" /></p>

only differing in the missing `title` attribute when compared to the
specification.

[0]: https://spec.commonmark.org/0.28/#images
[1]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#image
2019-04-06 12:56:27 +02:00
molpako
e53321e713 add a last line 2018-12-31 19:43:40 +09:00
molpako
34f3352135 add test 2018-12-31 19:38:28 +09:00
Anntoin Wilkinson
be55a6de90 Add visit_html_block
Without this any html_block nodes processed by the parser are dropped.
`visit_html_block` uses the existing logic for `visit_html_inline`.

Added a test case to check html_blocks are parsed as expected.

Fixes: https://github.com/rtfd/recommonmark/issues/121
2018-10-08 20:17:02 +01:00
Vasyl Fesik
a38bac33b7 rename CommonMark to commonmark in tests 2018-09-17 16:16:57 +03:00
djw
dd15581df1 Fix exception with link inside bold/italic
Return default line number of 0 when no sourcepos found.

Fixes #100
2018-05-07 17:24:07 +08:00
Kenneth Benzie (Benie)
7762ab3888 Fix hard error on cross-linking markdown document
Sphinx 1.6.5 with tip recommonmark hard errors when a markdown document
contains a cross-reference to another local markdown document as it
unconditionally access the `refdomain` of a `pending_xref`. This was
fixed [elsewhere](https://github.com/ignatenkobrain/sphinxcontrib-issuetracker/pull/13/files#diff-61beda6e59ec3020dbf0c2826dbb64c4R161)
by setting it to `None`. This patch uses the same approach which no
longer causes the Sphinx build to fail on cross-linking a markdown
document however the generated link is not correctly rendered producing
broken links in the generated html.

Addressing the broken links, the `mdnode.destination` is stripped of its
file extension if that extension is supported by `CommonMarkParser`
however this will only work for markdown documents, not ReStructuedText
or any other extended file type parsers.

Fixes #89.
2017-11-02 16:46:27 +00:00
Anthony Johnson
e62f4039ea
Add missing inline code parsing 2017-03-23 14:13:47 -07:00
Anthony Johnson
8baf238562
Fix linking, add tests, fix auto toc, deprecate and remove auto ref
This fixes link nesting, and resolves some issues around links not closing
correctly. There were a few changes required to support the autotoc feature, and
the auto ref feature has be deprecated. This feature no longer is required, as
we are doing pending_xref natively. The functionality was breaking Sphinx
altogether, so it doesn't make sense to keep it and deprecate the feature.
2017-03-03 01:20:23 -08:00
Anthony Johnson
1f7f525c7b
Port in pending_xref node changes to references
* Moves changes from #61 into this PR
* Drops basic testing from #61
* Adds to implementation pending_xref back down to reference

The implementation in #61 breaks a number of cases, like "/example" and
"example.html", etc. Instead of trying to enumerate case we want an xref instead
of a pending_xref, just pin the xref on the pending_xref to back down.
pending_xref replaces itself with it's children if the reference isn't resolved.
2017-03-02 20:04:30 -08:00
Anthony Johnson
fe8e00ab41
Update to support CommonMark >= 0.7.3 and clean up code
This was already dealing with a rewrite due to the spec change on CommonMark, so
I took the opportunity to modernize the code and clean things up as well.

* Updates to support CommonMark==0.7.3
* Reworks pattern for handling CommonMark nodes, mimic docutils visit/depart
  pattern
* Drops SectionHandler class, as it was only used in one place. Merge into the
  parser class, where it is used
* Drops requirements file for setup.py config, as this is a package requirements
  is superfluous
* Adds a number of more detailed test cases
* Adds test runner for 3.5, 3.6
* Updates strictness on prospector, cleans up linting errors and docstring
  problems
2017-03-02 20:04:30 -08:00
Eric Holscher
50be4978d7 Merge pull request #61 from pfultz2/pending-xref
Use pending_xref for links
2017-03-02 14:25:43 -08:00
Paul
6a22f6b04b Add test for header nested in a block 2016-10-27 01:17:06 -05:00
Paul
ad36e4990c Add support for external links 2016-06-14 01:16:46 -05:00
Paul
c9c58bcfc9 Use pending_xref for reference nodes 2016-06-13 23:14:35 -05:00
Paul
0ff83a9091 Add tests for checking custom file extensions 2016-06-12 03:12:15 -05:00
Paul
0eee19e600 Add tests for checking that pygments will still highlight the code. This requires a newer version sphinx as well. 2016-06-10 21:08:31 -05:00
Eric Holscher
3c2cd4930d Add initial stab at testing & Travis/Tox integration 2015-10-19 11:41:10 -07:00