You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:59:40 UTC

[lucene] 27/50: SOLR-11539: use page shortnames as explicit anchors in generated pdf-main-body.adoc

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

dweiss pushed a commit to branch branch_7_1
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 2d8c34b316c3ec655e073daab812644c24a09d0b
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Tue Oct 24 11:57:20 2017 -0700

    SOLR-11539: use page shortnames as explicit anchors in generated pdf-main-body.adoc
    
    (cherry picked from commit ab388fa3a723ec59c80567c3c0448e16b985d20b)
---
 solr/solr-ref-guide/tools/BuildNavAndPDFBody.java | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java b/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
index 75638a9..b1f0cf3 100644
--- a/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
+++ b/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
@@ -103,7 +103,9 @@ public class BuildNavAndPDFBody {
             }
             previous.set(page);
 
-            
+            // use an explicit anchor, since the auto-generated ID from the "title" might not match
+            // the shortname/filename
+            w.append("[[").append(page.shortname).append("]]\n");
             // HACK: where this file actually lives will determine what we need here...
             w.write("include::../");
             w.write(page.file.getName());
@@ -223,6 +225,16 @@ public class BuildNavAndPDFBody {
       Map<String,Object> attrs = header.getAttributes();
       this.shortname = (String) attrs.get("page-shortname");
       this.permalink = (String) attrs.get("page-permalink");
+
+      // TODO: SOLR-11531: we should eliminate these attributes and not depend on them in jekyll, ...
+      // ...but for now at least be sure they are consistent with the filename
+      if (! file.getName().equals(shortname + ".adoc") ) {
+        throw new RuntimeException(file + " has a mismatched shortname: " + shortname);
+      }
+      if (! permalink.equals(shortname + ".html") ) {
+        throw new RuntimeException(file + " has a mismatched permalink: " + permalink);
+      }
+
       
       if (attrs.containsKey("page-children")) {
         String kidsString = ((String) attrs.get("page-children")).trim();