From 19e185f2516a1fbb754dce23829b563425769b12 Mon Sep 17 00:00:00 2001 From: vicky Date: Fri, 27 May 2022 17:01:24 +0200 Subject: [PATCH] added AddFirstElementToLabel class for structural element tokens --- src/bootstraparse/modules/syntax.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bootstraparse/modules/syntax.py b/src/bootstraparse/modules/syntax.py index ce02861..47d4110 100644 --- a/src/bootstraparse/modules/syntax.py +++ b/src/bootstraparse/modules/syntax.py @@ -5,6 +5,9 @@ import os from itertools import zip_longest from collections import namedtuple + +import rich + from bootstraparse.modules.error_mngr import CannotBeContainedError import pyparsing as pp @@ -80,6 +83,12 @@ class SemanticType: raise CannotBeContainedError(self) +class AddFirstElementToLabel(SemanticType): + def __init__(self, content): + super().__init__(content) + self.label += ":" + content[0] + + class ExplicitSemanticType(SemanticType): """ Explicit semantic type, the label is the only information we need. @@ -202,12 +211,12 @@ class DisplayToken(SemanticType): label = "display" -class StructuralElementStartToken(SemanticType): +class StructuralElementStartToken(AddFirstElementToLabel, SemanticType): """<>""" label = "se:end"