squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

swi-prolog.pl (1113B)


      1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      2 % Predicate implementations for SWI-Prolog dialects.
      3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      4 
      5 % Detect SWI-Prolog
      6 swi_prolog:-
      7 	catch(current_prolog_flag(dialect, swi), _, fail).
      8 
      9 
     10 % SWI-Prolog-specific predicate to run an external Markdown tool.
     11 % The command itself should be specified in your site.pl.
     12 markdown_to_html(MarkdownEntryCodes, HTMLEntryCodes):-
     13 	swi_prolog,
     14 	markdown_command([Exe|Args]),
     15 	process_create(Exe, Args, [stdin(pipe(StreamIn)), stdout(pipe(StreamOut))]),
     16 	write_codes(StreamIn, MarkdownEntryCodes),
     17 	close(StreamIn),
     18 	read_file(StreamOut, HTMLEntryCodes),
     19 	close(StreamOut).
     20 
     21 
     22 % SWI-Prolog-specific predicates for date handling.
     23 today(FormattedDateCodes):-
     24 	swi_prolog,
     25 	get_time(DateStamp),
     26 	format_time(codes(FormattedDateCodes), '%a, %d %b %Y %T %z', DateStamp).
     27 
     28 % Format a date as RFC 822 (with a four-digit year).
     29 format_date(FormattedDateCodes, DateCodes):-
     30 	swi_prolog,
     31 	atom_codes(DateAtom, DateCodes),
     32 	parse_time(DateAtom, DateStamp),
     33 	format_time(codes(FormattedDateCodes), '%a, %d %b %Y %T %z', DateStamp).