From 5fe5e2239519c89d2f566aff01e40a2e71715c30 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 16:00:15 +0100 Subject: [PATCH] doc: Support any link having a fragment except http(s) links for linking between headings --- modules/doc/doc/1-module-documentation.md | 8 ++++++++ modules/doc/library/Doc/SectionRenderer.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/doc/doc/1-module-documentation.md b/modules/doc/doc/1-module-documentation.md index 968dd32d7..edf20aac2 100644 --- a/modules/doc/doc/1-module-documentation.md +++ b/modules/doc/doc/1-module-documentation.md @@ -36,10 +36,18 @@ For linking between headings, place an anchor where you want to link to, e.g.: # Heading +Please note that anchors have to be unique across all your Markdown documentation files. + Now you can reference the anchor either in the same or **in another** Markdown documentation file, e.g.: This is a link to [Heading](#heading). +Other tools support linking between headings by giving the filename plus the anchor to link to, e.g.: + + This is a link to [About/Heading](1-about.md#heading.md) + +This syntax is also supported in Icinga Web 2. + ## Including Images Images must placed in the `img` directory beneath your module's `public` directory, e.g.: diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index 2fdaf8e90..f923783f6 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -232,7 +232,7 @@ class SectionRenderer extends Renderer $html ); $content[] = preg_replace_callback( - '/[^>]*?\s+)?href="#(?P[^"]+)"/', + '/[^>]*?\s+)?href="(?:(?!http:\/\/)[^#]*)#(?P[^"]+)"/', array($callback, 'render'), $html );