Add test for highlighting MathML by content identifier hash
Merge request reports
Activity
Filter activity
2 3 4 import com.formulasearchengine.mathmltools.helper.XMLHelper; 5 import javax.xml.xpath.XPathExpressionException; 6 import org.w3c.dom.Element; 7 import org.w3c.dom.Node; 8 9 public class CIdentifier implements Comparable<CIdentifier> { 10 private Element n; 11 12 public CIdentifier(Element n) { 13 this.n = n; 14 } 15 16 public String getName() { 17 return n.getTextContent(); 1 package com.formulasearchengine.mathmltools.mml; 2 3 4 import com.formulasearchengine.mathmltools.helper.XMLHelper; 5 import javax.xml.xpath.XPathExpressionException; 6 import org.w3c.dom.Element; 7 import org.w3c.dom.Node; 8 9 public class CIdentifier implements Comparable<CIdentifier> { 252 nodeList.forEach(n -> cIdentifiers.add(new CIdentifier((Element) n))); 253 } 254 return cIdentifiers; 255 } 256 245 257 public Document getDom() { 246 258 return dom; 247 259 } 248 260 261 /** 262 * Highlights consecutive occurrences of identifiers. 263 * 264 * @param hashes list of content identifier hashes to highlight 265 * @param backward if true the first identifier is searched from the end of the expression 266 */ 267 public void highlightConsecutiveIdentifiers(List<Integer> hashes, boolean backward) { 2 3 4 import com.formulasearchengine.mathmltools.helper.XMLHelper; 5 import javax.xml.xpath.XPathExpressionException; 6 import org.w3c.dom.Element; 7 import org.w3c.dom.Node; 8 9 public class CIdentifier implements Comparable<CIdentifier> { 10 private Element n; 11 12 public CIdentifier(Element n) { 13 this.n = n; 14 } 15 16 public String getName() { 17 return n.getTextContent(); not sure. Can you provide an example? I guess it's always a string for ci elements, cf. https://www.w3.org/TR/MathML3/chapter4.html#contm.ci
252 nodeList.forEach(n -> cIdentifiers.add(new CIdentifier((Element) n))); 253 } 254 return cIdentifiers; 255 } 256 245 257 public Document getDom() { 246 258 return dom; 247 259 } 248 260 261 /** 262 * Highlights consecutive occurrences of identifiers. 263 * 264 * @param hashes list of content identifier hashes to highlight 265 * @param backward if true the first identifier is searched from the end of the expression 266 */ 267 public void highlightConsecutiveIdentifiers(List<Integer> hashes, boolean backward) { 252 nodeList.forEach(n -> cIdentifiers.add(new CIdentifier((Element) n))); 253 } 254 return cIdentifiers; 255 } 256 245 257 public Document getDom() { 246 258 return dom; 247 259 } 248 260 261 /** 262 * Highlights consecutive occurrences of identifiers. 263 * 264 * @param hashes list of content identifier hashes to highlight 265 * @param backward if true the first identifier is searched from the end of the expression 266 */ 267 public void highlightConsecutiveIdentifiers(List<Integer> hashes, boolean backward) { 272 } 273 274 private void highlightRemainingIdentifiers(List<Integer> hashes, int pos) { 275 final List<CIdentifier> identifiers = getIdentifiers(); 276 for (Integer curHash : hashes) { 277 final CIdentifier curIdent = identifiers.get(pos + 1); 278 if (curHash == curIdent.hashCode()) { 279 highlightIdentifier(curIdent); 280 pos++; 281 } else { 282 return; 283 } 284 } 285 } 286 287 private int highlightFirstIdentifier(int hash, boolean backward) { Created by: codeclimate[bot]
Code Climate has analyzed commit 67c5b92d and detected 0 issues on this pull request.
View more on Code Climate.
Please register or sign in to reply