You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/11/19 22:27:21 UTC

[commons-skin] 06/16: Optionally render
 tags using
 prettyprint.

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-skin.git

commit 95922782be8cfb60d9b45dab307c2e548e9b95c9
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Mon Nov 18 21:30:05 2019 +0000

    Optionally render <pre> tags using prettyprint.
---
 src/main/resources/META-INF/maven/site.vm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm
index b87c4d6..6356ca8 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -548,7 +548,20 @@ $StringUtils.replace( $text, '$relativePath', $relativePath )##
             </div>
           </td>
           <td class="content">
-            $bodyContent
+            ## Adpated from fluido-skin-1.8:
+            ## Custom properties to opt-in to prettyprint for "source" <pre> tags.
+            ## The regex targets a plain <pre> tag rendered by the site plugin as:
+            ## <div class="source"><pre>
+            #if ( 'true' == $decoration.getCustomValue( 'commonsSkin.prettyPrintSourcePreTags' ) )
+              #if ( 'true' == $decoration.getCustomValue( 'commonsSkin.sourceLineNumbersEnabled' ) )
+                #set ( $sourceStyle = "prettyprint linenums" )
+              #else
+                #set ( $sourceStyle = "prettyprint" )
+              #end
+              $bodyContent.replaceAll( "<div class=${esc.q}source${esc.q}>(\r?\n)?<pre>", "<div class=${esc.q}source${esc.q}><pre class=${esc.q}$sourceStyle${esc.q}>" )
+            #else
+              $bodyContent
+            #end
           </td>
         </tr>
       </table>