Skip to content

Commit

Permalink
refactor(parser): simplify InlineWord vs Word rules (#1080)
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Sep 4, 2022
1 parent eecd0bb commit 4d151e0
Show file tree
Hide file tree
Showing 4 changed files with 8,537 additions and 8,525 deletions.
11 changes: 6 additions & 5 deletions pkg/parser/document_processing_apply_substitutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,18 @@ func reparseAttributes(ctx *ParseContext, element types.WithAttributes, opts ...
for k, v := range attrs {
switch k {
case types.AttrTitle, types.AttrXRefLabel:
v, err := parseWithSubstitutions(v, attributeSubstitutions(), append(append(ctx.opts, Entrypoint("AttributeStructuredValue")), opts...)...)
subs := attributeSubstitutions()
// same as above, but do not allow for inline macros (eg: links)
if err := subs.append(Macros); err != nil {
return err
}
v, err := parseWithSubstitutions(v, subs, append(append(ctx.opts, Entrypoint("AttributeStructuredValue")), opts...)...)
if err != nil {
return err
}
attrs[k] = types.Reduce(v)
case types.AttrInlineLinkText:
subs := attributeSubstitutions()
// same as above, but do not allow for inline macros (eg: links)
if err := subs.remove(Macros); err != nil {
return err
}
v, err := parseWithSubstitutions(v, subs, append(append(ctx.opts, Entrypoint("AttributeStructuredValue")), opts...)...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/parser/document_substitutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func attributeSubstitutions() *substitutions {
AttributeRefs,
SpecialCharacters,
Quotes,
Macros,
// Macros,
Replacements,
},
}
Expand Down
Loading

0 comments on commit 4d151e0

Please sign in to comment.