Skip to content
Snippets Groups Projects

Add test for highlighting MathML by content identifier hash

Merged Moritz Aurel Pascal Schubotz requested to merge highlight into master

Merge request reports

Merged by avatar (Jan 13, 2025 5:48am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
242 243 return cSymbols;
243 244 }
244 245
246 public List<CIdentifier> getIdentifiers() {
  • Moritz Aurel Pascal Schubotz
  • Moritz Aurel Pascal Schubotz
  • 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> {
  • Moritz Aurel Pascal Schubotz
  • Moritz Aurel Pascal Schubotz
  • Moritz Aurel Pascal Schubotz
  • 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();
  • 242 243 return cSymbols;
    243 244 }
    244 245
    246 public List<CIdentifier> getIdentifiers() {
  • 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
    Loading