SOLR-11539: use page shortnames as explicit anchors in generated pdf-main-body.adoc

This commit is contained in:
Chris Hostetter 2017-10-24 11:57:20 -07:00
parent ea36f5040c
commit ab388fa3a7
1 changed files with 13 additions and 1 deletions

View File

@ -103,7 +103,9 @@ public class BuildNavAndPDFBody {
} }
previous.set(page); 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... // HACK: where this file actually lives will determine what we need here...
w.write("include::../"); w.write("include::../");
w.write(page.file.getName()); w.write(page.file.getName());
@ -224,6 +226,16 @@ public class BuildNavAndPDFBody {
this.shortname = (String) attrs.get("page-shortname"); this.shortname = (String) attrs.get("page-shortname");
this.permalink = (String) attrs.get("page-permalink"); 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")) { if (attrs.containsKey("page-children")) {
String kidsString = ((String) attrs.get("page-children")).trim(); String kidsString = ((String) attrs.get("page-children")).trim();
this.kidShortnames = Collections.<String>unmodifiableList this.kidShortnames = Collections.<String>unmodifiableList