{"id":19829680,"url":"https://github.com/dyalog/bb","last_synced_at":"2025-02-28T17:19:57.588Z","repository":{"id":19158414,"uuid":"22389887","full_name":"Dyalog/bb","owner":"Dyalog","description":"Brian Becker's Sandbox","archived":false,"fork":false,"pushed_at":"2025-02-28T03:48:00.000Z","size":1650,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-28T11:21:40.120Z","etag":null,"topics":["apl","dyalog","dyalog-apl","dyalog-library"],"latest_commit_sha":null,"homepage":"","language":"APL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dyalog.png","metadata":{"files":{"readme":"README.md","changelog":"changes.dyalog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-29T18:01:37.000Z","updated_at":"2025-02-28T03:48:03.000Z","dependencies_parsed_at":"2025-02-28T04:40:06.173Z","dependency_job_id":"f7e5e9e2-70fd-4902-817c-e003ba8f1772","html_url":"https://github.com/Dyalog/bb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dyalog%2Fbb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dyalog%2Fbb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dyalog%2Fbb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dyalog%2Fbb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dyalog","download_url":"https://codeload.github.com/Dyalog/bb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241188945,"owners_count":19924715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apl","dyalog","dyalog-apl","dyalog-library"],"created_at":"2024-11-12T11:19:33.133Z","updated_at":"2025-02-28T17:19:57.570Z","avatar_url":"https://github.com/Dyalog.png","language":"APL","funding_links":[],"categories":[],"sub_categories":[],"readme":"bb\n==\n\nBrian's Playground\n\nThis repository contains stuff I've tinkered with, some of it may be interesting, some of it may be incomplete.  The contents are provided \"as is\".\n\n----------\n\n## `xhtml.dyalog` namespace\n\nContains utilities to:\n- convert HTML to XHTML which is subsequently able to be parsed by `⎕XML`\n- search and extract elements from the result of `⎕XML`\n\n### `HTMLtoXHTML`\n`xhtml ← xhtml.HTMLtoXHTML html`\n`html` is a character vector containing HTML\n`xhtml` is a matrix form of the XHTML\n\n`HTMLtoXHTML` assumes that the HTML is reasonably formed (e.g. open tags have corresponding closing tags). It handles most, but probably not all, HTMLisms of some elements not requiring a closing tag.\n\n### `Xfind`\n`boolvec ← xml xhtml.Xfind spec`\n`xml` is an XML matrix (could be XHTML, but doesn't have to be)\n`spec` is a delimited-string search specification (first character is the delimiter) in the form `/levels/elements/content/attribute/value` where:\n- `levels`, if non-empty, specifies the level(s) to consider in the search.  For example:\n    - `3` specifies level 3 elements only, `3-` level 3 and lower (to 0), `3+` level 3 and higher, `3-5` levels 3 through 5\n- `elements` is a space-delimited list of elements to select\n- `content` is case-insensitive content to search for using `⍷`\n- `attribute` is a case-sensitive attribute name to exactly search for\n- `value` is a case-insensitive attribute value to search for using `⍷`, if no `attribute` is specified, all attributes will be searched.\n\n`boolvec` is a Boolean vector marking matching elements\n\nExamples:\n```\n\n      xml xhtml.Xfind '//table//class/results' ⍝ find all \u003ctable\u003e elements with a class attribute containing 'results'\n\n      xml xhtml.Xfind '/2////foobar' ⍝ find all level 2 elements with any attribute containing 'foobar'\n\n      xml xhtml.Xfind '/3+/th td/bloof' ⍝ find all level 3 or higher \u003cth\u003e or \u003ctd\u003e elements containing 'bloof' \n```\n### `Xsel`\n`elements ← xml Xsel boolvec`\n`xml` is an XML matrix (could be XHTML, but doesn't have to be)\n`boolvec` is a Boolean vector with as many elements as rows in `xml`\n`elements` is a nested vector of elements marked by `boolvec` and their descendants\n\n### Typical Use Case\nIn general, you'll convert some HTML to XHTML and then search for and extract element of interest to you.  For example:\n\n```\n\n      resp ← HttpCommand.Get 'someurl.com/somefile.html' ⍝ make a request \n      'request failed' ⎕SIGNAL (0 200≢resp.(rc HttpStatus))/777 ⍝ check that it succeeded\n      h ← resp.Data ⍝ grab the response data\n      x ← xhtml.HTMLtoXHTML h ⍝ convert to XHTML\n      mytables ← x xhtml.Xsel x xhtml.Xfind '//table//class/results' ⍝ extract all the \u003ctable\u003e elements with a class attribute containing \"results\"\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyalog%2Fbb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdyalog%2Fbb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyalog%2Fbb/lists"}