From 4e8239e87eac5495793bd449af62318dc006f9ca Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 17 Mar 2026 13:01:23 +0100 Subject: [PATCH] Simplify and clarify AUTODOC_PositionElementIfNotAfter --- gap/Parser.gi | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/gap/Parser.gi b/gap/Parser.gi index 6a110c28..aed753fe 100644 --- a/gap/Parser.gi +++ b/gap/Parser.gi @@ -167,28 +167,24 @@ InstallGlobalFunction( Scan_for_AutoDoc_Part, return AUTODOC_SplitCommandAndArgument( trimmed ); end ); -## Scans a string for after appeared. +## Scans a string for after appeared. ## This is necessary to scan the filter list for method declarations ## that contain \[\]. BindGlobal( "AUTODOC_PositionElementIfNotAfter", - function( list, element, element_not_before_element ) - local current_pos; - if not IsList( list ) then - Error( " must be a list" ); - fi; - if Length( list ) > 0 and list[ 1 ] = element then + function( str, char, not_before_char ) + local pos; + if Length( str ) > 0 and str[ 1 ] = char then return 1; fi; - for current_pos in [ 2 .. Length( list ) ] do - if list[ current_pos ] = element and list[ current_pos - 1 ] <> element_not_before_element then - return current_pos; + for pos in [ 2 .. Length( str ) ] do + if str[ pos ] = char and str[ pos - 1 ] <> not_before_char then + return pos; fi; od; return fail; end ); - ## InstallGlobalFunction( AutoDoc_Type_Of_Item, function( current_item, type, default_chapter_data )