Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute md links #628

Merged
merged 3 commits into from Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/about/release-notes.md
Expand Up @@ -70,16 +70,16 @@ This new file is created on every MkDocs build (with `mkdocs build`) and
no configuration is needed to enable it.

[future release]: https://github.com/mkdocs/mkdocs/pull/481
[site_dir]: /user-guide/configuration/#site_dir
[site_dir]: /user-guide/configuration.md#site_dir

#### Change the pages configuration

Provide a [new way] to define pages, and specifically [nested pages], in the
mkdocs.yml file and deprecate the existing approach, support will be removed
with MkDocs 1.0.

[new way]: /user-guide/writing-your-docs/#configure-pages-and-navigation
[nested pages]: /user-guide/writing-your-docs/#multilevel-documentation
[new way]: /user-guide/writing-your-docs.md#configure-pages-and-navigation
[nested pages]: /user-guide/writing-your-docs.md#multilevel-documentation

#### Warn users about the removal of builtin themes

Expand All @@ -98,7 +98,7 @@ JavaScript library [lunr.js]. It has been added to both the `mkdocs` and
for adding it to your own themes.

[lunr.js]: http://lunrjs.com/
[supporting search]: /user-guide/styling-your-docs/#search-and-themes
[supporting search]: /user-guide/styling-your-docs.md#search-and-themes

#### New Command Line Interface

Expand Down Expand Up @@ -126,10 +126,10 @@ can also use Jinja2 syntax and take advantage of the [global variables].
By default MkDocs will use this approach to create a sitemap for the
documentation.

[extra_javascript]: /user-guide/configuration/#extra_javascript
[extra_css]: /user-guide/configuration/#extra_css
[extra_templates]: /user-guide/configuration/#extra_templates
[global variables]: /user-guide/styling-your-docs/#global-context
[extra_javascript]: /user-guide/configuration.md#extra_javascript
[extra_css]: /user-guide/configuration.md#extra_css
[extra_templates]: /user-guide/configuration.md#extra_templates
[global variables]: /user-guide/styling-your-docs.md#global-context

### Other Changes and Additions

Expand All @@ -145,8 +145,8 @@ documentation.
* Bugfix: Fix linking to media within the same directory as a markdown file called index.md (#535)
* Bugfix: Fix errors with unicode filenames (#542).

[extra config]: /user-guide/configuration/#extra
[Markdown extension configuration options]: /user-guide/configuration/#markdown_extensions
[extra config]: /user-guide/configuration.md#extra
[Markdown extension configuration options]: /user-guide/configuration.md#markdown_extensions
[wheels]: http://pythonwheels.com/


Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Expand Up @@ -169,4 +169,4 @@ To get help with MkDocs, please use the [discussion group], [GitHub issues] or t
[GitHub project pages]: https://help.github.com/articles/creating-project-pages-manually
[pip]: http://pip.readthedocs.org/en/latest/installing.html
[Python]: https://www.python.org/
[Deploying your Docs]: user-guide/deploying-your-docs/
[Deploying your Docs]: user-guide/deploying-your-docs.md
6 changes: 3 additions & 3 deletions docs/user-guide/configuration.md
Expand Up @@ -105,7 +105,7 @@ This setting is used to determine the set of pages that should be built for the
- 'User Guide': 'user-guide.md'
- 'About': 'about.md'

See the section on [configuring pages and navigation](/user-guide/writing-your-docs/#configure-pages-and-navigation) for a more detailed breakdown, including how to create sub-sections.
See the section on [configuring pages and navigation](/user-guide/writing-your-docs.md#configure-pages-and-navigation) for a more detailed breakdown, including how to create sub-sections.

## Build directories

Expand Down Expand Up @@ -273,8 +273,8 @@ for that extension:

**default**: `[]`

[custom themes]: /user-guide/styling-your-docs/#custom-themes
[variables that are available]: /user-guide/styling-your-docs/#global-context
[custom themes]: /user-guide/styling-your-docs.md#custom-themes
[variables that are available]: /user-guide/styling-your-docs.md#global-context
[pymdk-extensions]: http://pythonhosted.org/Markdown/extensions/index.html
[pymkd]: http://pythonhosted.org/Markdown/
[smarty]: https://pythonhosted.org/Markdown/extensions/smarty.html
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/deploying-your-docs.md
Expand Up @@ -58,7 +58,7 @@ public repository.
[rtd]: https://readthedocs.org/
[instructions]: https://read-the-docs.readthedocs.org/en/latest/getting_started.html#in-markdown
[features]: http://read-the-docs.readthedocs.org/en/latest/features.html
[theme]: /user-guide/styling-your-docs/
[theme]: /user-guide/styling-your-docs.md

## PyPI

Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide/styling-your-docs.md
Expand Up @@ -12,9 +12,9 @@ To use a theme that is included in MkDocs, simply add this to your `mkdocs.yml`

Replace [`amelia`](#amelia) with any of the [builtin themes](#built-in-themes) listed below.

To customise a theme, simply place additional CSS and JavaScript files in the documentation directory next to the Markdown files and these will be automatically detected and added. Additionally, the [`extra_css`](/user-guide/configuration/#extra_css) and [`extra_javascript`](/user-guide/configuration/#extra_javascript) configuration options can be used to specifically include certain CSS or JavaScript files.
To customise a theme, simply place additional CSS and JavaScript files in the documentation directory next to the Markdown files and these will be automatically detected and added. Additionally, the [`extra_css`](/user-guide/configuration.md#extra_css) and [`extra_javascript`](/user-guide/configuration.md#extra_javascript) configuration options can be used to specifically include certain CSS or JavaScript files.

See the [configuration documentation](/user-guide/configuration/#theme) for more specific details about these options.
See the [configuration documentation](/user-guide/configuration.md#theme) for more specific details about these options.

To create a new custom theme or more heavily customise an existing theme, see the [custom themes](#custom-themes) section below.

Expand Down Expand Up @@ -123,7 +123,7 @@ Each template in a theme is built with a template context. These are the variabl

#### Global Context

The following variables in the context map directly the the [configuration options](/user-guide/configuration/).
The following variables in the context map directly the the [configuration options](/user-guide/configuration.md).

Variable Name | Configuration name
----------------- | ------------------- |
Expand Down Expand Up @@ -255,7 +255,7 @@ The page object for the next page.The isage is the same as for `current_page`.

#### Extra Context

Additional variables can be passed to the template with the [`extra`](/user-guide/configuration/#extra) configuration option. This is a set of key value pairs that can make custom templates far more flexible.
Additional variables can be passed to the template with the [`extra`](/user-guide/configuration.md#extra) configuration option. This is a set of key value pairs that can make custom templates far more flexible.

For example, this could be used to include the project version of all pages and a list of links related to the project. This can be achieved with the following `extra` configuration:

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/writing-your-docs.md
Expand Up @@ -6,7 +6,7 @@ How to write and layout your markdown source files.

## Configure Pages and Navigation

The [pages configuration](/user-guide/configuration/#pages) in your `mkdocs.yml` defines which pages are built by MkDocs and how they appear in the documentation navigation. If not provided, the pages configuration will be automatically created by discovering all the Markdown files in the [documentation directory](/user-guide/configuration/#docs_dir).
The [pages configuration](/user-guide/configuration.md#pages) in your `mkdocs.yml` defines which pages are built by MkDocs and how they appear in the documentation navigation. If not provided, the pages configuration will be automatically created by discovering all the Markdown files in the [documentation directory](/user-guide/configuration.md#docs_dir).

A simple pages configuration looks like this:

Expand Down
16 changes: 14 additions & 2 deletions mkdocs.yml
Expand Up @@ -4,10 +4,22 @@ site_description: Project documentation with Markdown.

repo_url: https://github.com/mkdocs/mkdocs/

pages:
- Home: index.md
- User Guide:
- Writing Your Docs: user-guide/writing-your-docs.md
- Styling Your Docs: user-guide/styling-your-docs.md
- Configuration: user-guide/configuration.md
- Deploying your docs: user-guide/deploying-your-docs.md
- About:
- Release Notes: about/release-notes.md
- Contributing: about/contributing.md
- License: about/license.md

markdown_extensions:
- toc:
permalink: ""
permalink:
- admonition:

copyright: Copyright &copy; 2014, <a href="https://twitter.com/_tomchristie">Tom Christie</a>. Maintenance and development by <a href="http://www.dougalmatthews.com/">Dougal Matthews</a>
copyright: Copyright &copy; 2014 <a href="https://twitter.com/_tomchristie">Tom Christie</a>, <a href="http://www.dougalmatthews.com/">Dougal Matthews</a>.
google_analytics: ['UA-27795084-5', 'mkdocs.org']
7 changes: 7 additions & 0 deletions mkdocs/relative_path_ext.py
Expand Up @@ -35,8 +35,11 @@
tutorial/intro.md | tutorial/intro/ | ../../img/initial-layout.png |

"""

from __future__ import unicode_literals

import logging
import os

from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor
Expand Down Expand Up @@ -68,6 +71,10 @@ def path_to_url(url, nav, strict):
# If the site navigation has been provided, then validate
# the internal hyperlink, making sure the target actually exists.
target_file = nav.file_context.make_absolute(path)

if target_file.startswith(os.path.sep):
target_file = target_file[1:]

if target_file not in nav.source_files:
source_file = nav.file_context.current_file
msg = (
Expand Down
11 changes: 11 additions & 0 deletions mkdocs/tests/build_tests.py
Expand Up @@ -342,6 +342,17 @@ def test_strict_mode_invalid(self):
MarkdownNotFound,
build.convert_markdown, invalid, load_config({'strict': True}), site_nav)

def test_absolute_link(self):
pages = [
'index.md',
'sub/index.md',
]
site_nav = nav.SiteNavigation(pages)

markdown = "[test 1](/index.md) [test 2](/sub/index.md)"
cfg = load_config({'strict': True})
build.convert_markdown(markdown, cfg, site_nav)

def test_extension_config(self):
"""
Test that a dictionary of 'markdown_extensions' is recognized as
Expand Down