From e6ceb6880a8615ad5b8b6a88a0b1bfbd85f4033c Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Mon, 23 Dec 2019 16:38:50 -0600 Subject: Prefix all user-generated IDs in markup (#9477) * Prefix all user-generated IDs in markup * Add user-content- to IDs in unit-tests * fixup markdown_test.go * update the hrefs for the wiki test * Add blackfriday extension regex Signed-off-by: jolheiser --- modules/markup/markdown/markdown.go | 4 +++- modules/markup/markdown/markdown_test.go | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'modules/markup/markdown') diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go index fc704243e2..f1e44a8fbc 100644 --- a/modules/markup/markdown/markdown.go +++ b/modules/markup/markdown/markdown.go @@ -146,7 +146,9 @@ const ( func RenderRaw(body []byte, urlPrefix string, wikiMarkdown bool) []byte { renderer := &Renderer{ Renderer: blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{ - Flags: blackfridayHTMLFlags, + Flags: blackfridayHTMLFlags, + FootnoteAnchorPrefix: "user-content-", + HeadingIDPrefix: "user-content-", }), URLPrefix: urlPrefix, IsWiki: wikiMarkdown, diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index e80173c6cf..e3156a657b 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -116,11 +116,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
  • Plot var helper
  • `, - `

    What is Wine Staging?

    + `

    What is Wine Staging?

    Wine Staging on website wine-staging.com.

    - +

    Here are some links to the most important topics. You can find the full list of pages at the sidebar.

    @@ -149,11 +149,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string { images/2.png -

    More tests

    +

    More tests

    (from https://www.markdownguide.org/extended-syntax/)

    -

    Definition list

    +

    Definition list

    First Term
    @@ -163,18 +163,18 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
    This is another definition of the second term.
    -

    Footnotes

    +

    Footnotes

    -

    Here is a simple footnote,1 and here is a longer one.2

    +

    Here is a simple footnote,1 and here is a longer one.2


      -
    1. This is the first footnote.
    2. +
    3. This is the first footnote.
    4. -
    5. Here is one with multiple paragraphs and code.

      +
    6. Here is one with multiple paragraphs and code.

      Indent paragraphs to include them in the footnote.

      -- cgit v1.2.3