# HG changeset patch # User Angel Ezquerra # Date 1360424901 -3600 # Node ID 52305554fd6e8f1dc281acacc3ef5941f62d89e3 # Parent 4e949b8e09307681d7b151d066bb385030e3084e hgweb: apply the websub filter to revision descriptions In order to use this, add a [websub] section to your configuration and add websub expressions such as: italic = s/\b_(\S+)_\b/\1<\/i>/ bold = s/\*\b(\S+)\b\*/\1<\/b>/ issues = s|issue(\d+)|issue\1|i bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!\1!i This also adds documentation (proofed by Kevin!) to the config help section. diff -r 4e949b8e0930 -r 52305554fd6e mercurial/help/config.txt --- a/mercurial/help/config.txt Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/help/config.txt Sat Feb 09 16:48:21 2013 +0100 @@ -1463,3 +1463,36 @@ ``templates`` Where to find the HTML templates. Default is install path. + +``websub`` +---------- + +Web substitution filter definition. You can use this section to +define a set of regular expression substitution patterns which +let you automatically modify the hgweb server output. + +The default hgweb templates only apply these substitution patterns +on the revision description fields. You can apply them anywhere +you want when you create your own templates by adding calls to the +"websub" filter (usually after calling the "escape" filter). + +This can be used, for example, to convert issue references to links +to your issue tracker, or to convert "markdown-like" syntax into +HTML (see the examples below). + +Each entry in this section names a substitution filter. +The value of each entry defines the substitution expression itself. +The websub expressions follow the old interhg extension syntax, +which in turn imitates the Unix sed replacement syntax:: + + pattername = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i] + +You can use any separator other than "/". The final "i" is optional +and indicates that the search must be case insensitive. + +Examples:: + + [websub] + issues = s|issue(\d+)|issue\1|i + italic = s/\b_(\S+)_\b/\1<\/i>/ + bold = s/\*\b(\S+)\b\*/\1<\/b>/ diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/gitweb/changelogentry.tmpl --- a/mercurial/templates/gitweb/changelogentry.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/changelogentry.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -8,7 +8,7 @@ {author|obfuscate} [{date|rfc822date}] rev {rev}
-{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty}

diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/gitweb/changeset.tmpl --- a/mercurial/templates/gitweb/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -41,7 +41,7 @@
-{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/gitweb/fileannotate.tmpl --- a/mercurial/templates/gitweb/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -56,7 +56,7 @@
-{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/gitweb/filerevision.tmpl --- a/mercurial/templates/gitweb/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -56,7 +56,7 @@
-{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/monoblue/changelogentry.tmpl --- a/mercurial/templates/monoblue/changelogentry.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/changelogentry.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -2,5 +2,5 @@
  • {date|rfc822date}
  • by {author|obfuscate} [{date|rfc822date}] rev {rev}
  • -
  • {desc|strip|escape|addbreaks|nonempty}
  • +
  • {desc|strip|escape|websub|addbreaks|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/monoblue/changeset.tmpl --- a/mercurial/templates/monoblue/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -52,7 +52,7 @@ {child%changesetchild} -

{desc|strip|escape|addbreaks|nonempty}

+

{desc|strip|escape|websub|addbreaks|nonempty}

{files} diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/monoblue/fileannotate.tmpl --- a/mercurial/templates/monoblue/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -57,7 +57,7 @@
{permissions|permissions}
-

{desc|strip|escape|addbreaks|nonempty}

+

{desc|strip|escape|websub|addbreaks|nonempty}

{annotate%annotateline} diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/monoblue/filerevision.tmpl --- a/mercurial/templates/monoblue/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -57,7 +57,7 @@
{permissions|permissions}
-

{desc|strip|escape|addbreaks|nonempty}

+

{desc|strip|escape|websub|addbreaks|nonempty}

{text%fileline} diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/paper/changeset.tmpl --- a/mercurial/templates/paper/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -40,7 +40,7 @@ files, or words in the commit message
-
{desc|strip|escape|nonempty}
+
{desc|strip|escape|websub|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/paper/fileannotate.tmpl --- a/mercurial/templates/paper/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -46,7 +46,7 @@ files, or words in the commit message -
{desc|strip|escape|nonempty}
+
{desc|strip|escape|websub|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/paper/filecomparison.tmpl --- a/mercurial/templates/paper/filecomparison.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filecomparison.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -45,7 +45,7 @@ files, or words in the commit message -
{desc|strip|escape|nonempty}
+
{desc|strip|escape|websub|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/paper/filediff.tmpl --- a/mercurial/templates/paper/filediff.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filediff.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -45,7 +45,7 @@ files, or words in the commit message -
{desc|strip|escape|nonempty}
+
{desc|strip|escape|websub|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/paper/filerevision.tmpl --- a/mercurial/templates/paper/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -44,7 +44,7 @@ files, or words in the commit message -
{desc|strip|escape|nonempty}
+
{desc|strip|escape|websub|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/spartan/changeset.tmpl --- a/mercurial/templates/spartan/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -39,7 +39,7 @@ - +
description:{desc|strip|escape|addbreaks|nonempty}{desc|strip|escape|websub|addbreaks|nonempty}
diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/spartan/fileannotate.tmpl --- a/mercurial/templates/spartan/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -38,7 +38,7 @@ description: - {desc|strip|escape|addbreaks|nonempty} + {desc|strip|escape|websub|addbreaks|nonempty} diff -r 4e949b8e0930 -r 52305554fd6e mercurial/templates/spartan/filerevision.tmpl --- a/mercurial/templates/spartan/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -36,7 +36,7 @@ {permissions|permissions} description: - {desc|strip|escape|addbreaks|nonempty} + {desc|strip|escape|websub|addbreaks|nonempty}