diff options
author | Tu Ton | 2017-05-30 11:43:19 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-06-27 13:36:02 +0000 |
commit | 8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4 (patch) | |
tree | 752e05564287027a454dc58844539377d638af88 | |
parent | 48a18b6ac01fa1888111f7add8edfc506672bec5 (diff) | |
download | eclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.tar.gz eclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.tar.xz eclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.zip |
Bug 517421 - [Help content] Using "Print selected topics and allI20170719-2000I20170719-0600I20170719-0040I20170718-2000I20170718-0355I20170717-2000I20170717-0350I20170716-2000I20170716-0130I20170715-2000I20170714-2000I20170713-2000I20170713-0615I20170712-2000I20170711-2000I20170710-2000I20170709-2000I20170708-2000I20170707-2000I20170707-0530I20170706-2000I20170706-0630I20170705-2000I20170704-2000I20170703-2000I20170702-2000I20170701-2000I20170630-2000I20170630-0410I20170629-2000I20170629-0425I20170629-0210I20170628-2000I20170628-0310I20170627-2000
subtopics" produces broken links
Change-Id: I732c772186c564cfcda419a4d959f5158267edf1
Signed-off-by: Tu Ton <minhtutonthat@gmail.com>
-rw-r--r-- | org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java index ff30e5050..b2ae71ff7 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -265,13 +265,18 @@ public class PrintData extends RequestData { private int generateToc(ITopic topic, String sectionId, int tocGenerated, Writer out) throws IOException { if (tocGenerated < allowedMaxTopics) { out.write("<div class=\"toc_" + (sectionId.length() > 2 ? "sub" : "") + "entry\">\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - out.write(sectionId + ". " + "<a href=\"#section" + sectionId + "\">" + topic.getLabel() + "</a>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + String hrefContent = sectionId + ". " + "<a href=\"#section" + sectionId + "\">" + topic.getLabel() + "</a>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ String href = topic.getHref(); if (href != null && href.length() > 0) { tocGenerated++; + //If the link points to an anchor, use the anchor ID instead of using the section ID + if (href.contains("#")) //$NON-NLS-1$ + hrefContent = sectionId + ". " + "<a href=\"" + getAnchor(href) + "\">" + topic.getLabel() + "</a>\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } + out.write(hrefContent); + ITopic[] subtopics = ScopeUtils.inScopeTopics(topic.getSubtopics(), scope); for (int i = 0; i < subtopics.length; ++i) { String subsectionId = sectionId + "." + (i + 1); //$NON-NLS-1$ @@ -493,6 +498,14 @@ public class PrintData extends RequestData { return href; } + private static String getAnchor(String href) { + int index = href.indexOf('#'); + if (index != -1) { + return href.substring(index, href.length()); + } + return ""; //$NON-NLS-1$ + } + private String getCssIncludes() { List<String> css = new ArrayList<>(); CssUtil.addCssFiles("topic_css", css); //$NON-NLS-1$ |