feat(attestation): list tags errors and substitute missing tag by libelle

This commit is contained in:
Colin Darie 2024-02-01 18:55:41 +01:00
parent 6f49dd892d
commit f7484eb0e5
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
16 changed files with 139 additions and 55 deletions

View file

@ -5,13 +5,14 @@ class TiptapService
children(node[:content], substitutions, 0)
end
def used_tags(node, tags = Set.new)
# NOTE: node must be deep symbolized keys
def used_tags_and_libelle_for(node, tags = Set.new)
case node
in type: 'mention', attrs: { id: }
tags << id
in { content: } if content.is_a?(Array)
content.each { used_tags(_1, tags) }
else
in type: 'mention', attrs: { id:, label: }, **rest
tags << [id, label]
in { content:, **rest } if content.is_a?(Array)
content.each { used_tags_and_libelle_for(_1, tags) }
in type:, **rest
# noop
end