parsing html xml parsing expression grammar peg
parsing expression grammar (peg)
- 2025-10-01
- explain parsing expression grammar
- https://x.com/i/grok/share/pjjbWz5QnmSlzzMdYSXegNaw0
- 2025-10-01
- parsing expression grammar libraries in python fsharp golang
- https://x.com/i/grok/share/hqJiFlkMM28wHlKGp0XDPA3Za
parsing html xml
- think about parsing html problem.
- e.g. i often need to redo html tags, e.g. vocabulary word88
- using emacs lisp with regex is very tedius, cuz cannot parse nesting.
- look into PEG parsing expression grammar. or html parser.
- sample page
- SAT Words
;; -*- coding: utf-8; lexical-binding: t; -*- ;; 2025-10-03 ;; show a example of elisp code of peg-run with success-function ;; from grok ai. ;; does not work (require 'peg) (defun my-peg-success-function (result) "Function called when PEG parsing succeeds." (message "Parsing succeeded! Result: %s" result)) (defun parse-example-string (input) "Parse INPUT string using PEG with a success function." (peg-run (peg example-grammar ((number (and (substring (+ [0-9])))) (example-grammar number))) input #'my-peg-success-function)) ;; Example usage (parse-example-string "12345") ;; This code: ;; Defines a simple PEG grammar to match a number (one or more digits). ;; Uses peg-run to parse an input string. ;; Specifies my-peg-success-function as the success function, which will be called with the parsing result if successful. ;; When run with "12345", it will output a message with the parsed result. ;; The success function is invoked only when the parsing succeeds, receiving the parsed result as its argument.
when done study pasing html reformat my site citation.
〔<cite>...</cite> <time>...</time> @ <a ...>...</a>〕 <cite>...</cite> <time>...</time> @ <a ...>...</a>