kibi-swipl-linux-x64-gnu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
/* Part of SWI-Prolog
|
|
2
|
+
|
|
3
|
+
Author: Jan Wielemaker
|
|
4
|
+
E-mail: J.Wielemaker@vu.nl
|
|
5
|
+
WWW: http://www.swi-prolog.org
|
|
6
|
+
Copyright (c) 2018-2020, CWI, Amsterdam
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
|
10
|
+
modification, are permitted provided that the following conditions
|
|
11
|
+
are met:
|
|
12
|
+
|
|
13
|
+
1. Redistributions of source code must retain the above copyright
|
|
14
|
+
notice, this list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
notice, this list of conditions and the following disclaimer in
|
|
18
|
+
the documentation and/or other materials provided with the
|
|
19
|
+
distribution.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
24
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
25
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
26
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
27
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
28
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
30
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
31
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
:- module(html_text,
|
|
37
|
+
[ html_text/1, % +FileName
|
|
38
|
+
html_text/2 % +FileName, Options
|
|
39
|
+
]).
|
|
40
|
+
:- use_module(library(debug),[debug/3]).
|
|
41
|
+
:- autoload(library(ansi_term),[ansi_format/3]).
|
|
42
|
+
:- autoload(library(apply),[foldl/4,maplist/3,maplist/2]).
|
|
43
|
+
:- autoload(library(error),[must_be/2]).
|
|
44
|
+
:- autoload(library(lists),
|
|
45
|
+
[ append/3, list_to_set/2, reverse/2, delete/3, sum_list/2,
|
|
46
|
+
nth1/3, max_list/2
|
|
47
|
+
]).
|
|
48
|
+
:- autoload(library(option),[select_option/4,merge_options/3,option/3]).
|
|
49
|
+
:- autoload(library(sgml),[xml_is_dom/1,load_html/3]).
|
|
50
|
+
:- autoload(library(lynx/format),[format_paragraph/2,trim_line/2]).
|
|
51
|
+
:- autoload(library(lynx/html_style),
|
|
52
|
+
[ element_css/3, css_block_options/5, css_inline_options/3,
|
|
53
|
+
attrs_classes/2, style_css_attrs/2
|
|
54
|
+
]).
|
|
55
|
+
|
|
56
|
+
:- predicate_options(html_text/2, 2,
|
|
57
|
+
[ margin_left(integer),
|
|
58
|
+
margin_right(integer),
|
|
59
|
+
width(integer),
|
|
60
|
+
text_align(oneof([justify, left]))
|
|
61
|
+
]).
|
|
62
|
+
|
|
63
|
+
/** <module> Render HTML as plain text
|
|
64
|
+
|
|
65
|
+
This module renders HTML markup as plain text, just like the open _lynx_
|
|
66
|
+
program does. It is (as yet), limited to and spacialized for dealing
|
|
67
|
+
with the SWI-Prolog documentation. This library first of all supports
|
|
68
|
+
help/1.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
%! html_text(+Input) is det.
|
|
72
|
+
%! html_text(+Input, +Options) is det.
|
|
73
|
+
%
|
|
74
|
+
% Render HTML from Input to `current_output`. Input is either an HTML
|
|
75
|
+
% DOM or a valid input for load_html/3. Options defined are:
|
|
76
|
+
%
|
|
77
|
+
% - margin_left(+N)
|
|
78
|
+
% - margin_right(+N)
|
|
79
|
+
% Initial margins.
|
|
80
|
+
% - width(+N)
|
|
81
|
+
% Total preceived line width.
|
|
82
|
+
% - text_align(+Align)
|
|
83
|
+
% One of `justify` or `left`. Default is `justify`.
|
|
84
|
+
|
|
85
|
+
html_text(Input) :-
|
|
86
|
+
html_text(Input, []).
|
|
87
|
+
|
|
88
|
+
html_text(Input, Options) :-
|
|
89
|
+
( xml_is_dom(Input)
|
|
90
|
+
-> DOM = Input
|
|
91
|
+
; load_html(Input, DOM, Options)
|
|
92
|
+
),
|
|
93
|
+
default_state(State0),
|
|
94
|
+
state_options(Options, State0, State),
|
|
95
|
+
init_nl,
|
|
96
|
+
format_dom(DOM, State).
|
|
97
|
+
|
|
98
|
+
state_options([], State, State).
|
|
99
|
+
state_options([H|T], State0, State) :-
|
|
100
|
+
H =.. [Key,Value],
|
|
101
|
+
( fmt_option(Key, Type, _Default)
|
|
102
|
+
-> must_be(Type, Value),
|
|
103
|
+
State1 = State0.put(Key,Value)
|
|
104
|
+
; State1 = State0
|
|
105
|
+
),
|
|
106
|
+
state_options(T, State1, State).
|
|
107
|
+
|
|
108
|
+
fmt_option(margin_left, integer, 0).
|
|
109
|
+
fmt_option(margin_right, integer, 0).
|
|
110
|
+
fmt_option(text_align, oneof([justify, left]), justify).
|
|
111
|
+
fmt_option(width, between(10,1000), 72).
|
|
112
|
+
|
|
113
|
+
default_state(State) :-
|
|
114
|
+
findall(Key-Value, fmt_option(Key, _, Value), Pairs),
|
|
115
|
+
dict_pairs(Dict, _, Pairs),
|
|
116
|
+
State = Dict.put(_{ style:[], list:[]}).
|
|
117
|
+
|
|
118
|
+
%! format_dom(+DOM, +State) is det.
|
|
119
|
+
%
|
|
120
|
+
% Format the given HTML DOM to `current_output` according to State.
|
|
121
|
+
|
|
122
|
+
format_dom([], _) :-
|
|
123
|
+
!.
|
|
124
|
+
format_dom([H|T], State) :-
|
|
125
|
+
format_dom(H, State),
|
|
126
|
+
!,
|
|
127
|
+
format_dom(T, State).
|
|
128
|
+
format_dom(Content, State) :-
|
|
129
|
+
Content = [H0|_],
|
|
130
|
+
\+ is_block_element(H0),
|
|
131
|
+
!,
|
|
132
|
+
( append(Inline, [H|T], Content),
|
|
133
|
+
is_block_element(H)
|
|
134
|
+
-> true
|
|
135
|
+
; Inline = Content
|
|
136
|
+
),
|
|
137
|
+
format_dom(element(p, [], Inline), State),
|
|
138
|
+
format_dom([H|T], State).
|
|
139
|
+
format_dom(element(html, _, Content), State) :-
|
|
140
|
+
!,
|
|
141
|
+
format_dom(Content, State).
|
|
142
|
+
format_dom(element(head, _, _), _) :-
|
|
143
|
+
!.
|
|
144
|
+
format_dom(element(body, _, Content), State) :-
|
|
145
|
+
!,
|
|
146
|
+
format_dom(Content, State).
|
|
147
|
+
format_dom(element(E, Attrs, Content), State) :-
|
|
148
|
+
!,
|
|
149
|
+
( format_element(E, Attrs, Content, State)
|
|
150
|
+
-> true
|
|
151
|
+
; debug(format(html), 'Skipped block element ~q', [E])
|
|
152
|
+
).
|
|
153
|
+
|
|
154
|
+
format_element(pre, Attrs, [Content], State) :-
|
|
155
|
+
!,
|
|
156
|
+
block_element(pre, Attrs, Top-Bottom, BlockAttrs, Style),
|
|
157
|
+
update_style(Style, State, State1),
|
|
158
|
+
ask_nl(Top),
|
|
159
|
+
emit_code(Content, BlockAttrs, State1),
|
|
160
|
+
ask_nl(Bottom).
|
|
161
|
+
format_element(table, Attrs, Content, State) :-
|
|
162
|
+
!,
|
|
163
|
+
block_element(table, Attrs, Top-Bottom, BlockAttrs, Style),
|
|
164
|
+
update_style(Style, State, State1),
|
|
165
|
+
state_par_properties(State1, BlockAttrs, BlockOptions),
|
|
166
|
+
ask_nl(Top),
|
|
167
|
+
emit_nl,
|
|
168
|
+
format_table(Content, Attrs, BlockOptions, State1),
|
|
169
|
+
ask_nl(Bottom).
|
|
170
|
+
format_element(hr, Attrs, _, State) :-
|
|
171
|
+
!,
|
|
172
|
+
block_element(hr, Attrs, Top-Bottom, BlockAttrs, Style),
|
|
173
|
+
update_style(Style, State, State1),
|
|
174
|
+
state_par_properties(State1, BlockAttrs, BlockOptions),
|
|
175
|
+
ask_nl(Top),
|
|
176
|
+
emit_nl,
|
|
177
|
+
emit_hr(Attrs, BlockOptions, State1),
|
|
178
|
+
ask_nl(Bottom).
|
|
179
|
+
format_element(Elem, Attrs, Content, State) :-
|
|
180
|
+
block_element(Elem, Attrs, Top-Bottom, BlockAttrs, Style),
|
|
181
|
+
!,
|
|
182
|
+
update_style(Style, State, State1),
|
|
183
|
+
block_words(Content, SubBlocks, Words, State1),
|
|
184
|
+
( Words == []
|
|
185
|
+
-> true
|
|
186
|
+
; ask_nl(Top),
|
|
187
|
+
emit_block(Words, BlockAttrs, State1),
|
|
188
|
+
ask_nl(Bottom)
|
|
189
|
+
),
|
|
190
|
+
( SubBlocks \== []
|
|
191
|
+
-> update_state_par_properties(BlockAttrs, State1, State2),
|
|
192
|
+
format_dom(SubBlocks, State2)
|
|
193
|
+
; true
|
|
194
|
+
).
|
|
195
|
+
format_element(Elem, Attrs, Content, State) :-
|
|
196
|
+
list_element(Elem, Attrs, Top-Bottom, State, State1),
|
|
197
|
+
!,
|
|
198
|
+
open_list(Elem, State1, State2),
|
|
199
|
+
ask_nl(Top),
|
|
200
|
+
format_list(Content, Elem, 1, State2),
|
|
201
|
+
ask_nl(Bottom).
|
|
202
|
+
format_element(Elem, Attrs, Content, State) :-
|
|
203
|
+
format_list_element(element(Elem, Attrs, Content), none, 0, State).
|
|
204
|
+
|
|
205
|
+
%! block_element(+El, +Attrs, -Margin, -ParOPtions, -Style)
|
|
206
|
+
%
|
|
207
|
+
% Describe a block element
|
|
208
|
+
|
|
209
|
+
block_element(El, Attrs, Margins, ParOptions, Style) :-
|
|
210
|
+
block_element(El, Margins0, ParOptions0, Style0),
|
|
211
|
+
( nonvar(Attrs),
|
|
212
|
+
element_css(El, Attrs, CSS)
|
|
213
|
+
-> css_block_options(CSS, Margins0, Margins, ParOptions, Style1),
|
|
214
|
+
append(Style1, Style0, Style2),
|
|
215
|
+
list_to_set(Style2, Style)
|
|
216
|
+
; Margins = Margins0,
|
|
217
|
+
ParOptions = ParOptions0,
|
|
218
|
+
Style = Style0
|
|
219
|
+
).
|
|
220
|
+
|
|
221
|
+
block_element(p, 1-2, [], []).
|
|
222
|
+
block_element(div, 1-1, [], []).
|
|
223
|
+
block_element(hr, 1-1, [], []).
|
|
224
|
+
block_element(h1, 2-2, [], [bold]).
|
|
225
|
+
block_element(h2, 2-2, [], [bold]).
|
|
226
|
+
block_element(h3, 2-2, [], [bold]).
|
|
227
|
+
block_element(h4, 2-2, [], [bold]).
|
|
228
|
+
block_element(pre, 2-2, [], []).
|
|
229
|
+
block_element(blockquote, 2-2, [margin_left(4), margin_right(4)], []).
|
|
230
|
+
block_element(table, 2-2, [], []).
|
|
231
|
+
|
|
232
|
+
list_element(ul, _, Margins, State0, State) :-
|
|
233
|
+
margins(4, 4, State0, State),
|
|
234
|
+
list_level_margins(State, Margins).
|
|
235
|
+
list_element(ol, _, Margins, State0, State) :-
|
|
236
|
+
margins(4, 4, State0, State),
|
|
237
|
+
list_level_margins(State, Margins).
|
|
238
|
+
list_element(dl, _, 2-2, State, State).
|
|
239
|
+
|
|
240
|
+
list_element(ul).
|
|
241
|
+
list_element(ol).
|
|
242
|
+
list_element(dl).
|
|
243
|
+
|
|
244
|
+
list_level_margins(State, 2-2) :-
|
|
245
|
+
nonvar(State),
|
|
246
|
+
State.get(list) == [],
|
|
247
|
+
!.
|
|
248
|
+
list_level_margins(_, 0-0).
|
|
249
|
+
|
|
250
|
+
format_list([], _, _, _).
|
|
251
|
+
format_list([H|T], Type, Nth, State) :-
|
|
252
|
+
format_list_element(H, Type, Nth, State),
|
|
253
|
+
( T == []
|
|
254
|
+
-> true
|
|
255
|
+
; Nth1 is Nth + 1,
|
|
256
|
+
format_list(T, Type, Nth1, State)
|
|
257
|
+
).
|
|
258
|
+
|
|
259
|
+
format_list_element(element(LE, Attrs, Content), Type, Nth, State) :-
|
|
260
|
+
setup_list_element(LE, Attrs, Type, Nth, ListParProps, State, State1),
|
|
261
|
+
block_words(Content, Blocks, Words, State1),
|
|
262
|
+
emit_block(Words, ListParProps, State1),
|
|
263
|
+
( Blocks \== []
|
|
264
|
+
-> ask_nl(2), % empty line before next par
|
|
265
|
+
update_state_par_properties(ListParProps, State1, State2),
|
|
266
|
+
format_dom(Blocks, State2)
|
|
267
|
+
; true
|
|
268
|
+
).
|
|
269
|
+
|
|
270
|
+
setup_list_element(li, _Attrs, _Type, Nth, ListParProps, State, State) :-
|
|
271
|
+
list_par_properties(State.list, Nth, ListParProps).
|
|
272
|
+
setup_list_element(dt, _Attrs, _Type, _Nth, [], State, State2) :-
|
|
273
|
+
margins(0, 0, State, State1),
|
|
274
|
+
update_style([bold], State1, State2).
|
|
275
|
+
setup_list_element(dd, _Attrs, _Type, _Nth, [], State, State1) :-
|
|
276
|
+
margins(4, 0, State, State1).
|
|
277
|
+
|
|
278
|
+
list_item_element(li).
|
|
279
|
+
list_item_element(dt).
|
|
280
|
+
list_item_element(dd).
|
|
281
|
+
|
|
282
|
+
list_par_properties([ul|_More], _, [bullet('\u2022')]).
|
|
283
|
+
list_par_properties([ol|_More], N, [bullet(N)]).
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
%! block_words(+Content, -RestContent, -Words, +State)
|
|
287
|
+
%
|
|
288
|
+
% Turn Content into a list of words with attributes and spaces.
|
|
289
|
+
|
|
290
|
+
block_words(Content, RC, Words, State) :-
|
|
291
|
+
phrase(bwords(Content, RC, State), Words0),
|
|
292
|
+
join_whitespace(Words0, Words1),
|
|
293
|
+
trim_line(Words1, Words).
|
|
294
|
+
|
|
295
|
+
bwords([], [], _) -->
|
|
296
|
+
!.
|
|
297
|
+
bwords([H|T], Rest, _State) -->
|
|
298
|
+
{ var(Rest),
|
|
299
|
+
is_block_element(H),
|
|
300
|
+
!,
|
|
301
|
+
Rest = [H|T]
|
|
302
|
+
}.
|
|
303
|
+
bwords([H|T], Rest, State) -->
|
|
304
|
+
!,
|
|
305
|
+
bwordsel(H, State),
|
|
306
|
+
bwords(T, Rest, State).
|
|
307
|
+
|
|
308
|
+
is_block_element(element(E,_,_)) :-
|
|
309
|
+
( block_element(E, _, _, _)
|
|
310
|
+
; list_element(E)
|
|
311
|
+
; list_item_element(E)
|
|
312
|
+
),
|
|
313
|
+
debug(format(html), 'Found block ~q', [E]),
|
|
314
|
+
!.
|
|
315
|
+
|
|
316
|
+
bwordsel(element(Elem, Attrs, Content), State) -->
|
|
317
|
+
{ styled_inline(Elem, Attrs, Margins, Style),
|
|
318
|
+
!,
|
|
319
|
+
update_style(Style, State, State1)
|
|
320
|
+
},
|
|
321
|
+
left_margin(Margins),
|
|
322
|
+
bwords(Content, [], State1),
|
|
323
|
+
right_margin(Margins).
|
|
324
|
+
bwordsel(element(br, _, _), _State) -->
|
|
325
|
+
[br([])].
|
|
326
|
+
bwordsel(CDATA, State) -->
|
|
327
|
+
{ atomic(CDATA),
|
|
328
|
+
!,
|
|
329
|
+
split_string(CDATA, " \n\t\r", "", Words)
|
|
330
|
+
},
|
|
331
|
+
words(Words, State).
|
|
332
|
+
bwordsel(element(Elem, _Attrs, _Content), _State) -->
|
|
333
|
+
{ debug(format(html), 'Skipped inline element ~q', [Elem]) }.
|
|
334
|
+
|
|
335
|
+
left_margin(0-_) --> !.
|
|
336
|
+
left_margin(N-_) --> [b(N,_)].
|
|
337
|
+
|
|
338
|
+
right_margin(_-0) --> !.
|
|
339
|
+
right_margin(_-N) --> [b(N,_)].
|
|
340
|
+
|
|
341
|
+
styled_inline(El, Attrs, Margins, Style) :-
|
|
342
|
+
styled_inline(El, Style0),
|
|
343
|
+
( nonvar(Attrs),
|
|
344
|
+
element_css(El, Attrs, CSS)
|
|
345
|
+
-> css_inline_options(CSS, Margins, Style1),
|
|
346
|
+
append(Style1, Style0, Style2),
|
|
347
|
+
list_to_set(Style2, Style)
|
|
348
|
+
; Style = Style0
|
|
349
|
+
).
|
|
350
|
+
|
|
351
|
+
styled_inline(b, [bold]).
|
|
352
|
+
styled_inline(strong, [bold]).
|
|
353
|
+
styled_inline(em, [bold]).
|
|
354
|
+
styled_inline(span, []).
|
|
355
|
+
styled_inline(i, [underline]).
|
|
356
|
+
styled_inline(a, [underline]).
|
|
357
|
+
styled_inline(var, []).
|
|
358
|
+
styled_inline(code, []).
|
|
359
|
+
|
|
360
|
+
%! words(+Tokens, +State)//
|
|
361
|
+
%
|
|
362
|
+
% Generate a list of w(Word,Len,Attrs) and b(Len,_) terms for words
|
|
363
|
+
% and (breakable) white space.
|
|
364
|
+
|
|
365
|
+
words([], _) --> [].
|
|
366
|
+
words([""|T0], State) -->
|
|
367
|
+
!,
|
|
368
|
+
{ skip_leading_spaces(T0, T) },
|
|
369
|
+
space,
|
|
370
|
+
words(T, State).
|
|
371
|
+
words([H|T], State) -->
|
|
372
|
+
word(H, State),
|
|
373
|
+
( {T==[]}
|
|
374
|
+
-> []
|
|
375
|
+
; { skip_leading_spaces(T, T1) },
|
|
376
|
+
space,
|
|
377
|
+
words(T1, State)
|
|
378
|
+
).
|
|
379
|
+
|
|
380
|
+
skip_leading_spaces([""|T0], T) :-
|
|
381
|
+
!,
|
|
382
|
+
skip_leading_spaces(T0, T).
|
|
383
|
+
skip_leading_spaces(L, L).
|
|
384
|
+
|
|
385
|
+
word(W, State) -->
|
|
386
|
+
{ string_length(W, Len),
|
|
387
|
+
( Style = State.get(style)
|
|
388
|
+
-> true
|
|
389
|
+
; Style = []
|
|
390
|
+
)
|
|
391
|
+
},
|
|
392
|
+
[w(W, Len, Style)].
|
|
393
|
+
|
|
394
|
+
space -->
|
|
395
|
+
[b(1,_)].
|
|
396
|
+
|
|
397
|
+
%! join_whitespace(Elements, Joined)
|
|
398
|
+
%
|
|
399
|
+
% Join consequtive space elements into a single white space element.
|
|
400
|
+
|
|
401
|
+
join_whitespace([], []).
|
|
402
|
+
join_whitespace([H0|T0], [H|T]) :-
|
|
403
|
+
join_whitespace(H0, H, T0, T1),
|
|
404
|
+
!,
|
|
405
|
+
join_whitespace(T1, T).
|
|
406
|
+
join_whitespace([H|T0], [H|T]) :-
|
|
407
|
+
join_whitespace(T0, T).
|
|
408
|
+
|
|
409
|
+
join_whitespace(b(Len0,_), b(Len,_), T0, T) :-
|
|
410
|
+
take_whitespace(T0, T, Len0, Len).
|
|
411
|
+
|
|
412
|
+
take_whitespace([b(Len1,_)|T0], T, Len0, Len) :-
|
|
413
|
+
!,
|
|
414
|
+
Len2 is max(Len1,Len0),
|
|
415
|
+
take_whitespace(T0, T, Len2, Len).
|
|
416
|
+
take_whitespace(L, L, Len, Len).
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
/*******************************
|
|
420
|
+
* STATE MANAGEMENT *
|
|
421
|
+
*******************************/
|
|
422
|
+
|
|
423
|
+
%! update_style(+Style:list, +State0, -State)
|
|
424
|
+
%
|
|
425
|
+
% Add Style to the current state.
|
|
426
|
+
|
|
427
|
+
update_style([], State, State) :-
|
|
428
|
+
!.
|
|
429
|
+
update_style(Extra, State0, State) :-
|
|
430
|
+
( get_dict(style, State0, Style0, State, Style)
|
|
431
|
+
-> add_style(Extra, Style0, Style)
|
|
432
|
+
; add_style(Extra, [], Style),
|
|
433
|
+
put_dict(style, State0, Style, State)
|
|
434
|
+
).
|
|
435
|
+
|
|
436
|
+
add_style(Extra, Style0, Style) :-
|
|
437
|
+
reverse(Extra, RevExtra),
|
|
438
|
+
foldl(add1_style, RevExtra, Style0, Style).
|
|
439
|
+
|
|
440
|
+
%! add1_style(+New, +Style0, -Style) is det.
|
|
441
|
+
%
|
|
442
|
+
% Modify the current text style.
|
|
443
|
+
|
|
444
|
+
add1_style(New, Style0, Style) :-
|
|
445
|
+
( style_overrides(New, Add, Overrides)
|
|
446
|
+
-> delete_all(Overrides, Style0, Style1),
|
|
447
|
+
append(Add, Style1, Style)
|
|
448
|
+
; Style = [New|Style0]
|
|
449
|
+
).
|
|
450
|
+
|
|
451
|
+
delete_all([], List, List).
|
|
452
|
+
delete_all([H|T], List0, List) :-
|
|
453
|
+
delete(List0, H, List1),
|
|
454
|
+
delete_all(T, List1, List).
|
|
455
|
+
|
|
456
|
+
style_overrides(normal, [], [bold]).
|
|
457
|
+
style_overrides(fg(C), [fg(C)], [fg(_), hfg(_)]).
|
|
458
|
+
style_overrides(bg(C), [bg(C)], [bg(_), hbg(_)]).
|
|
459
|
+
style_overrides(underline(false), [], [underline]).
|
|
460
|
+
|
|
461
|
+
margins(Left, Right, State0, State) :-
|
|
462
|
+
_{ margin_left:ML0, margin_right:MR0 } >:< State0,
|
|
463
|
+
ML is ML0 + Left,
|
|
464
|
+
MR is MR0 + Right,
|
|
465
|
+
State = State0.put(_{margin_left:ML, margin_right:MR}).
|
|
466
|
+
|
|
467
|
+
open_list(Type, State0, State) :-
|
|
468
|
+
get_dict(list, State0, Lists, State, [Type|Lists]).
|
|
469
|
+
|
|
470
|
+
update_state_par_properties([], State, State).
|
|
471
|
+
update_state_par_properties([H|T], State0, State) :-
|
|
472
|
+
H =.. [ Key, Value ],
|
|
473
|
+
State1 = State0.put(Key,Value),
|
|
474
|
+
update_state_par_properties(T, State1, State).
|
|
475
|
+
|
|
476
|
+
%! state_par_properties(+State, -ParProps)
|
|
477
|
+
%
|
|
478
|
+
% Get the paragraph shape properties from State. Eventually these two
|
|
479
|
+
% should be merged!
|
|
480
|
+
|
|
481
|
+
state_par_properties(State, Props) :-
|
|
482
|
+
Props0 = [ margin_left(LM),
|
|
483
|
+
margin_right(RM),
|
|
484
|
+
text_align(TA),
|
|
485
|
+
width(W),
|
|
486
|
+
pad(Pad)
|
|
487
|
+
],
|
|
488
|
+
_{margin_left:LM, margin_right:RM, text_align:TA, width:W,
|
|
489
|
+
pad:Pad} >:< State,
|
|
490
|
+
filled_par_props(Props0, Props).
|
|
491
|
+
|
|
492
|
+
filled_par_props([], []).
|
|
493
|
+
filled_par_props([H|T0], [H|T]) :-
|
|
494
|
+
arg(1, H, A),
|
|
495
|
+
nonvar(A),
|
|
496
|
+
!,
|
|
497
|
+
filled_par_props(T0, T).
|
|
498
|
+
filled_par_props([_|T0], T) :-
|
|
499
|
+
filled_par_props(T0, T).
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
state_par_properties(State, Options, BlockOptions) :-
|
|
503
|
+
state_par_properties(State, Options0),
|
|
504
|
+
foldl(merge_par_option, Options, Options0, BlockOptions).
|
|
505
|
+
|
|
506
|
+
merge_par_option(margin_left(ML0), Options0, [margin_left(ML)|Options1]) :-
|
|
507
|
+
!,
|
|
508
|
+
select_option(margin_left(ML1), Options0, Options1, 0),
|
|
509
|
+
ML is ML0+ML1.
|
|
510
|
+
merge_par_option(margin_right(MR0), Options0, [margin_right(MR)|Options1]) :-
|
|
511
|
+
!,
|
|
512
|
+
select_option(margin_right(MR1), Options0, Options1, 0),
|
|
513
|
+
MR is MR0+MR1.
|
|
514
|
+
merge_par_option(Opt, Options0, Options) :-
|
|
515
|
+
merge_options([Opt], Options0, Options).
|
|
516
|
+
|
|
517
|
+
%! emit_block(+Words, +Options, +State) is det.
|
|
518
|
+
%
|
|
519
|
+
% Format a block given Words inline elements, Options and State. Calls
|
|
520
|
+
% format_paragraph/2 after finalizing the paragraph shape and using
|
|
521
|
+
% the newline logic.
|
|
522
|
+
|
|
523
|
+
emit_block([], _, _) :-
|
|
524
|
+
!.
|
|
525
|
+
emit_block(Words, Options, State) :-
|
|
526
|
+
state_par_properties(State, Options, BlockOptions),
|
|
527
|
+
use_current_position(BlockOptions, BlockOptions1),
|
|
528
|
+
ask_nl(1),
|
|
529
|
+
emit_nl,
|
|
530
|
+
format_paragraph(Words, BlockOptions1),
|
|
531
|
+
ask_nl(1).
|
|
532
|
+
|
|
533
|
+
use_current_position(Options0, Options) :-
|
|
534
|
+
nb_current(nl_pending, start),
|
|
535
|
+
line_position(current_output, Pos),
|
|
536
|
+
Pos > 0,
|
|
537
|
+
!,
|
|
538
|
+
Hang is -Pos,
|
|
539
|
+
Options = [hang(Hang)|Options0].
|
|
540
|
+
use_current_position(Options, Options).
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
%! init_nl is det.
|
|
544
|
+
%! init_nl(-State) is det.
|
|
545
|
+
%! exit_nl(+State) is det.
|
|
546
|
+
%
|
|
547
|
+
% Initialize/finalize the newline logic.
|
|
548
|
+
|
|
549
|
+
init_nl :-
|
|
550
|
+
nb_setval(nl_pending, start).
|
|
551
|
+
|
|
552
|
+
init_nl(Old) :-
|
|
553
|
+
( nb_current(nl_pending, Old)
|
|
554
|
+
-> true
|
|
555
|
+
; Old = []
|
|
556
|
+
),
|
|
557
|
+
nb_setval(nl_pending, start).
|
|
558
|
+
exit_nl(Old) :-
|
|
559
|
+
nb_setval(nl_pending, Old).
|
|
560
|
+
|
|
561
|
+
ask_nl(N) :-
|
|
562
|
+
( nb_current(nl_pending, N0)
|
|
563
|
+
-> ( N0 == start
|
|
564
|
+
-> true
|
|
565
|
+
; integer(N0)
|
|
566
|
+
-> N1 is max(N0, N),
|
|
567
|
+
nb_setval(nl_pending, N1)
|
|
568
|
+
; nb_setval(nl_pending, N)
|
|
569
|
+
)
|
|
570
|
+
; nb_setval(nl_pending, N)
|
|
571
|
+
).
|
|
572
|
+
|
|
573
|
+
emit_nl :-
|
|
574
|
+
( nb_current(nl_pending, N),
|
|
575
|
+
integer(N)
|
|
576
|
+
-> forall(between(1,N,_), nl)
|
|
577
|
+
; true
|
|
578
|
+
),
|
|
579
|
+
nb_setval(nl_pending, 0).
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
/*******************************
|
|
583
|
+
* PRE *
|
|
584
|
+
*******************************/
|
|
585
|
+
|
|
586
|
+
%! emit_code(+Content, +BlockAttrs, +State)
|
|
587
|
+
|
|
588
|
+
emit_code(Content, BlockAttrs, State) :-
|
|
589
|
+
Style = State.style,
|
|
590
|
+
split_string(Content, "\n", "", Lines),
|
|
591
|
+
option(margin_left(LM0), BlockAttrs, 4),
|
|
592
|
+
LM is LM0+State.margin_left,
|
|
593
|
+
ask_nl(1),
|
|
594
|
+
emit_nl,
|
|
595
|
+
emit_code_lines(Lines, 1, LM, Style),
|
|
596
|
+
ask_nl(1).
|
|
597
|
+
|
|
598
|
+
emit_code_lines([], _, _, _).
|
|
599
|
+
emit_code_lines([H|T], LineNo, LM, Style) :-
|
|
600
|
+
emit_code_line(H, LineNo, LM, Style),
|
|
601
|
+
LineNo1 is LineNo + 1,
|
|
602
|
+
emit_code_lines(T, LineNo1, LM, Style).
|
|
603
|
+
|
|
604
|
+
emit_code_line(Line, _LineNo, LM, Style) :-
|
|
605
|
+
emit_nl,
|
|
606
|
+
emit_indent(LM),
|
|
607
|
+
( Style == []
|
|
608
|
+
-> write(Line)
|
|
609
|
+
; ansi_format(Style, '~s', [Line])
|
|
610
|
+
),
|
|
611
|
+
ask_nl(1).
|
|
612
|
+
|
|
613
|
+
emit_indent(N) :-
|
|
614
|
+
forall(between(1, N, _),
|
|
615
|
+
put_char(' ')).
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
/*******************************
|
|
619
|
+
* TABLES *
|
|
620
|
+
*******************************/
|
|
621
|
+
|
|
622
|
+
%! format_table(+Content, +Attrs, +BlockAttrs, +State) is det.
|
|
623
|
+
|
|
624
|
+
format_table(Content, Attrs, BlockAttrs, State) :-
|
|
625
|
+
tty_state(TTY),
|
|
626
|
+
option(margin_left(ML), BlockAttrs, 0),
|
|
627
|
+
option(margin_right(MR), BlockAttrs, 0),
|
|
628
|
+
MaxTableWidth is State.width - ML - MR,
|
|
629
|
+
table_cell_state(Attrs, State, CellState),
|
|
630
|
+
phrase(rows(Content), Rows),
|
|
631
|
+
columns(Rows, Columns),
|
|
632
|
+
maplist(auto_column_width(CellState.put(tty,false)), Columns, Widths),
|
|
633
|
+
column_widths(Widths, MaxTableWidth, ColWidths),
|
|
634
|
+
maplist(format_row(ColWidths, CellState.put(tty,TTY), ML), Rows).
|
|
635
|
+
|
|
636
|
+
tty_state(TTY) :-
|
|
637
|
+
stream_property(current_output, tty(true)),
|
|
638
|
+
!,
|
|
639
|
+
TTY = true.
|
|
640
|
+
tty_state(false).
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
%! column_widths(+AutoWidths, +MaxTableWidth, -Widths) is det.
|
|
644
|
+
%
|
|
645
|
+
% Establish the widths of the columns. AutoWidths is a list of widths
|
|
646
|
+
% for each of the columns if no folding is applied.
|
|
647
|
+
|
|
648
|
+
column_widths(Widths, MaxTableWidth, Widths) :-
|
|
649
|
+
sum_list(Widths, AutoWidth),
|
|
650
|
+
AutoWidth =< MaxTableWidth,
|
|
651
|
+
!.
|
|
652
|
+
column_widths(AutoWidths, MaxTableWidth, Widths) :-
|
|
653
|
+
sort(0, >=, AutoWidths, Sorted),
|
|
654
|
+
append(Wrapped, Keep, Sorted),
|
|
655
|
+
sum_list(Keep, KeepWidth),
|
|
656
|
+
KeepWidth < MaxTableWidth/2,
|
|
657
|
+
length(Wrapped, NWrapped),
|
|
658
|
+
WideWidth is round((MaxTableWidth-KeepWidth)/NWrapped),
|
|
659
|
+
( [KeepW|_] = Keep
|
|
660
|
+
-> true
|
|
661
|
+
; KeepW = 0
|
|
662
|
+
),
|
|
663
|
+
!,
|
|
664
|
+
maplist(truncate_column(KeepW,WideWidth), AutoWidths, Widths).
|
|
665
|
+
|
|
666
|
+
truncate_column(Keep, WideWidth, AutoWidth, Width) :-
|
|
667
|
+
( AutoWidth =< Keep
|
|
668
|
+
-> Width = AutoWidth
|
|
669
|
+
; Width = WideWidth
|
|
670
|
+
).
|
|
671
|
+
|
|
672
|
+
table_cell_state(Attrs, State, CellState) :-
|
|
673
|
+
( element_css(table, Attrs, CSS)
|
|
674
|
+
-> true
|
|
675
|
+
; CSS = []
|
|
676
|
+
),
|
|
677
|
+
option(padding_left(PL), CSS, 1),
|
|
678
|
+
option(padding_right(PR), CSS, 1),
|
|
679
|
+
CellState = State.put(_{margin_left:PL, margin_right:PR}).
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
%! rows(+Content, -Rows) is det.
|
|
683
|
+
|
|
684
|
+
rows([]) --> [].
|
|
685
|
+
rows([H|T]) --> rows(H), rows(T).
|
|
686
|
+
rows([element(tbody,_,Content)|T]) --> rows(Content), rows(T).
|
|
687
|
+
rows([element(tr,Attrs,Columns)|T]) --> [row(Columns, Attrs)], rows(T).
|
|
688
|
+
|
|
689
|
+
%! columns(+Rows, -Columns) is det.
|
|
690
|
+
%
|
|
691
|
+
% Transpose the table, filling missing columns with an empty `td`
|
|
692
|
+
% element as needed.
|
|
693
|
+
|
|
694
|
+
columns(Rows, Columns) :-
|
|
695
|
+
columns(Rows, 1, Columns).
|
|
696
|
+
|
|
697
|
+
columns(Rows, I, Columns) :-
|
|
698
|
+
maplist(row_column(I, Found), Rows, H),
|
|
699
|
+
( Found == true
|
|
700
|
+
-> Columns = [H|T],
|
|
701
|
+
I2 is I + 1,
|
|
702
|
+
columns(Rows, I2, T)
|
|
703
|
+
; Columns = []
|
|
704
|
+
).
|
|
705
|
+
|
|
706
|
+
row_column(I, Found, row(Columns, _Attrs), Cell) :-
|
|
707
|
+
( nth1(I, Columns, Cell)
|
|
708
|
+
-> Found = true
|
|
709
|
+
; Cell = element(td,[],[])
|
|
710
|
+
).
|
|
711
|
+
|
|
712
|
+
auto_column_width(State, Col, Width) :-
|
|
713
|
+
maplist(auto_cell_width(State), Col, Widths),
|
|
714
|
+
max_list(Widths, Width).
|
|
715
|
+
|
|
716
|
+
auto_cell_width(State, Cell, Width) :-
|
|
717
|
+
cell_colspan(Cell, 1),
|
|
718
|
+
!,
|
|
719
|
+
format_cell_to_string(Cell, 1_000, State, String),
|
|
720
|
+
split_string(String, "\n", "", Lines),
|
|
721
|
+
maplist(string_length, Lines, LineW),
|
|
722
|
+
max_list(LineW, Width0),
|
|
723
|
+
Width is Width0 + State.margin_right.
|
|
724
|
+
auto_cell_width(_, _, 0).
|
|
725
|
+
|
|
726
|
+
%! format_row(+ColWidths, +State, +MarginLeft, +Row)
|
|
727
|
+
%
|
|
728
|
+
% Format a single row.
|
|
729
|
+
|
|
730
|
+
format_row(ColWidths, State, MarginLeft, Row) :-
|
|
731
|
+
hrule(Row, ColWidths, MarginLeft),
|
|
732
|
+
format_cells(ColWidths, CWSpanned, 1, Row, State, Cells),
|
|
733
|
+
format_row_lines(1, CWSpanned, Cells, MarginLeft).
|
|
734
|
+
|
|
735
|
+
hrule(row(_, Attrs), ColWidths, MarginLeft) :-
|
|
736
|
+
attrs_classes(Attrs, Classes),
|
|
737
|
+
memberchk(hline, Classes),
|
|
738
|
+
!,
|
|
739
|
+
sum_list(ColWidths, RuleLen),
|
|
740
|
+
format('~N~t~*|~`-t~*+', [MarginLeft, RuleLen]).
|
|
741
|
+
hrule(_, _, _).
|
|
742
|
+
|
|
743
|
+
format_row_lines(LineNo, Widths, Cells, MarginLeft) :-
|
|
744
|
+
nth_row_line(Widths, 1, LineNo, Cells, CellLines, Found),
|
|
745
|
+
( Found == true
|
|
746
|
+
-> emit_nl,
|
|
747
|
+
emit_indent(MarginLeft),
|
|
748
|
+
maplist(emit_cell_line, CellLines),
|
|
749
|
+
ask_nl(1),
|
|
750
|
+
LineNo1 is LineNo + 1,
|
|
751
|
+
format_row_lines(LineNo1, Widths, Cells, MarginLeft)
|
|
752
|
+
; true
|
|
753
|
+
).
|
|
754
|
+
|
|
755
|
+
emit_cell_line(Line-Pad) :-
|
|
756
|
+
write(Line),
|
|
757
|
+
forall(between(1,Pad,_), put_char(' ')).
|
|
758
|
+
|
|
759
|
+
nth_row_line([], _, _, _, [], _).
|
|
760
|
+
nth_row_line([ColW|CWT], CellNo, LineNo, Cells, [CellLine-Pad|ColLines],
|
|
761
|
+
Found) :-
|
|
762
|
+
nth1(CellNo, Cells, CellLines),
|
|
763
|
+
( nth1(LineNo, CellLines, CellLine)
|
|
764
|
+
-> Found = true,
|
|
765
|
+
Pad = 0
|
|
766
|
+
; CellLine = '', Pad = ColW
|
|
767
|
+
),
|
|
768
|
+
CellNo1 is CellNo + 1,
|
|
769
|
+
nth_row_line(CWT, CellNo1, LineNo, Cells, ColLines, Found).
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
%! format_cells(+ColWidths, -CWSpanned, +Col0, +Row, +State, -Cells)
|
|
773
|
+
%
|
|
774
|
+
% Format the cells for Row. The resulting Cells list is a list of
|
|
775
|
+
% cells, where each cell is a list of strings, each representing a
|
|
776
|
+
% line.
|
|
777
|
+
|
|
778
|
+
format_cells([], [], _, _, _, []) :- !.
|
|
779
|
+
format_cells(CWidths, [HW|TW], Column, Row, State, [HC|TC]) :-
|
|
780
|
+
Row = row(Columns, _Attrs),
|
|
781
|
+
nth1(Column, Columns, Cell),
|
|
782
|
+
cell_colspan(Cell, CWidths, HW, TW0),
|
|
783
|
+
cell_align(Cell, Align),
|
|
784
|
+
format_cell_to_string(Cell, HW, State.put(_{pad:' ', text_align:Align}), String),
|
|
785
|
+
split_string(String, "\n", "", HC),
|
|
786
|
+
Column1 is Column+1,
|
|
787
|
+
format_cells(TW0, TW, Column1, Row, State, TC).
|
|
788
|
+
|
|
789
|
+
cell_colspan(Cell, CWidths, HW, TW) :-
|
|
790
|
+
cell_colspan(Cell, Span),
|
|
791
|
+
length(SpanW, Span),
|
|
792
|
+
append(SpanW, TW, CWidths),
|
|
793
|
+
sum_list(SpanW, HW).
|
|
794
|
+
|
|
795
|
+
cell_colspan(element(_,Attrs,_), Span) :-
|
|
796
|
+
( memberchk(colspan=SpanA, Attrs),
|
|
797
|
+
atom_number(SpanA, SpanN)
|
|
798
|
+
-> Span = SpanN
|
|
799
|
+
; Span = 1
|
|
800
|
+
).
|
|
801
|
+
|
|
802
|
+
%! cell_align(+Cell, -Align) is det.
|
|
803
|
+
%
|
|
804
|
+
% Determine the cell alignment. Currently supports the (deprecated)
|
|
805
|
+
% HTML4 `align=Align` possibility and very naively parsed CSS
|
|
806
|
+
% ``text-align:center``, etc.
|
|
807
|
+
|
|
808
|
+
cell_align(element(_,Attrs,_), Align) :-
|
|
809
|
+
( memberchk(align=AlignA, Attrs)
|
|
810
|
+
-> Align = AlignA
|
|
811
|
+
; memberchk(style=Style, Attrs),
|
|
812
|
+
style_css_attrs(Style, Props),
|
|
813
|
+
memberchk('text-align'(AlignA), Props)
|
|
814
|
+
-> Align = AlignA
|
|
815
|
+
; Align = left
|
|
816
|
+
).
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
%! format_cell_to_string(+Cell, +ColWidth, +State, -String) is det.
|
|
820
|
+
%
|
|
821
|
+
% Format Cell to a String, given the state and column width.
|
|
822
|
+
|
|
823
|
+
format_cell_to_string(element(_,_,[]), ColWidth, State, String) :-
|
|
824
|
+
Pad = State.get(pad),
|
|
825
|
+
!,
|
|
826
|
+
length(Chars, ColWidth),
|
|
827
|
+
maplist(=(Pad), Chars),
|
|
828
|
+
atomics_to_string(Chars, String).
|
|
829
|
+
format_cell_to_string(Cell, ColWidth, State, String) :-
|
|
830
|
+
setup_call_cleanup(
|
|
831
|
+
init_nl(NlState),
|
|
832
|
+
with_output_to(
|
|
833
|
+
string(String),
|
|
834
|
+
format_cell(Cell, ColWidth, State)),
|
|
835
|
+
exit_nl(NlState)).
|
|
836
|
+
|
|
837
|
+
format_cell(element(E, _Attrs, Content), ColWidth, State) :-
|
|
838
|
+
set_stream(current_output, tty(State.tty)),
|
|
839
|
+
cell_element(E, Style),
|
|
840
|
+
update_style(Style, State.put(width, ColWidth), CellState),
|
|
841
|
+
block_words(Content, Blocks, Words, CellState),
|
|
842
|
+
emit_block(Words, [], CellState),
|
|
843
|
+
( Blocks \== []
|
|
844
|
+
-> format_dom(Blocks, CellState)
|
|
845
|
+
; true
|
|
846
|
+
).
|
|
847
|
+
|
|
848
|
+
cell_element(td, [normal]).
|
|
849
|
+
cell_element(th, [bold]).
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
%! emit_hr(+Attrs, +BlockOptions, +State)
|
|
853
|
+
%
|
|
854
|
+
% Emit a horizontal rule.
|
|
855
|
+
|
|
856
|
+
emit_hr(_Attrs, BlockAttrs, State) :-
|
|
857
|
+
option(margin_left(ML), BlockAttrs, 0),
|
|
858
|
+
option(margin_right(MR), BlockAttrs, 0),
|
|
859
|
+
RuleWidth is State.width - ML - MR,
|
|
860
|
+
Style = State.style,
|
|
861
|
+
emit_indent(ML),
|
|
862
|
+
( Style == []
|
|
863
|
+
-> format('~|~*t~*+', [0'-, RuleWidth])
|
|
864
|
+
; ansi_format(Style, '~|~*t~*+', [0'-, RuleWidth])
|
|
865
|
+
).
|