adjusted structural elements
This commit is contained in:
parent
c3adc16edc
commit
7079c27311
|
|
@ -82,8 +82,8 @@ class HeaderToken(SemanticType):
|
|||
label = "header"
|
||||
|
||||
|
||||
class IdentifierToken(SemanticType):
|
||||
label = "identifier"
|
||||
class StructuralElementToken(SemanticType):
|
||||
label = "structural element"
|
||||
|
||||
|
||||
class HyperlinkToken(SemanticType):
|
||||
|
|
@ -110,6 +110,10 @@ class TableSeparatorToken(SemanticType):
|
|||
label = "table:separator"
|
||||
|
||||
|
||||
class TableSeparatorToken(SemanticType):
|
||||
label = "table:separator"
|
||||
|
||||
|
||||
def of_type(token_class):
|
||||
"""
|
||||
Function creating a custom function for generating the given Token type.
|
||||
|
|
@ -176,6 +180,7 @@ image_element = ('@{' + pp.common.identifier('image_name') + '}')("image_element
|
|||
alias_element = ('@[' + pp.common.identifier('alias_name') + ']')("alias_element")
|
||||
expression = pp.Word(pp.alphanums + r'=+-_\'",;:!<> ')
|
||||
html_insert = '{' + expression('html_insert') + '}'
|
||||
structural_elements = (pp.Word('div') ^ pp.Word('article') ^ pp.Word('aside') ^ pp.Word('section'))('structural_element')
|
||||
|
||||
# Optional elements
|
||||
optional = (pp.Opt(html_insert)("html_insert") + pp.Opt(var)("var"))("optional")
|
||||
|
|
@ -192,16 +197,21 @@ optional = (pp.Opt(html_insert)("html_insert") + pp.Opt(var)("var"))("optional")
|
|||
# enhanced_text <<= (text | et_strong | et_em | et_underline | et_strikethrough | et_custom_span) + pp.Opt(enhanced_text)
|
||||
|
||||
# Multiline elements
|
||||
div_start = '~~' + text # TODO : It's not a text, rather a keyword and add ("name") and .add_parse_action(of_type(TextToken))
|
||||
div_end = text + '~~'
|
||||
se_start = '~~' + structural_elements
|
||||
se_end = text + '~~'
|
||||
|
||||
# Inline elements
|
||||
il_link = '[' + text + ']' + '(' + quotes + http_characters + pp.match_previous_literal(quotes) + ')' # Todo: change the quotes to quoted_string, get rid of text which was a placeholder
|
||||
il_link = '[' + text + ']' + '(' + quotes + http_characters + pp.match_previous_literal(quotes) + ')'
|
||||
# Todo: change the quotes to quoted_string and get rid of the text which was a placeholder
|
||||
|
||||
# Oneline elements
|
||||
one_header = ('#' + text + pps('#')).add_parse_action(of_type(HeaderToken)) # 1 per hX or copy paste six times? # TODO: add a header level to the token and get rid of the text which was a placeholder
|
||||
one_olist = pp.line_start + (pp.Word(pp.nums) ^ pp.Word('#')) + '.' + text # TODO: add a ("name") and add .add_parse_action(of_type(TextToken))
|
||||
one_ulist = pp.line_start + ('-' + text).add_parse_action(of_type(EtUlistToken)) # TODO: add a ("name") and add .add_parse_action(of_type(TextToken)) and get rid of the text which was a placeholder
|
||||
one_header = ('#' + text + pps('#')).add_parse_action(of_type(HeaderToken))
|
||||
# 1 per hX or copy paste six times?
|
||||
# TODO: add a header level to the token and get rid of the text which was a placeholder
|
||||
one_olist = pp.line_start + (pp.Word(pp.nums) ^ pp.Word('#')) + '.' + text
|
||||
# TODO: add a ("name") and add .add_parse_action(of_type(TextToken))
|
||||
one_ulist = pp.line_start + ('-' + text).add_parse_action(of_type(EtUlistToken))
|
||||
# TODO: add a ("name") and add .add_parse_action(of_type(TextToken)) and get rid of the text which was a placeholder
|
||||
|
||||
# Final elements
|
||||
enhanced_text = text # TODO: It's actually text or et_em or et_strong etc..., either recursive or repeated
|
||||
|
|
@ -221,8 +231,9 @@ line_to_replace = pp.OneOrMore(pp.SkipTo(image ^ alias)('text').add_parse_action
|
|||
alias.add_parse_action(of_type(AliasToken)))\
|
||||
^ pp.SkipTo(pp.lineEnd)('text').add_parse_action(of_type(TextToken))
|
||||
|
||||
###############################################################################
|
||||
##############################################################################
|
||||
# Temporary tests
|
||||
##############################################################################
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
pp.autoname_elements()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue