| 
									
										
										
										
											2009-04-22 05:20:38 -04:00
										 |  |  | ! Copyright (C) 2005, 2009 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2016-03-20 22:42:38 -04:00
										 |  |  | USING: fry help.markup help.topics kernel math sequences ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: help.crossref | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 18:32:38 -05:00
										 |  |  | : article-links ( topic elements -- seq )
 | 
					
						
							| 
									
										
										
										
											2016-03-20 22:42:38 -04:00
										 |  |  |     [ article-content ] dip collect-elements ;
 | 
					
						
							| 
									
										
										
										
											2008-12-20 18:32:38 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : article-children ( topic -- seq )
 | 
					
						
							| 
									
										
										
										
											2010-01-25 07:18:10 -05:00
										 |  |  |     { $subsection $subsections } article-links [ >link ] map ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : help-path ( topic -- seq )
 | 
					
						
							| 
									
										
										
										
											2008-04-26 03:01:43 -04:00
										 |  |  |     [ article-parent ] follow rest ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : set-article-parents ( parent article -- )
 | 
					
						
							| 
									
										
										
										
											2008-01-09 17:36:30 -05:00
										 |  |  |     article-children [ set-article-parent ] with each ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : xref-article ( topic -- )
 | 
					
						
							| 
									
										
										
										
											2009-04-22 05:20:38 -04:00
										 |  |  |     dup set-article-parents ;
 | 
					
						
							| 
									
										
										
										
											2008-12-20 18:32:38 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-07 13:18:30 -05:00
										 |  |  | : prev/next ( obj seq n -- obj' )
 | 
					
						
							|  |  |  |     [ [ index dup ] keep ] dip swap
 | 
					
						
							|  |  |  |     '[ _ + _ ?nth ] when ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 18:32:38 -05:00
										 |  |  | : prev/next-article ( article n -- article' )
 | 
					
						
							|  |  |  |     [ dup article-parent dup ] dip
 | 
					
						
							| 
									
										
										
										
											2009-01-07 13:18:30 -05:00
										 |  |  |     '[ article-children _ prev/next ] [ 2drop f ] if ;
 | 
					
						
							| 
									
										
										
										
											2008-12-20 18:32:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : prev-article ( article -- prev ) -1 prev/next-article ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | : next-article ( article -- next ) 1 prev/next-article ;
 |