From f186ca160186a309bb0e3e7e2420c7ffd088e549 Mon Sep 17 00:00:00 2001 From: RoiArthurB Date: Fri, 14 Oct 2022 13:54:21 +0700 Subject: [PATCH 1/4] [PRISM] Swizzle prism language selector --- website/src/theme/prism-include-languages.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 website/src/theme/prism-include-languages.js diff --git a/website/src/theme/prism-include-languages.js b/website/src/theme/prism-include-languages.js new file mode 100644 index 0000000000..55086d3100 --- /dev/null +++ b/website/src/theme/prism-include-languages.js @@ -0,0 +1,19 @@ +import siteConfig from '@generated/docusaurus.config'; +export default function prismIncludeLanguages(PrismObject) { + const { + themeConfig: {prism}, + } = siteConfig; + const {additionalLanguages} = prism; + // Prism components work on the Prism instance on the window, while prism- + // react-renderer uses its own Prism instance. We temporarily mount the + // instance onto window, import components to enhance it, then remove it to + // avoid polluting global namespace. + // You can mutate PrismObject: registering plugins, deleting languages... As + // long as you don't re-assign it + globalThis.Prism = PrismObject; + additionalLanguages.forEach((lang) => { + // eslint-disable-next-line global-require, import/no-dynamic-require + require(`prismjs/components/prism-${lang}`); + }); + delete globalThis.Prism; +} From 929ed41c2cf696c58660e9836ca9d2816955413d Mon Sep 17 00:00:00 2001 From: RoiArthurB Date: Fri, 14 Oct 2022 13:55:19 +0700 Subject: [PATCH 2/4] [PRISM] Add Prism's GAML syntax in website Source syntax from @benoitgaudou in issue #49 --- website/docusaurus.config.js | 2 +- website/src/theme/prism-gaml.js | 25 ++++++++++++++++++++ website/src/theme/prism-include-languages.js | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 website/src/theme/prism-gaml.js diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index f0d8b9180a..aebf630053 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -92,7 +92,7 @@ module.exports={ }, "prism": { additionalLanguages: ['java','javascript','python'], - defaultLanguage: 'java', + defaultLanguage: 'gaml', }, algolia: { appId: 'MWUOLTL2EG', diff --git a/website/src/theme/prism-gaml.js b/website/src/theme/prism-gaml.js new file mode 100644 index 0000000000..9753b61db4 --- /dev/null +++ b/website/src/theme/prism-gaml.js @@ -0,0 +1,25 @@ +Prism.languages.gaml = { + 'comment': [ + { pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, + { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], + 'string': + { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, + 'number': [ + { + pattern: /\b\d(?:_?\d)*#[\dA-F](?:_?[\dA-F])*(?:\.[\dA-F](?:_?[\dA-F])*)?#(?:E[+-]?\d(?:_?\d)*)?/i + }, + { + pattern: /\b\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:E[+-]?\d(?:_?\d)*)?\b/i + } + ], + 'attribute': { + pattern: /\b'\w+/, + alias: 'attr-name' + }, + 'keyword': /\b(?:species|global|grid|model|import|output|action|add|agents|annealing|ask|aspect|assert|break|camera|capture|chart|conscious_contagion|create|data|datalist|default|diffuse|display|display_grid|display_population|do|draw|else|emotional_contagion|enter|equation|error|event|exhaustive|exit|experiment|export|focus|focus_on|genetic|graphics|highlight|hill_climbing|if|image|inspect|layout_forceatlas2|layout_yifanhu|let|light|loop|match|migrate|monitor|output|output_file|overlay|parameter|pause_sound|perceive|permanent|plan|put|reactive_tabu|reflex|release|remove|resume_sound|return|rule|run|save|save_batch|set|setup|simulate|solve|species|start_sound|state|status|stop_sound|switch|tabu|task|test|trace|transition|unconscious_contagion|user_command|user_init|user_input|user_panel|using|Variable_container|Variable_number|Variable_regular|warn|write|init)\b/i, + 'boolean': /\b(?:false|true)\b/i, + 'operator': /<[=>]?|>=?|=>?|:=|\/=?|\*\*?|[&+-]/, + 'punctuation': /\.\.?|[,;():]/, + 'char': /'.'/, + 'variable': /\b[a-z](?:\w)*\b/i +}; diff --git a/website/src/theme/prism-include-languages.js b/website/src/theme/prism-include-languages.js index 55086d3100..e2e0ebb822 100644 --- a/website/src/theme/prism-include-languages.js +++ b/website/src/theme/prism-include-languages.js @@ -15,5 +15,8 @@ export default function prismIncludeLanguages(PrismObject) { // eslint-disable-next-line global-require, import/no-dynamic-require require(`prismjs/components/prism-${lang}`); }); + + require('./prism-gaml'); + delete globalThis.Prism; } From c2266ea0e8d2ce422ba98fd888691ac0e924e8d8 Mon Sep 17 00:00:00 2001 From: benoitgaudou Date: Sat, 15 Oct 2022 17:08:35 +0200 Subject: [PATCH 3/4] Update prism JS file for GAML --- website/src/theme/prism-gaml.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/website/src/theme/prism-gaml.js b/website/src/theme/prism-gaml.js index 9753b61db4..a81e360a2e 100644 --- a/website/src/theme/prism-gaml.js +++ b/website/src/theme/prism-gaml.js @@ -1,3 +1,4 @@ + Prism.languages.gaml = { 'comment': [ { pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, @@ -10,16 +11,16 @@ Prism.languages.gaml = { }, { pattern: /\b\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:E[+-]?\d(?:_?\d)*)?\b/i - } - ], - 'attribute': { - pattern: /\b'\w+/, - alias: 'attr-name' - }, - 'keyword': /\b(?:species|global|grid|model|import|output|action|add|agents|annealing|ask|aspect|assert|break|camera|capture|chart|conscious_contagion|create|data|datalist|default|diffuse|display|display_grid|display_population|do|draw|else|emotional_contagion|enter|equation|error|event|exhaustive|exit|experiment|export|focus|focus_on|genetic|graphics|highlight|hill_climbing|if|image|inspect|layout_forceatlas2|layout_yifanhu|let|light|loop|match|migrate|monitor|output|output_file|overlay|parameter|pause_sound|perceive|permanent|plan|put|reactive_tabu|reflex|release|remove|resume_sound|return|rule|run|save|save_batch|set|setup|simulate|solve|species|start_sound|state|status|stop_sound|switch|tabu|task|test|trace|transition|unconscious_contagion|user_command|user_init|user_input|user_panel|using|Variable_container|Variable_number|Variable_regular|warn|write|init)\b/i, + }], + 'type_statement': /\b(?:string\s\s|action\s|agent\s|attributes\s|BDIPlan\s|bool\s|container\s|conversation\s|date\s|directory\s|emotion\s|field\s|file\s|float\s|font\s|gaml_type\s|gen_population_generator\s|gen_range\s|geometry\s|graph\s|int\s|kml\s|list\s|map\s|material\s|matrix\s|mental_state\s|message\s|Norm\s|pair\s|path\s|point\s|predicate\s|regression\s|rgb\s|Sanction\s|skill\s|social_link\s|species\s|string\s|topology\s|unknown)(?!(\(|\_))/i, 'boolean': /\b(?:false|true)\b/i, - 'operator': /<[=>]?|>=?|=>?|:=|\/=?|\*\*?|[&+-]/, + 'statement': /\b(?:model|import|=|abort|action|add|agents|annealing|ask|aspect|assert|benchmark|betad|break|browse|camera|capture|catch|chart|conscious_contagion|continue|coping|create|data|datalist|default|diffuse|diffusion|display|display_grid|display_population|do|draw|else|emotional_contagion|enforcement|enter|equation|error|event|exit|experiment|exploration|focus|focus_on|generate|genetic|global|graphics|grid|highlight|hill_climbing|if|image|init|inspect|invoke|law|layout|let|light|loop|match|match_between|match_one|match_regex|mesh|migrate|monitor|morris|norm|output|output_file|overlay|parameter|perceive|permanent|plan|pso|put|reactive_tabu|reflex|release|remove|return|rotation|rule|rule|run|sanction|save|set|setup|simulate|sobol|socialize|solve|species|start_simulation|state|status|stochanalyse|switch|tabu|task|test|text|trace|transition|try|unconscious_contagion|user_command|user_init|user_input|user_panel|using|Variable_container|Variable_number|Variable_regular|warn|write)\b/i, + 'facet': /\b(?:name|name|name|iter_max|init_solution|maximize|minimize|aggregation|value|rotate|trace|selectable|fading|position|size|transparency|visible|name|aspect|refresh|rounded|border|position|size|transparency|left|visible|right|center|background|color|initial|name|color|message|position|background|border|rotate|trace|fading|size|transparency|visible|name|refresh|name|value|name|iter_max|num_particles|weight_inertia|weight_cognitive|weight_social|maximize|minimize|aggregation|position|rotate|no_data|scale|size|transparency|visible|border|wireframe|smooth|source|texture|grayscale|color|triangulation|text|refresh|value|editors|toolbars|controls|parameters|navigator|consoles|tray|background|tabs|initial|name|action|with|internal_function|x_range|y_range|y2_range|position|size|reverse_axes|background|x_serie|x_serie_labels|y_serie_labels|x_log_scale|y_log_scale|y2_log_scale|axes|x_tick_values_visible|y_tick_values_visible|title_visible|x_tick_line_visible|y_tick_line_visible|tick_line_color|type|style|gap|y_tick_unit|y2_tick_unit|x_tick_unit|name|x_label|y_label|y2_label|color|series_label_position|label_background_color|label_text_color|memorize|tick_font|label_font|transparency|visible|legend_font|title_font|from|to|step|name|over|while|times|name|type|init|<-|update|function|->|const|category|parameter|on_change|min|max|step|among|species|returns|from|number|as|with|source|target|returns|value|legend|use_second_y_axis|y_err_values|x_err_values|y_minmax_values|marker_size|color|accumulate_values|line_visible|marker|marker_shape|fill|thickness|style|name|location|type|direction|angle|linear_attenuation|quadratic_attenuation|active|intensity|show|dynamic|position|rotate|selectable|size|transparency|trace|fading|visible|species|aspect|refresh|name|iter_max|init_solution|tabu_list_size|maximize|minimize|aggregation|name|title|benchmark|parent|skills|control|frequency|schedules|keep_seed|keep_simulations|repeat|until|parallel|type|virtual|autorun|topology|name|sample|levels|outputs|report|csv|results|value|to|item|at|all|parallel|target|as|name|temp_end|init_solution|temp_decrease|temp_init|nb_iter_cst_temp|maximize|minimize|aggregation|value|name|sampling|outputs|sample|results|levels|threshold|name|color|refresh|value|name|data|refresh|header|footer|rewrite|type|value|warning|target|as|in|returns|color|value|value|weight|name|name|type|of|index|virtual|geometry|texture|wireframe|border|at|anchor|size|color|rotate|font|depth|precision|begin_arrow|end_arrow|lighted|perspective|material|width|item|from|index|key|all|when|name|name|dynamic|distance|location|target|lens|locked|name|type|init|min|slider|max|returns|among|message|name|type|init|<-|update|function|->|const|category|parameter|on_change|of|index|name|type|init|min|max|category|var|unit|on_change|enables|disables|updates|in_workspace|extensions|slider|colors|labels|step|read_only|among|at|key|all|item|in|position|rotate|selectable|size|transparency|species|visible|border|elevation|texture|smooth|grayscale|triangulation|hexagonal|text|wireframe|refresh|name|type|of|index|init|<-|update|on_change|function|->|const|category|parameter|among|type|data|rewrite|header|to|crs|attributes|condition|name|sample|outputs|results|report|path|message|synchronized|parallel|width|height|cell_width|cell_height|neighbors|horizontal_orientation|use_individual_shapes|use_regular_agents|optimizer|use_neighbors_cache|file|files|torus|name|parent|edge_species|skills|mirrors|control|compile|frequency|schedules|topology|virtual|color|background|font|category|message|color|message|name|iter_max|init_solution|tabu_list_size_init|tabu_list_size_max|tabu_list_size_min|nb_tests_wthout_col_max|cycle_size_max|cycle_size_min|maximize|minimize|aggregation|dynamic|location|axis|angle|name|value|of|index|type|unused|name|type|action|value|y_err_values|x_err_values|use_second_y_axis|y_minmax_values|marker_size|legend|marker|marker_shape|accumulate_values|line_visible|fill|color|thickness|style|virtual|parent|background|name|type|antialias|refresh|toolbar|fullscreen|show_fps|axes|orthographic_projection|light|camera|keystone|z_near|z_far|autosave|name|name|refresh|value|attributes|type|target|as|returns|file|rotate|position|size|transparency|visible|name|gis|color|refresh|value|message|repeat|when|to|name|sampling|outputs|sample|results|report|initial|final|name|name|pop_dim|crossover_prob|mutation_prob|nb_prelim_gen|max_gen|improve_sol|stochastic_sel|maximize|minimize|aggregation|when|priority|name|value|continue|color|category|action|name|when|with|name|sampling|from|with|sample|levels|iterations|synchronized|autosave|comodel|with_experiment|share|with_input|with_output|reset|until|repeat|equation|method|t0|tf|step|step_size|min_step|max_step|scalAbsoluteTolerance|scalRelativeTolerance|nSteps|var|on|matrix|method|min|mask|proportion|propagation|radius|variation|cycle_length|avoid_mask|left|right|name|vars|params|simultaneously|of|name|seed|with_param|of|name|end_cycle|core|seed|with_output|with_param|species|from|attributes|number|generator|belief|desire|emotion|uncertainty|ideal|obligation|desires|beliefs|emotions|uncertainties|ideals|obligations|new_desire|new_belief|new_emotion|new_uncertainty|new_ideal|new_desires|new_beliefs|new_emotions|new_uncertainties|new_ideals|remove_beliefs|remove_desires|remove_emotions|remove_ideals|remove_obligations|remove_uncertainties|remove_belief|remove_ideal|remove_desire|remove_intention|remove_emotion|remove_uncertainty|remove_obligation|when|threshold|parallel|strength|lifetime|name|when|finished_when|priority|name|intention|obligation|threshold|lifetime|instantaneous|name|name|emotion_detected|emotion_created|charisma|when|threshold|decay|intensity|receptivity|id|var|expression|when|lifetime|truth|agent_cause|belief|desire|emotion|uncertainty|ideal|is_uncertain|strength|name|when|norm|obligation|law|sanction|reward|when|finished_when|priority|name|intention|emotion|threshold|instantaneous|name|emotion|charisma|when|threshold|decay|receptivity|name|emotion_detected|emotion_created|charisma|when|threshold|decay|intensity|receptivity|belief|desire|emotion|uncertainty|ideal|obligation|desires|beliefs|emotions|uncertainties|ideals|obligations|new_desire|new_belief|new_emotion|new_uncertainty|new_ideal|new_desires|new_beliefs|new_emotions|new_uncertainties|new_ideals|remove_beliefs|remove_desires|remove_emotions|remove_ideals|remove_obligations|remove_uncertainties|remove_belief|remove_ideal|remove_desire|remove_intention|remove_emotion|remove_uncertainty|remove_obligation|when|threshold|parallel|strength|lifetime|all|name|belief|beliefs|new_obligation|new_obligations|when|parallel|strength|lifetime|threshold|all|name|name|liking|dominance|solidarity|familiarity|trust|agent|when|name|as|when|parallel|in|emotion|threshold|target):/i, + 'operator': /\b(?:-|-|:|::|!|!=|\?|\/|\.|\.|\^|@|\*|\+|<|<=|=|>|>=|abs|accumulate|acos|action|add_3Dmodel|add_attribute|add_census_file|add_days|add_edge|add_geometry|add_hours|add_icon|add_mapper|add_marginals|add_minutes|add_months|add_ms|add_node|add_point|add_range_attribute|add_seconds|add_values|add_weeks|add_years|adjacency|after|agent|agent_closest_to|agent_farthest_to|agent_from_geometry|agent_intersecting|agents_at_distance|agents_covering|agents_crossing|agents_inside|agents_overlapping|agents_partially_overlapping|agents_touching|all_indexes_of|all_match|all_pairs_shortest_path|all_verify|alpha_index|among|and|and|angle_between|any|any_location_in|any_point_in|append_horizontally|append_vertically|arc|around|as|as_4_grid|as_distance_graph|as_driving_graph|as_edge_graph|as_grid|as_hexagonal_grid|as_int|as_intersection_graph|as_map|as_matrix|as_path|as_spatial_graph|asin|at|at_distance|at_location|atan|atan2|attributes|auto_correlation|BDIPlan|before|beta|beta_index|between|betweenness_centrality|biggest_cliques_of|binomial|binomial_coeff|binomial_complemented|binomial_sum|blend|bool|box|brewer_colors|brewer_palettes|buffer|build|capitalize|cartesian_product|ceil|cell_at|cells_in|cells_overlapping|centroid|char|chi_square|chi_square_complemented|choose|circle|clean|clean_network|closest_points_with|closest_to|collect|column_at|columns_list|command|cone|cone3D|connected_components_of|connectivity_index|container|contains|contains_all|contains_any|contains_edge|contains_key|contains_node|contains_value|contains_vertex|conversation|convex_hull|copy|copy_between|copy_file|copy_to_clipboard|correlation|cos|cos_rad|count|covariance|covering|covers|create_map|cross|crosses|crossing|crs|CRS_transform|csv_file|cube|curve|cylinder|date|dbscan|dead|degree_of|delete_file|det|determinant|diff|diff2|directed|direction_between|direction_to|directory|disjoint_from|distance_between|distance_to|distinct|distribution_of|distribution2d_of|div|dnorm|dtw|durbin_watson|dxf_file|edge|edge_between|edge_betweenness|edges|eigenvalues|electre_DM|ellipse|elliptical_arc|emotion|empty|enlarged_by|enter|envelope|eval_gaml|eval_when|evaluate_sub_model|even|every|every_cycle|evidence_theory_DM|exp|fact|farthest_point_to|farthest_to|field|file|file_exists|first|first_of|first_with|flip|float|floor|folder|folder_exists|font|frequency_of|from|fuzzy_choquet_DM|fuzzy_kappa|fuzzy_kappa_sim|gaml_file|gaml_type|gamma|gamma_density|gamma_distribution|gamma_distribution_complemented|gamma_index|gamma_rnd|gamma_trunc_rnd|gauss|gauss_rnd|gen_population_generator|gen_range|generate_barabasi_albert|generate_complete_graph|generate_random_graph|generate_terrain|generate_watts_strogatz|geojson_file|geometric_mean|geometry|geometry_collection|get|get_about|get_agent|get_agent_cause|get_belief_op|get_belief_with_name_op|get_beliefs_op|get_beliefs_with_name_op|get_current_intention_op|get_decay|get_desire_op|get_desire_with_name_op|get_desires_op|get_desires_with_name_op|get_dominance|get_familiarity|get_ideal_op|get_ideal_with_name_op|get_ideals_op|get_ideals_with_name_op|get_intensity|get_intention_op|get_intention_with_name_op|get_intentions_op|get_intentions_with_name_op|get_lifetime|get_liking|get_modality|get_obligation_op|get_obligation_with_name_op|get_obligations_op|get_obligations_with_name_op|get_plan_name|get_predicate|get_solidarity|get_strength|get_super_intention|get_trust|get_truth|get_uncertainties_op|get_uncertainties_with_name_op|get_uncertainty_op|get_uncertainty_with_name_op|get_values|gif_file|gini|girvan_newman_clustering|gml_file|gradient|graph|graph6_file|graphdimacs_file|graphdot_file|graphgexf_file|graphgml_file|graphml_file|graphtsplib_file|grayscale|grid_at|grid_cells_to_graph|grid_file|group_by|harmonic_mean|has_belief_op|has_belief_with_name_op|has_desire_op|has_desire_with_name_op|has_ideal_op|has_ideal_with_name_op|has_intention_op|has_intention_with_name_op|has_obligation_op|has_obligation_with_name_op|has_uncertainty_op|has_uncertainty_with_name_op|hexagon|hierarchical_clustering|horizontal|hsb|hypot|IDW|image_file|in|in_degree_of|in_edges_of|incomplete_beta|incomplete_gamma|incomplete_gamma_complement|indented_by|index_by|index_of|inside|int|inter|interleave|internal_integrated_value|intersecting|intersection|intersects|inverse|inverse_distance_weighting|inverse_rotation|is|is_csv|is_dxf|is_error|is_finite|is_gaml|is_geojson|is_gif|is_gml|is_graph6|is_graphdimacs|is_graphdot|is_graphgexf|is_graphgml|is_graphml|is_graphtsplib|is_grid|is_image|is_json|is_number|is_obj|is_osm|is_pgm|is_property|is_reachable|is_saved_simulation|is_shape|is_skill|is_svg|is_text|is_threeds|is_warning|is_xml|json_file|k_spanning_tree_clustering|kappa|kappa_sim|kmeans|kml|kurtosis|label_propagation_clustering|last|last_index_of|last_of|last_with|layout_circle|layout_force|layout_force_FR|layout_force_FR_indexed|layout_grid|length|lgamma|line|link|list|list_with|ln|load_shortest_paths|load_sub_model|log|log_gamma|lognormal_density|lognormal_rnd|lognormal_trunc_rnd|lower_case|main_connected_component|map|masked_by|material|matrix|matrix_with|max|max_flow_between|max_of|maximal_cliques_of|mean|mean_deviation|mean_of|median|mental_state|message|milliseconds_between|min|min_of|minus_days|minus_hours|minus_minutes|minus_months|minus_ms|minus_seconds|minus_weeks|minus_years|mod|moment|months_between|moran|morrisAnalysis|mul|nb_cycles|neighbors_at|neighbors_of|new_emotion|new_folder|new_mental_state|new_predicate|new_social_link|node|nodes|none_matches|none_verifies|norm|Norm|normal_area|normal_density|normal_inverse|normalized_rotation|not|not|obj_file|of|of_generic_species|of_species|one_matches|one_of|one_verifies|or|or|osm_file|out_degree_of|out_edges_of|overlapping|overlaps|pair|palette|partially_overlapping|partially_overlaps|path|path_between|path_to|paths_between|pbinom|pchisq|percent_absolute_deviation|percentile|pgamma|pgm_file|plan|play_sound|plus_days|plus_hours|plus_minutes|plus_months|plus_ms|plus_seconds|plus_weeks|plus_years|pnorm|point|points_along|points_at|points_in|points_on|poisson|polygon|polyhedron|polyline|polyplan|predecessors_of|predicate|predict|product|product_of|promethee_DM|property_file|pValue_for_fStat|pValue_for_tStat|pyramid|quantile|quantile_inverse|range|rank_interpolated|read|rectangle|reduced_by|regex_matches|regression|remove_duplicates|remove_node_from|rename_file|replace|replace_regex|residuals|restore_simulation|restore_simulation_from_file|reverse|rewire_n|rgb|rgb|rms|rnd|rnd_choice|rnd_color|rotated_by|rotation_composition|round|row_at|rows_list|rSquare|sample|Sanction|save_simulation|saved_simulation_file|scale|scaled_by|scaled_to|select|serialize|serialize_agent|set_about|set_agent|set_agent_cause|set_decay|set_dominance|set_familiarity|set_intensity|set_lifetime|set_liking|set_modality|set_predicate|set_solidarity|set_strength|set_trust|set_truth|set_z|shape_file|shuffle|signum|simple_clustering_by_distance|simple_clustering_by_envelope_distance|simplification|sin|sin_rad|since|skeletonize|skew|skew_gauss|skewness|skill|smooth|sobolAnalysis|social_link|solid|sort|sort_by|source_of|spatial_graph|species|species_of|sphere|split|split_at|split_geometry|split_in|split_lines|split_using|split_with|sqrt|square|squircle|stack|standard_deviation|step_sub_model|strahler|string|student_area|student_t_inverse|subtract_days|subtract_hours|subtract_minutes|subtract_months|subtract_ms|subtract_seconds|subtract_weeks|subtract_years|successors_of|sum|sum_of|svg_file|t_test|tan|tan_rad|tanh|target_of|teapot|text_file|TGauss|threeds_file|to|to_GAMA_CRS|to_gaml|to_rectangles|to_segments|to_squares|to_sub_geometries|to_triangles|tokenize|topology|topology|touches|touching|towards|trace|transformed_by|translated_by|translated_to|transpose|triangle|triangulate|truncated_gauss|type_of|undirected|union|unknown|until|unzip|upper_case|use_cache|user_confirm|user_input_dialog|using|values_in|variance|variance_of|vertical|voronoi|weibull_density|weibull_rnd|weibull_trunc_rnd|weight_of|weighted_means_DM|where|with_generation_algo|with_k_shortest_path_algorithm|with_max_of|with_min_of|with_precision|with_shortest_path_algorithm|with_values|with_weights|without_holes|wizard|wizard_page|writable|xml_file|xor|years_between|zip)\b/i, + + 'keyword':/\b(?:nil|each|self|myself)\b/, + 'constant':/#[A-Za-z]+/i, 'punctuation': /\.\.?|[,;():]/, - 'char': /'.'/, + 'variableDefinition': /\b(?<=string|action|agent|attributes|BDIPlan|bool|container|conversation|date|directory|emotion|field|file|float|font|gaml_type|gen_population_generator|gen_range|geometry|graph|int|kml|list|map|material|matrix|mental_state|message|Norm|pair|path|point|predicate|regression|rgb|Sanction|skill|social_link|species|string|topology|unknown)\s*[a-z]\w*/i, 'variable': /\b[a-z](?:\w)*\b/i }; From c5a36374ad835e62db7d27f16eca93ae3eedd87a Mon Sep 17 00:00:00 2001 From: RoiArthurB Date: Mon, 17 Oct 2022 22:20:56 +0700 Subject: [PATCH 4/4] [PRISM-GAML] Migrate from ad.hoc implementation to official NodeJS package --- website/docusaurus.config.js | 4 +++ website/package.json | 1 + website/src/theme/prism-gaml.js | 26 -------------------- website/src/theme/prism-include-languages.js | 2 +- 4 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 website/src/theme/prism-gaml.js diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index aebf630053..3c6073a803 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -93,6 +93,10 @@ module.exports={ "prism": { additionalLanguages: ['java','javascript','python'], defaultLanguage: 'gaml', + + theme: require('prism-gaml/themes/light'), + darkTheme: require('prism-gaml/themes/dark'), + }, algolia: { appId: 'MWUOLTL2EG', diff --git a/website/package.json b/website/package.json index 316fed9b60..e5bf1aaab7 100644 --- a/website/package.json +++ b/website/package.json @@ -18,6 +18,7 @@ "@docusaurus/preset-classic": "^2.1.0", "@saucelabs/theme-github-codeblock": "^0.1.1", "clsx": "^1.1.1", + "prism-gaml": "^0.1.2", "react": "^17.0.2", "react-dom": "^17.0.2", "url": "^0.11.0" diff --git a/website/src/theme/prism-gaml.js b/website/src/theme/prism-gaml.js deleted file mode 100644 index a81e360a2e..0000000000 --- a/website/src/theme/prism-gaml.js +++ /dev/null @@ -1,26 +0,0 @@ - -Prism.languages.gaml = { - 'comment': [ - { pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, - { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], - 'string': - { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, - 'number': [ - { - pattern: /\b\d(?:_?\d)*#[\dA-F](?:_?[\dA-F])*(?:\.[\dA-F](?:_?[\dA-F])*)?#(?:E[+-]?\d(?:_?\d)*)?/i - }, - { - pattern: /\b\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:E[+-]?\d(?:_?\d)*)?\b/i - }], - 'type_statement': /\b(?:string\s\s|action\s|agent\s|attributes\s|BDIPlan\s|bool\s|container\s|conversation\s|date\s|directory\s|emotion\s|field\s|file\s|float\s|font\s|gaml_type\s|gen_population_generator\s|gen_range\s|geometry\s|graph\s|int\s|kml\s|list\s|map\s|material\s|matrix\s|mental_state\s|message\s|Norm\s|pair\s|path\s|point\s|predicate\s|regression\s|rgb\s|Sanction\s|skill\s|social_link\s|species\s|string\s|topology\s|unknown)(?!(\(|\_))/i, - 'boolean': /\b(?:false|true)\b/i, - 'statement': /\b(?:model|import|=|abort|action|add|agents|annealing|ask|aspect|assert|benchmark|betad|break|browse|camera|capture|catch|chart|conscious_contagion|continue|coping|create|data|datalist|default|diffuse|diffusion|display|display_grid|display_population|do|draw|else|emotional_contagion|enforcement|enter|equation|error|event|exit|experiment|exploration|focus|focus_on|generate|genetic|global|graphics|grid|highlight|hill_climbing|if|image|init|inspect|invoke|law|layout|let|light|loop|match|match_between|match_one|match_regex|mesh|migrate|monitor|morris|norm|output|output_file|overlay|parameter|perceive|permanent|plan|pso|put|reactive_tabu|reflex|release|remove|return|rotation|rule|rule|run|sanction|save|set|setup|simulate|sobol|socialize|solve|species|start_simulation|state|status|stochanalyse|switch|tabu|task|test|text|trace|transition|try|unconscious_contagion|user_command|user_init|user_input|user_panel|using|Variable_container|Variable_number|Variable_regular|warn|write)\b/i, - 'facet': /\b(?:name|name|name|iter_max|init_solution|maximize|minimize|aggregation|value|rotate|trace|selectable|fading|position|size|transparency|visible|name|aspect|refresh|rounded|border|position|size|transparency|left|visible|right|center|background|color|initial|name|color|message|position|background|border|rotate|trace|fading|size|transparency|visible|name|refresh|name|value|name|iter_max|num_particles|weight_inertia|weight_cognitive|weight_social|maximize|minimize|aggregation|position|rotate|no_data|scale|size|transparency|visible|border|wireframe|smooth|source|texture|grayscale|color|triangulation|text|refresh|value|editors|toolbars|controls|parameters|navigator|consoles|tray|background|tabs|initial|name|action|with|internal_function|x_range|y_range|y2_range|position|size|reverse_axes|background|x_serie|x_serie_labels|y_serie_labels|x_log_scale|y_log_scale|y2_log_scale|axes|x_tick_values_visible|y_tick_values_visible|title_visible|x_tick_line_visible|y_tick_line_visible|tick_line_color|type|style|gap|y_tick_unit|y2_tick_unit|x_tick_unit|name|x_label|y_label|y2_label|color|series_label_position|label_background_color|label_text_color|memorize|tick_font|label_font|transparency|visible|legend_font|title_font|from|to|step|name|over|while|times|name|type|init|<-|update|function|->|const|category|parameter|on_change|min|max|step|among|species|returns|from|number|as|with|source|target|returns|value|legend|use_second_y_axis|y_err_values|x_err_values|y_minmax_values|marker_size|color|accumulate_values|line_visible|marker|marker_shape|fill|thickness|style|name|location|type|direction|angle|linear_attenuation|quadratic_attenuation|active|intensity|show|dynamic|position|rotate|selectable|size|transparency|trace|fading|visible|species|aspect|refresh|name|iter_max|init_solution|tabu_list_size|maximize|minimize|aggregation|name|title|benchmark|parent|skills|control|frequency|schedules|keep_seed|keep_simulations|repeat|until|parallel|type|virtual|autorun|topology|name|sample|levels|outputs|report|csv|results|value|to|item|at|all|parallel|target|as|name|temp_end|init_solution|temp_decrease|temp_init|nb_iter_cst_temp|maximize|minimize|aggregation|value|name|sampling|outputs|sample|results|levels|threshold|name|color|refresh|value|name|data|refresh|header|footer|rewrite|type|value|warning|target|as|in|returns|color|value|value|weight|name|name|type|of|index|virtual|geometry|texture|wireframe|border|at|anchor|size|color|rotate|font|depth|precision|begin_arrow|end_arrow|lighted|perspective|material|width|item|from|index|key|all|when|name|name|dynamic|distance|location|target|lens|locked|name|type|init|min|slider|max|returns|among|message|name|type|init|<-|update|function|->|const|category|parameter|on_change|of|index|name|type|init|min|max|category|var|unit|on_change|enables|disables|updates|in_workspace|extensions|slider|colors|labels|step|read_only|among|at|key|all|item|in|position|rotate|selectable|size|transparency|species|visible|border|elevation|texture|smooth|grayscale|triangulation|hexagonal|text|wireframe|refresh|name|type|of|index|init|<-|update|on_change|function|->|const|category|parameter|among|type|data|rewrite|header|to|crs|attributes|condition|name|sample|outputs|results|report|path|message|synchronized|parallel|width|height|cell_width|cell_height|neighbors|horizontal_orientation|use_individual_shapes|use_regular_agents|optimizer|use_neighbors_cache|file|files|torus|name|parent|edge_species|skills|mirrors|control|compile|frequency|schedules|topology|virtual|color|background|font|category|message|color|message|name|iter_max|init_solution|tabu_list_size_init|tabu_list_size_max|tabu_list_size_min|nb_tests_wthout_col_max|cycle_size_max|cycle_size_min|maximize|minimize|aggregation|dynamic|location|axis|angle|name|value|of|index|type|unused|name|type|action|value|y_err_values|x_err_values|use_second_y_axis|y_minmax_values|marker_size|legend|marker|marker_shape|accumulate_values|line_visible|fill|color|thickness|style|virtual|parent|background|name|type|antialias|refresh|toolbar|fullscreen|show_fps|axes|orthographic_projection|light|camera|keystone|z_near|z_far|autosave|name|name|refresh|value|attributes|type|target|as|returns|file|rotate|position|size|transparency|visible|name|gis|color|refresh|value|message|repeat|when|to|name|sampling|outputs|sample|results|report|initial|final|name|name|pop_dim|crossover_prob|mutation_prob|nb_prelim_gen|max_gen|improve_sol|stochastic_sel|maximize|minimize|aggregation|when|priority|name|value|continue|color|category|action|name|when|with|name|sampling|from|with|sample|levels|iterations|synchronized|autosave|comodel|with_experiment|share|with_input|with_output|reset|until|repeat|equation|method|t0|tf|step|step_size|min_step|max_step|scalAbsoluteTolerance|scalRelativeTolerance|nSteps|var|on|matrix|method|min|mask|proportion|propagation|radius|variation|cycle_length|avoid_mask|left|right|name|vars|params|simultaneously|of|name|seed|with_param|of|name|end_cycle|core|seed|with_output|with_param|species|from|attributes|number|generator|belief|desire|emotion|uncertainty|ideal|obligation|desires|beliefs|emotions|uncertainties|ideals|obligations|new_desire|new_belief|new_emotion|new_uncertainty|new_ideal|new_desires|new_beliefs|new_emotions|new_uncertainties|new_ideals|remove_beliefs|remove_desires|remove_emotions|remove_ideals|remove_obligations|remove_uncertainties|remove_belief|remove_ideal|remove_desire|remove_intention|remove_emotion|remove_uncertainty|remove_obligation|when|threshold|parallel|strength|lifetime|name|when|finished_when|priority|name|intention|obligation|threshold|lifetime|instantaneous|name|name|emotion_detected|emotion_created|charisma|when|threshold|decay|intensity|receptivity|id|var|expression|when|lifetime|truth|agent_cause|belief|desire|emotion|uncertainty|ideal|is_uncertain|strength|name|when|norm|obligation|law|sanction|reward|when|finished_when|priority|name|intention|emotion|threshold|instantaneous|name|emotion|charisma|when|threshold|decay|receptivity|name|emotion_detected|emotion_created|charisma|when|threshold|decay|intensity|receptivity|belief|desire|emotion|uncertainty|ideal|obligation|desires|beliefs|emotions|uncertainties|ideals|obligations|new_desire|new_belief|new_emotion|new_uncertainty|new_ideal|new_desires|new_beliefs|new_emotions|new_uncertainties|new_ideals|remove_beliefs|remove_desires|remove_emotions|remove_ideals|remove_obligations|remove_uncertainties|remove_belief|remove_ideal|remove_desire|remove_intention|remove_emotion|remove_uncertainty|remove_obligation|when|threshold|parallel|strength|lifetime|all|name|belief|beliefs|new_obligation|new_obligations|when|parallel|strength|lifetime|threshold|all|name|name|liking|dominance|solidarity|familiarity|trust|agent|when|name|as|when|parallel|in|emotion|threshold|target):/i, - 'operator': /\b(?:-|-|:|::|!|!=|\?|\/|\.|\.|\^|@|\*|\+|<|<=|=|>|>=|abs|accumulate|acos|action|add_3Dmodel|add_attribute|add_census_file|add_days|add_edge|add_geometry|add_hours|add_icon|add_mapper|add_marginals|add_minutes|add_months|add_ms|add_node|add_point|add_range_attribute|add_seconds|add_values|add_weeks|add_years|adjacency|after|agent|agent_closest_to|agent_farthest_to|agent_from_geometry|agent_intersecting|agents_at_distance|agents_covering|agents_crossing|agents_inside|agents_overlapping|agents_partially_overlapping|agents_touching|all_indexes_of|all_match|all_pairs_shortest_path|all_verify|alpha_index|among|and|and|angle_between|any|any_location_in|any_point_in|append_horizontally|append_vertically|arc|around|as|as_4_grid|as_distance_graph|as_driving_graph|as_edge_graph|as_grid|as_hexagonal_grid|as_int|as_intersection_graph|as_map|as_matrix|as_path|as_spatial_graph|asin|at|at_distance|at_location|atan|atan2|attributes|auto_correlation|BDIPlan|before|beta|beta_index|between|betweenness_centrality|biggest_cliques_of|binomial|binomial_coeff|binomial_complemented|binomial_sum|blend|bool|box|brewer_colors|brewer_palettes|buffer|build|capitalize|cartesian_product|ceil|cell_at|cells_in|cells_overlapping|centroid|char|chi_square|chi_square_complemented|choose|circle|clean|clean_network|closest_points_with|closest_to|collect|column_at|columns_list|command|cone|cone3D|connected_components_of|connectivity_index|container|contains|contains_all|contains_any|contains_edge|contains_key|contains_node|contains_value|contains_vertex|conversation|convex_hull|copy|copy_between|copy_file|copy_to_clipboard|correlation|cos|cos_rad|count|covariance|covering|covers|create_map|cross|crosses|crossing|crs|CRS_transform|csv_file|cube|curve|cylinder|date|dbscan|dead|degree_of|delete_file|det|determinant|diff|diff2|directed|direction_between|direction_to|directory|disjoint_from|distance_between|distance_to|distinct|distribution_of|distribution2d_of|div|dnorm|dtw|durbin_watson|dxf_file|edge|edge_between|edge_betweenness|edges|eigenvalues|electre_DM|ellipse|elliptical_arc|emotion|empty|enlarged_by|enter|envelope|eval_gaml|eval_when|evaluate_sub_model|even|every|every_cycle|evidence_theory_DM|exp|fact|farthest_point_to|farthest_to|field|file|file_exists|first|first_of|first_with|flip|float|floor|folder|folder_exists|font|frequency_of|from|fuzzy_choquet_DM|fuzzy_kappa|fuzzy_kappa_sim|gaml_file|gaml_type|gamma|gamma_density|gamma_distribution|gamma_distribution_complemented|gamma_index|gamma_rnd|gamma_trunc_rnd|gauss|gauss_rnd|gen_population_generator|gen_range|generate_barabasi_albert|generate_complete_graph|generate_random_graph|generate_terrain|generate_watts_strogatz|geojson_file|geometric_mean|geometry|geometry_collection|get|get_about|get_agent|get_agent_cause|get_belief_op|get_belief_with_name_op|get_beliefs_op|get_beliefs_with_name_op|get_current_intention_op|get_decay|get_desire_op|get_desire_with_name_op|get_desires_op|get_desires_with_name_op|get_dominance|get_familiarity|get_ideal_op|get_ideal_with_name_op|get_ideals_op|get_ideals_with_name_op|get_intensity|get_intention_op|get_intention_with_name_op|get_intentions_op|get_intentions_with_name_op|get_lifetime|get_liking|get_modality|get_obligation_op|get_obligation_with_name_op|get_obligations_op|get_obligations_with_name_op|get_plan_name|get_predicate|get_solidarity|get_strength|get_super_intention|get_trust|get_truth|get_uncertainties_op|get_uncertainties_with_name_op|get_uncertainty_op|get_uncertainty_with_name_op|get_values|gif_file|gini|girvan_newman_clustering|gml_file|gradient|graph|graph6_file|graphdimacs_file|graphdot_file|graphgexf_file|graphgml_file|graphml_file|graphtsplib_file|grayscale|grid_at|grid_cells_to_graph|grid_file|group_by|harmonic_mean|has_belief_op|has_belief_with_name_op|has_desire_op|has_desire_with_name_op|has_ideal_op|has_ideal_with_name_op|has_intention_op|has_intention_with_name_op|has_obligation_op|has_obligation_with_name_op|has_uncertainty_op|has_uncertainty_with_name_op|hexagon|hierarchical_clustering|horizontal|hsb|hypot|IDW|image_file|in|in_degree_of|in_edges_of|incomplete_beta|incomplete_gamma|incomplete_gamma_complement|indented_by|index_by|index_of|inside|int|inter|interleave|internal_integrated_value|intersecting|intersection|intersects|inverse|inverse_distance_weighting|inverse_rotation|is|is_csv|is_dxf|is_error|is_finite|is_gaml|is_geojson|is_gif|is_gml|is_graph6|is_graphdimacs|is_graphdot|is_graphgexf|is_graphgml|is_graphml|is_graphtsplib|is_grid|is_image|is_json|is_number|is_obj|is_osm|is_pgm|is_property|is_reachable|is_saved_simulation|is_shape|is_skill|is_svg|is_text|is_threeds|is_warning|is_xml|json_file|k_spanning_tree_clustering|kappa|kappa_sim|kmeans|kml|kurtosis|label_propagation_clustering|last|last_index_of|last_of|last_with|layout_circle|layout_force|layout_force_FR|layout_force_FR_indexed|layout_grid|length|lgamma|line|link|list|list_with|ln|load_shortest_paths|load_sub_model|log|log_gamma|lognormal_density|lognormal_rnd|lognormal_trunc_rnd|lower_case|main_connected_component|map|masked_by|material|matrix|matrix_with|max|max_flow_between|max_of|maximal_cliques_of|mean|mean_deviation|mean_of|median|mental_state|message|milliseconds_between|min|min_of|minus_days|minus_hours|minus_minutes|minus_months|minus_ms|minus_seconds|minus_weeks|minus_years|mod|moment|months_between|moran|morrisAnalysis|mul|nb_cycles|neighbors_at|neighbors_of|new_emotion|new_folder|new_mental_state|new_predicate|new_social_link|node|nodes|none_matches|none_verifies|norm|Norm|normal_area|normal_density|normal_inverse|normalized_rotation|not|not|obj_file|of|of_generic_species|of_species|one_matches|one_of|one_verifies|or|or|osm_file|out_degree_of|out_edges_of|overlapping|overlaps|pair|palette|partially_overlapping|partially_overlaps|path|path_between|path_to|paths_between|pbinom|pchisq|percent_absolute_deviation|percentile|pgamma|pgm_file|plan|play_sound|plus_days|plus_hours|plus_minutes|plus_months|plus_ms|plus_seconds|plus_weeks|plus_years|pnorm|point|points_along|points_at|points_in|points_on|poisson|polygon|polyhedron|polyline|polyplan|predecessors_of|predicate|predict|product|product_of|promethee_DM|property_file|pValue_for_fStat|pValue_for_tStat|pyramid|quantile|quantile_inverse|range|rank_interpolated|read|rectangle|reduced_by|regex_matches|regression|remove_duplicates|remove_node_from|rename_file|replace|replace_regex|residuals|restore_simulation|restore_simulation_from_file|reverse|rewire_n|rgb|rgb|rms|rnd|rnd_choice|rnd_color|rotated_by|rotation_composition|round|row_at|rows_list|rSquare|sample|Sanction|save_simulation|saved_simulation_file|scale|scaled_by|scaled_to|select|serialize|serialize_agent|set_about|set_agent|set_agent_cause|set_decay|set_dominance|set_familiarity|set_intensity|set_lifetime|set_liking|set_modality|set_predicate|set_solidarity|set_strength|set_trust|set_truth|set_z|shape_file|shuffle|signum|simple_clustering_by_distance|simple_clustering_by_envelope_distance|simplification|sin|sin_rad|since|skeletonize|skew|skew_gauss|skewness|skill|smooth|sobolAnalysis|social_link|solid|sort|sort_by|source_of|spatial_graph|species|species_of|sphere|split|split_at|split_geometry|split_in|split_lines|split_using|split_with|sqrt|square|squircle|stack|standard_deviation|step_sub_model|strahler|string|student_area|student_t_inverse|subtract_days|subtract_hours|subtract_minutes|subtract_months|subtract_ms|subtract_seconds|subtract_weeks|subtract_years|successors_of|sum|sum_of|svg_file|t_test|tan|tan_rad|tanh|target_of|teapot|text_file|TGauss|threeds_file|to|to_GAMA_CRS|to_gaml|to_rectangles|to_segments|to_squares|to_sub_geometries|to_triangles|tokenize|topology|topology|touches|touching|towards|trace|transformed_by|translated_by|translated_to|transpose|triangle|triangulate|truncated_gauss|type_of|undirected|union|unknown|until|unzip|upper_case|use_cache|user_confirm|user_input_dialog|using|values_in|variance|variance_of|vertical|voronoi|weibull_density|weibull_rnd|weibull_trunc_rnd|weight_of|weighted_means_DM|where|with_generation_algo|with_k_shortest_path_algorithm|with_max_of|with_min_of|with_precision|with_shortest_path_algorithm|with_values|with_weights|without_holes|wizard|wizard_page|writable|xml_file|xor|years_between|zip)\b/i, - - 'keyword':/\b(?:nil|each|self|myself)\b/, - 'constant':/#[A-Za-z]+/i, - 'punctuation': /\.\.?|[,;():]/, - 'variableDefinition': /\b(?<=string|action|agent|attributes|BDIPlan|bool|container|conversation|date|directory|emotion|field|file|float|font|gaml_type|gen_population_generator|gen_range|geometry|graph|int|kml|list|map|material|matrix|mental_state|message|Norm|pair|path|point|predicate|regression|rgb|Sanction|skill|social_link|species|string|topology|unknown)\s*[a-z]\w*/i, - 'variable': /\b[a-z](?:\w)*\b/i -}; diff --git a/website/src/theme/prism-include-languages.js b/website/src/theme/prism-include-languages.js index e2e0ebb822..657eb2e5e1 100644 --- a/website/src/theme/prism-include-languages.js +++ b/website/src/theme/prism-include-languages.js @@ -16,7 +16,7 @@ export default function prismIncludeLanguages(PrismObject) { require(`prismjs/components/prism-${lang}`); }); - require('./prism-gaml'); + require('prism-gaml/components/prism-gaml'); delete globalThis.Prism; }