Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTu Ton2017-05-30 11:43:19 +0000
committerAlexander Kurtakov2017-06-27 13:36:02 +0000
commit8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4 (patch)
tree752e05564287027a454dc58844539377d638af88
parent48a18b6ac01fa1888111f7add8edfc506672bec5 (diff)
downloadeclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.tar.gz
eclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.tar.xz
eclipse.platform.ua-8e2fe1ac6f6539f86e99f5b936d68f2bac3a2da4.zip
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.java17
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$

Back to the top