Include PRETTIFY_CSS_URL on repository index landing page when README is present RepositoryIndex.soy renders $readmeHtml when a root README.md exists, but only passed DOC_CSS_URL to common.header. Pass PRETTIFY_CSS_URL as well (matching PathDetail.soy and RevisionDetail.soy) so that fenced code blocks in README.md on the repository landing page render with syntax highlighting and theme variables. Change-Id: Ic7adc3a50e723d706135c275ea5e1efc6e525e83
diff --git a/javatests/com/google/gitiles/ThemeTest.java b/javatests/com/google/gitiles/ThemeTest.java index 2be83c4..7e91a65 100644 --- a/javatests/com/google/gitiles/ThemeTest.java +++ b/javatests/com/google/gitiles/ThemeTest.java
@@ -51,6 +51,23 @@ } @Test + public void repositoryIndexWithReadmeIncludesPrettifyCss() throws Exception { + repo.branch("master") + .commit() + .add("README.md", "# Hello Gitiles\n```python\nprint('hello')\n```") + .create(); + repo.getRepository().updateRef("HEAD").link("refs/heads/master"); + String html = buildHtml("/" + REPO_NAME + "/", false); + assertThat(html).contains("prettify/prettify.css"); + } + + @Test + public void repositoryIndexWithoutReadmeOmitsPrettifyCss() throws Exception { + String html = buildHtml("/" + REPO_NAME + "/", false); + assertThat(html).doesNotContain("prettify/prettify.css"); + } + + @Test public void docPageIncludesThemeScriptAndToggle() throws Exception { repo.branch("master").commit().add("README.md", "# Hello Gitiles\nDark mode test.").create(); String html = buildHtml("/" + REPO_NAME + "/+doc/master/README.md", false);
diff --git a/resources/com/google/gitiles/templates/RepositoryIndex.soy b/resources/com/google/gitiles/templates/RepositoryIndex.soy index f069055..af286f1 100644 --- a/resources/com/google/gitiles/templates/RepositoryIndex.soy +++ b/resources/com/google/gitiles/templates/RepositoryIndex.soy
@@ -41,7 +41,7 @@ {param menuEntries: $menuEntries /} {param customVariant: $customVariant /} {param breadcrumbs: $breadcrumbs /} - {param css: [$staticUrls['DOC_CSS_URL']] /} + {param css: [$staticUrls.DOC_CSS_URL, $staticUrls.PRETTIFY_CSS_URL] /} {/call} {else} {call common.header}