Fix Farkup link escaping
							parent
							
								
									af49278d3f
								
							
						
					
					
						commit
						d815c0c048
					
				| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
! Copyright (C) 2008 Doug Coleman.
 | 
			
		||||
! See http://factorcode.org/license.txt for BSD license.
 | 
			
		||||
USING: farkup kernel peg peg.ebnf tools.test namespaces ;
 | 
			
		||||
USING: farkup kernel peg peg.ebnf tools.test namespaces xml
 | 
			
		||||
urls.encoding assocs xml.utilities ;
 | 
			
		||||
IN: farkup.tests
 | 
			
		||||
 | 
			
		||||
relative-link-prefix off
 | 
			
		||||
| 
						 | 
				
			
			@ -157,3 +158,12 @@ link-no-follow? off
 | 
			
		|||
 | 
			
		||||
[ "<p>hello_world how are you today?\n<ul><li> hello_world how are you today?</li></ul></p>" ]
 | 
			
		||||
[ "hello_world how are you today?\n- hello_world how are you today?" convert-farkup ] unit-test
 | 
			
		||||
 | 
			
		||||
: check-link-escaping ( string -- link )
 | 
			
		||||
    convert-farkup string>xml-chunk
 | 
			
		||||
    "a" deep-tag-named "href" swap at url-decode ;
 | 
			
		||||
 | 
			
		||||
[ "Trader Joe's" ] [ "[[Trader Joe's]]" check-link-escaping ] unit-test
 | 
			
		||||
[ "<foo>" ] [ "[[<foo>]]" check-link-escaping ] unit-test
 | 
			
		||||
[ "&blah;" ] [ "[[&blah;]]" check-link-escaping ] unit-test
 | 
			
		||||
[ "C++" ] [ "[[C++]]" check-link-escaping ] unit-test
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ stand-alone
 | 
			
		|||
    } cond ;
 | 
			
		||||
 | 
			
		||||
: escape-link ( href text -- href-esc text-esc )
 | 
			
		||||
    [ check-url escape-quoted-string ] dip escape-string ;
 | 
			
		||||
    [ check-url ] dip escape-string ;
 | 
			
		||||
 | 
			
		||||
: write-link ( href text -- )
 | 
			
		||||
    escape-link
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue