accounted for container logic
This commit is contained in:
parent
254405b384
commit
f6944a274b
|
|
@ -8,7 +8,7 @@ from collections import namedtuple
|
||||||
|
|
||||||
import rich
|
import rich
|
||||||
|
|
||||||
from bootstraparse.modules.error_mngr import CannotBeContainedError
|
from bootstraparse.modules.error_mngr import MismatchedContainerError
|
||||||
|
|
||||||
import pyparsing as pp
|
import pyparsing as pp
|
||||||
# import rich
|
# import rich
|
||||||
|
|
@ -80,7 +80,7 @@ class SemanticType:
|
||||||
CannotBeContainedError
|
CannotBeContainedError
|
||||||
Raises error if the token we were trying to encapsulate cannot be (probably mismatched).
|
Raises error if the token we were trying to encapsulate cannot be (probably mismatched).
|
||||||
"""
|
"""
|
||||||
raise CannotBeContainedError(self)
|
raise MismatchedContainerError(self)
|
||||||
|
|
||||||
|
|
||||||
class AddFirstElementToLabel(SemanticType):
|
class AddFirstElementToLabel(SemanticType):
|
||||||
|
|
@ -115,7 +115,15 @@ class FinalSemanticType(SemanticType):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class EncapsulatedSemanticType(SemanticType):
|
class OpenedSemanticType(SemanticType):
|
||||||
|
"""
|
||||||
|
Semantic type used to signify it has a matching end component and needs to be matched.
|
||||||
|
"""
|
||||||
|
def to_container(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
class ClosedSemanticType(SemanticType):
|
||||||
"""
|
"""
|
||||||
Semantic type used to signify it has a matching start component and needs to be matched.
|
Semantic type used to signify it has a matching start component and needs to be matched.
|
||||||
"""
|
"""
|
||||||
|
|
@ -195,7 +203,7 @@ class EtOlistToken(SemanticType):
|
||||||
label = "list:olist"
|
label = "list:olist"
|
||||||
|
|
||||||
|
|
||||||
class HeaderToken(SemanticType):
|
class HeaderToken(FinalSemanticType):
|
||||||
"""
|
"""
|
||||||
# string #
|
# string #
|
||||||
number of # indicates level
|
number of # indicates level
|
||||||
|
|
@ -203,7 +211,7 @@ class HeaderToken(SemanticType):
|
||||||
label = "header"
|
label = "header"
|
||||||
|
|
||||||
|
|
||||||
class DisplayToken(SemanticType):
|
class DisplayToken(FinalSemanticType):
|
||||||
"""
|
"""
|
||||||
! string !
|
! string !
|
||||||
number of ! indicates level
|
number of ! indicates level
|
||||||
|
|
@ -211,17 +219,18 @@ class DisplayToken(SemanticType):
|
||||||
label = "display"
|
label = "display"
|
||||||
|
|
||||||
|
|
||||||
class StructuralElementStartToken(AddFirstElementToLabel, SemanticType):
|
class StructuralElementStartToken(AddFirstElementToLabel, OpenedSemanticType):
|
||||||
"""<<string"""
|
"""<<string"""
|
||||||
label = 'se:start'
|
label = 'se:start'
|
||||||
|
|
||||||
|
|
||||||
class StructuralElementEndToken(AddFirstElementToLabel, EncapsulatedSemanticType):
|
class StructuralElementEndToken(AddFirstElementToLabel, ClosedSemanticType):
|
||||||
"""string>>"""
|
"""string>>"""
|
||||||
label = "se:end"
|
label = "se:end"
|
||||||
|
|
||||||
def counterpart(self): # noqa
|
def counterpart(self):
|
||||||
return "se:start"
|
return f"se:start:{self.content[0]}"
|
||||||
|
# TODO : correct this monstrosity
|
||||||
|
|
||||||
|
|
||||||
class HyperlinkToken(SemanticType):
|
class HyperlinkToken(SemanticType):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue